[PATCH] D49351: [LLD] [COFF] Sort .relocs before all other discardable sections

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 20 11:49:02 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337598: [COFF] Sort .reloc before all other discardable sections (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49351?vs=156209&id=156557#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49351

Files:
  lld/trunk/COFF/Writer.cpp
  lld/trunk/test/COFF/sort-debug.test


Index: lld/trunk/COFF/Writer.cpp
===================================================================
--- lld/trunk/COFF/Writer.cpp
+++ lld/trunk/COFF/Writer.cpp
@@ -470,12 +470,9 @@
 
   // Finally, move some output sections to the end.
   auto SectionOrder = [&](OutputSection *S) {
-    // .reloc should come last of all since it refers to RVAs of data in the
-    // previous sections.
-    if (S == RelocSec)
-      return 3;
     // Move DISCARDABLE (or non-memory-mapped) sections to the end of file because
-    // the loader cannot handle holes.
+    // the loader cannot handle holes. Stripping can remove other discardable ones
+    // than .reloc, which is first of them (created early).
     if (S->Header.Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
       return 2;
     // .rsrc should come at the end of the non-discardable sections because its
Index: lld/trunk/test/COFF/sort-debug.test
===================================================================
--- lld/trunk/test/COFF/sort-debug.test
+++ lld/trunk/test/COFF/sort-debug.test
@@ -9,20 +9,20 @@
 # RUN: llvm-readobj -sections %t.exe | FileCheck -check-prefix=NODEBUG %s
 
 # CHECK: Name: .text
+# CHECK: Name: .reloc
 # CHECK: Name: .debug_abbrev
 # CHECK: Name: .debug_info
 # CHECK: Name: .debug_line
 # CHECK: Name: .debug_pubnames
 # CHECK: Name: .debug_pubtypes
-# CHECK: Name: .reloc
 
 # NODEBUG: Name: .text
+# NODEBUG: Name: .reloc
 # NODEBUG-NOT: Name: .debug_abbrev
 # NODEBUG-NOT: Name: .debug_info
 # NODEBUG-NOT: Name: .debug_line
 # NODEBUG-NOT: Name: .debug_pubnames
 # NODEBUG-NOT: Name: .debug_pubtypes
-# NODEBUG: Name: .reloc
 
 --- !COFF
 header:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49351.156557.patch
Type: text/x-patch
Size: 1643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180720/5861686a/attachment.bin>


More information about the llvm-commits mailing list