[PATCH] D38580: [ELF] - Do not produce broken .dynamic section with --no-rosegment

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 6 03:07:59 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL315054: [ELF] - Do not produce broken .dynamic section with --no-rosegment (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D38580?vs=117796&id=117968#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38580

Files:
  lld/trunk/ELF/SyntheticSections.cpp
  lld/trunk/test/ELF/dynamic-no-rosegment.s


Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -1171,10 +1171,10 @@
       add({DT_MIPS_RLD_MAP, InX::MipsRldMap});
   }
 
-  getParent()->Link = this->Link;
+  add({DT_NULL, (uint64_t)0});
 
-  // +1 for DT_NULL
-  this->Size = (Entries.size() + 1) * this->Entsize;
+  getParent()->Link = this->Link;
+  this->Size = Entries.size() * this->Entsize;
 }
 
 template <class ELFT> void DynamicSection<ELFT>::writeTo(uint8_t *Buf) {
Index: lld/trunk/test/ELF/dynamic-no-rosegment.s
===================================================================
--- lld/trunk/test/ELF/dynamic-no-rosegment.s
+++ lld/trunk/test/ELF/dynamic-no-rosegment.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -shared --no-rosegment -z rodynamic -o %t %t.o
+# RUN: llvm-readobj -dynamic-table -s %t | FileCheck %s
+
+# CHECK:      DynamicSection [ (7 entries)
+# CHECK-NEXT:   Tag                Type                 Name/Value
+# CHECK-NEXT:   0x0000000000000006 SYMTAB               0x120
+# CHECK-NEXT:   0x000000000000000B SYMENT               24 (bytes)
+# CHECK-NEXT:   0x0000000000000005 STRTAB               0x1D0
+# CHECK-NEXT:   0x000000000000000A STRSZ                1 (bytes)
+# CHECK-NEXT:   0x000000006FFFFEF5 GNU_HASH             0x138
+# CHECK-NEXT:   0x0000000000000004 HASH                 0x150
+# CHECK-NEXT:   0x0000000000000000 NULL                 0x0
+# CHECK-NEXT: ]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38580.117968.patch
Type: text/x-patch
Size: 1582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171006/d4d5bd9f/attachment.bin>


More information about the llvm-commits mailing list