[PATCH] D29981: [ELF] - Allow section to have multiple dependent sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 00:53:05 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL295298: [ELF] - Allow section to have multiple dependent sections. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D29981?vs=88497&id=88673#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29981

Files:
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/ELF/InputSection.h
  lld/trunk/ELF/MarkLive.cpp
  lld/trunk/test/ELF/gc-sections-metadata2.s


Index: lld/trunk/test/ELF/gc-sections-metadata2.s
===================================================================
--- lld/trunk/test/ELF/gc-sections-metadata2.s
+++ lld/trunk/test/ELF/gc-sections-metadata2.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld --gc-sections %t.o -o %t
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+
+# CHECK: .foo
+# CHECK: .bar
+# CHECK: .zed
+
+.globl _start
+_start:
+.quad .foo
+
+.section .foo,"a"
+.quad 0
+.section .bar,"am", at progbits,.foo
+.quad 0
+.section .zed,"am", at progbits,.foo
+.quad 0
Index: lld/trunk/ELF/MarkLive.cpp
===================================================================
--- lld/trunk/ELF/MarkLive.cpp
+++ lld/trunk/ELF/MarkLive.cpp
@@ -87,8 +87,8 @@
     for (const typename ELFT::Rel &Rel : Sec.rels())
       Fn(resolveReloc(Sec, Rel));
   }
-  if (Sec.DependentSection)
-    Fn({Sec.DependentSection, 0});
+  for (InputSectionBase<ELFT> *IS : Sec.DependentSections)
+    Fn({IS, 0});
 }
 
 // The .eh_frame section is an unfortunate special case.
Index: lld/trunk/ELF/InputSection.h
===================================================================
--- lld/trunk/ELF/InputSection.h
+++ lld/trunk/ELF/InputSection.h
@@ -281,8 +281,8 @@
   // to. The writer sets a value.
   uint64_t OutSecOff = 0;
 
-  // InputSection that is dependent on us (reverse dependency for GC)
-  InputSectionBase<ELFT> *DependentSection = nullptr;
+  // InputSections that are dependent on us (reverse dependency for GC)
+  llvm::TinyPtrVector<InputSectionBase<ELFT> *> DependentSections;
 
   static bool classof(const InputSectionData *S);
 
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -323,7 +323,7 @@
         fatal(toString(this) + ": invalid sh_link index: " +
               Twine(Sec.sh_link));
       auto *IS = cast<InputSection<ELFT>>(Sections[Sec.sh_link]);
-      IS->DependentSection = Sections[I];
+      IS->DependentSections.push_back(Sections[I]);
     }
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29981.88673.patch
Type: text/x-patch
Size: 2134 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170216/14534990/attachment.bin>


More information about the llvm-commits mailing list