Use the correct page size.

Config->MaxPageSize is what we use for the segment alignment, so that
is the one that we have to use for placing the header.

llvm-svn: 287569
This commit is contained in:
Rafael Espindola 2016-11-21 20:20:04 +00:00
parent dac3808873
commit 28d5f059ae
2 changed files with 22 additions and 1 deletions

View File

@ -717,7 +717,7 @@ void LinkerScript<ELFT>::assignAddresses(std::vector<PhdrEntry<ELFT>> &Phdrs) {
// ELF and Program headers need to be right before the first section in
// memory. Set their addresses accordingly.
MinVA = alignDown(MinVA - HeaderSize, Target->PageSize);
MinVA = alignDown(MinVA - HeaderSize, Config->MaxPageSize);
Out<ELFT>::ElfHeader->Addr = MinVA;
Out<ELFT>::ProgramHeaders->Addr = Out<ELFT>::ElfHeader->Size + MinVA;

View File

@ -24,3 +24,24 @@
# CHECK-NEXT: Alignment: 4096
# CHECK-NEXT: }
# CHECK-NEXT: ]
# RUN: ld.lld -o %t2.so --script %t.script %t.o -shared -z max-page-size=0x2000
# RUN: llvm-readobj -program-headers %t2.so \
# RUN: | FileCheck --check-prefix=MAXPAGE %s
# MAXPAGE: ProgramHeaders [
# MAXPAGE-NEXT: ProgramHeader {
# MAXPAGE-NEXT: Type: PT_LOAD
# MAXPAGE-NEXT: Offset: 0x40
# MAXPAGE-NEXT: VirtualAddress: 0x40
# MAXPAGE-NEXT: PhysicalAddress: 0x40
# MAXPAGE-NEXT: FileSize: 8272
# MAXPAGE-NEXT: MemSize: 8272
# MAXPAGE-NEXT: Flags [
# MAXPAGE-NEXT: PF_R
# MAXPAGE-NEXT: PF_W
# MAXPAGE-NEXT: PF_X
# MAXPAGE-NEXT: ]
# MAXPAGE-NEXT: Alignment: 8192
# MAXPAGE-NEXT: }
# MAXPAGE-NEXT: ]