[PATCH] D64880: ELF: Allow forward references to linked sections.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 17 19:30:18 PDT 2019


pcc updated this revision to Diff 210477.
pcc marked 2 inline comments as done.
pcc added a comment.

- Add comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64880/new/

https://reviews.llvm.org/D64880

Files:
  lld/ELF/InputFiles.cpp
  lld/test/ELF/linkorder-forward-ref.test


Index: lld/test/ELF/linkorder-forward-ref.test
===================================================================
--- /dev/null
+++ lld/test/ELF/linkorder-forward-ref.test
@@ -0,0 +1,24 @@
+# REQUIRES: x86
+# RUN: yaml2obj %s -o %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: llvm-readelf -S %t | FileCheck %s
+
+# Test that we accept forward sh_link references.
+
+# CHECK: .linkorder
+# CHECK: .text
+
+--- !ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Name:          .linkorder
+    Type:          SHT_PROGBITS
+    Flags:         [ SHF_ALLOC, SHF_EXECINSTR, SHF_LINK_ORDER ]
+    Link:          2
+  - Name:          .text
+    Type:          SHT_PROGBITS
+    Flags:         [ SHF_ALLOC, SHF_EXECINSTR ]
Index: lld/ELF/InputFiles.cpp
===================================================================
--- lld/ELF/InputFiles.cpp
+++ lld/ELF/InputFiles.cpp
@@ -652,6 +652,12 @@
     default:
       this->sections[i] = createInputSection(sec);
     }
+  }
+
+  for (size_t i = 0, e = objSections.size(); i < e; i++) {
+    if (this->sections[i] == &InputSection::discarded)
+      continue;
+    const Elf_Shdr &sec = objSections[i];
 
     // .ARM.exidx sections have a reverse dependency on the InputSection they
     // have a SHF_LINK_ORDER dependency, this is identified by the sh_link.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64880.210477.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190718/caae364e/attachment.bin>


More information about the llvm-commits mailing list