forked from OSchip/llvm-project
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
This commit is contained in:
parent
8cea92b972
commit
4ec013ac83
|
@ -467,11 +467,14 @@ template <class ELFT> void LinkerScript<ELFT>::assignAddresses() {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
|
||||
# RUN: echo "SECTIONS {foo 0 : {*(foo*)} }" > %t.script
|
||||
# RUN: not ld.lld -o %t --script %t.script %t.o -shared 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: Not enough space for ELF and program headers
|
||||
|
||||
.section foo, "a"
|
||||
.quad 0
|
Loading…
Reference in New Issue