[lld] r278889 - [ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.

Michael J. Spencer via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 19:10:52 PDT 2016


Author: mspencer
Date: Tue Aug 16 21:10:51 2016
New Revision: 278889

URL: http://llvm.org/viewvc/llvm-project?rev=278889&view=rev
Log:
[ELF] Set MAXPAGESIZE to 2MiB on x86-64 to match bfd and gold.

The FreeBSD kernel relies on this behavior to not overwrite the boot loader.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Target.h
    lld/trunk/test/ELF/linkerscript-outsections-addr.s
    lld/trunk/test/ELF/linkerscript/linkerscript-data-segment-relro.s
    lld/trunk/test/ELF/linkerscript/linkerscript-locationcounter.s
    lld/trunk/test/ELF/linkerscript/linkerscript-symbol-assignexpr.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Aug 16 21:10:51 2016
@@ -1138,8 +1138,10 @@ Expr ScriptParser::readExpr1(Expr Lhs, i
 }
 
 uint64_t static getConstant(StringRef S) {
-  if (S == "COMMONPAGESIZE" || S == "MAXPAGESIZE")
+  if (S == "COMMONPAGESIZE")
     return Target->PageSize;
+  if (S == "MAXPAGESIZE")
+    return Target->MaxPageSize;
   error("unknown constant: " + S);
   return 0;
 }

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Aug 16 21:10:51 2016
@@ -545,6 +545,7 @@ void X86TargetInfo::relaxTlsLdToLe(uint8
 }
 
 template <class ELFT> X86_64TargetInfo<ELFT>::X86_64TargetInfo() {
+  MaxPageSize = 0x200000; // 2MiB
   CopyRel = R_X86_64_COPY;
   GotRel = R_X86_64_GLOB_DAT;
   PltRel = R_X86_64_JUMP_SLOT;

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Tue Aug 16 21:10:51 2016
@@ -62,6 +62,7 @@ public:
 
   unsigned TlsGdRelaxSkip = 1;
   unsigned PageSize = 4096;
+  unsigned MaxPageSize = 4096;
 
   // On freebsd x86_64 the first page cannot be mmaped.
   // On linux that is controled by vm.mmap_min_addr. At least on some x86_64

Modified: lld/trunk/test/ELF/linkerscript-outsections-addr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript-outsections-addr.s?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript-outsections-addr.s (original)
+++ lld/trunk/test/ELF/linkerscript-outsections-addr.s Tue Aug 16 21:10:51 2016
@@ -80,7 +80,7 @@
 #CHECK:    Flags [
 #CHECK:      SHF_ALLOC
 #CHECK:    ]
-#CHECK:    Address: 0x4008
+#CHECK:    Address: 0x203008
 #CHECK:    Offset: 0x2008
 #CHECK:    Size: 8
 #CHECK:    Link: 0

Modified: lld/trunk/test/ELF/linkerscript/linkerscript-data-segment-relro.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-data-segment-relro.s?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-data-segment-relro.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-data-segment-relro.s Tue Aug 16 21:10:51 2016
@@ -31,7 +31,7 @@
 # CHECK-NEXT:      SHF_ALLOC
 # CHECK-NEXT:      SHF_WRITE
 # CHECK-NEXT:    ]
-# CHECK-NEXT:    Address: 0x10F0
+# CHECK-NEXT:    Address: 0x2000F0
 # CHECK-NEXT:    Offset: 0x10F0
 # CHECK-NEXT:    Size:
 # CHECK-NEXT:    Link:
@@ -47,7 +47,7 @@
 # CHECK-NEXT:      SHF_ALLOC
 # CHECK-NEXT:      SHF_WRITE
 # CHECK-NEXT:    ]
-# CHECK-NEXT:    Address: 0x2000
+# CHECK-NEXT:    Address: 0x201000
 # CHECK-NEXT:    Offset: 0x2000
 # CHECK-NEXT:    Size:
 # CHECK-NEXT:    Link:

Modified: lld/trunk/test/ELF/linkerscript/linkerscript-locationcounter.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-locationcounter.s?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-locationcounter.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-locationcounter.s Tue Aug 16 21:10:51 2016
@@ -261,7 +261,7 @@
 # CHECK-NEXT:   Flags [
 # CHECK-NEXT:     SHF_ALLOC
 # CHECK-NEXT:   ]
-# CHECK-NEXT:   Address: 0x24000
+# CHECK-NEXT:   Address: 0x4800000
 # CHECK-NEXT:   Offset:
 # CHECK-NEXT:   Size:
 # CHECK-NEXT:   Link:
@@ -291,7 +291,7 @@
 # CHECK-NEXT:   Flags [
 # CHECK-NEXT:     SHF_ALLOC
 # CHECK-NEXT:   ]
-# CHECK-NEXT:   Address: 0x26000
+# CHECK-NEXT:   Address: 0x200000
 # CHECK-NEXT:   Offset:
 # CHECK-NEXT:   Size:
 # CHECK-NEXT:   Link:

Modified: lld/trunk/test/ELF/linkerscript/linkerscript-symbol-assignexpr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-symbol-assignexpr.s?rev=278889&r1=278888&r2=278889&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-symbol-assignexpr.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-symbol-assignexpr.s Tue Aug 16 21:10:51 2016
@@ -13,9 +13,9 @@
 # CHECK-NEXT: 0000000000000000 *UND* 00000000
 # CHECK-NEXT: 0000000000000120 .text 00000000 _start
 # CHECK-NEXT: 0000000000000121 .text 00000000 foo
-# CHECK-NEXT: 0000000000001000 *ABS* 00000000 symbol
-# CHECK-NEXT: 0000000000002234 *ABS* 00000000 symbol2
-# CHECK-NEXT: 0000000000002234 *ABS* 00000000 symbol3
+# CHECK-NEXT: 0000000000200000 *ABS* 00000000 symbol
+# CHECK-NEXT: 0000000000201234 *ABS* 00000000 symbol2
+# CHECK-NEXT: 0000000000201234 *ABS* 00000000 symbol3
 
 # RUN: echo "SECTIONS { \
 # RUN:         symbol2 = symbol; \




More information about the llvm-commits mailing list