Error out instead of producing a corrupt PT_LOAD.

What bfd and gold do is give up in putting the headers in the PT_LOAD
and just start the PT_LOAD in the second page.

llvm-svn: 281660
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7ae61e9..f58f4d7 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -467,11 +467,14 @@
     }
   }
 
+  uintX_t HeaderSize =
+      Out<ELFT>::ElfHeader->getSize() + Out<ELFT>::ProgramHeaders->getSize();
+  if (HeaderSize > MinVA)
+    fatal("Not enough space for ELF and program headers");
+
   // ELF and Program headers need to be right before the first section in
   // memory. Set their addresses accordingly.
-  MinVA = alignDown(MinVA - Out<ELFT>::ElfHeader->getSize() -
-                        Out<ELFT>::ProgramHeaders->getSize(),
-                    Target->PageSize);
+  MinVA = alignDown(MinVA - HeaderSize, Target->PageSize);
   Out<ELFT>::ElfHeader->setVA(MinVA);
   Out<ELFT>::ProgramHeaders->setVA(Out<ELFT>::ElfHeader->getSize() + MinVA);
 }