[lld] r287569 - Use the correct page size.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 12:20:04 PST 2016


Author: rafael
Date: Mon Nov 21 14:20:04 2016
New Revision: 287569

URL: http://llvm.org/viewvc/llvm-project?rev=287569&view=rev
Log:
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.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/test/ELF/linkerscript/header-addr.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=287569&r1=287568&r2=287569&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Nov 21 14:20:04 2016
@@ -717,7 +717,7 @@ void LinkerScript<ELFT>::assignAddresses
 
   // 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;
 

Modified: lld/trunk/test/ELF/linkerscript/header-addr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/header-addr.s?rev=287569&r1=287568&r2=287569&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/header-addr.s (original)
+++ lld/trunk/test/ELF/linkerscript/header-addr.s Mon Nov 21 14:20:04 2016
@@ -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: ]




More information about the llvm-commits mailing list