[PATCH] D45788: Mitigate relocation overflow [part 1 of 2]

Han Shen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 26 15:39:44 PDT 2018


shenhan updated this revision to Diff 144229.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D45788

Files:
  ELF/Writer.cpp
  test/ELF/aarch64-copy.s
  test/ELF/arm-copy.s


Index: test/ELF/arm-copy.s
===================================================================
--- test/ELF/arm-copy.s
+++ test/ELF/arm-copy.s
@@ -78,4 +78,4 @@
 
 // RODATA: Contents of section .rodata:
 // S(z) = 0x13004
-// RODATA-NEXT: 10114 04300100
+// RODATA-NEXT: 10144 04300100
Index: test/ELF/aarch64-copy.s
===================================================================
--- test/ELF/aarch64-copy.s
+++ test/ELF/aarch64-copy.s
@@ -90,4 +90,4 @@
 
 // RODATA: Contents of section .rodata:
 // S(z) = 0x40014
-// RODATA-NEXT:  101c8 14000400
+// RODATA-NEXT:  10228 14000400
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -717,6 +717,16 @@
   if (!(Sec->Flags & SHF_ALLOC))
     return Rank | RF_NOT_ALLOC;
 
+  // Place .dynsym and .dynstr at the beginning of "ALLOC"
+  // sections. We want to do this to mitigate the possibility that
+  // huge .dynsym and .dynstr sections placed between text sections
+  // cause relocation overflow.  Note: .dynstr has SHT_STRTAB type and
+  // ALLOC attribute, whereas sections that only have SHT_STRTAB but
+  // without ALLOC is placed at the end. All "Sec" reaching here has
+  // "ALLOC" bit set.
+  if (Sec->Type == SHT_DYNSYM || Sec->Type == SHT_STRTAB)
+    return Rank;
+
   // Sort sections based on their access permission in the following
   // order: R, RX, RWX, RW.  This order is based on the following
   // considerations:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45788.144229.patch
Type: text/x-patch
Size: 1476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180426/a1840cbf/attachment.bin>


More information about the llvm-commits mailing list