[PATCH] D32289: [ELF] - Linkerscript: support combination of linkerscript and --compress-debug-sections.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 20 05:23:58 PDT 2017


grimar created this revision.

Previously it was impossible to use linkerscript with --compress-debug-sections because of
assert failture:
Assertion failed: isFinalized(), file C:\access_softek\llvm\lib\MC\StringTableBuilder.cpp, line 64

Patch fixes the issue.


https://reviews.llvm.org/D32289

Files:
  ELF/OutputSections.cpp
  test/ELF/linkerscript/Inputs/compress-debug-sections.s
  test/ELF/linkerscript/compress-debug-sections.s


Index: test/ELF/linkerscript/compress-debug-sections.s
===================================================================
--- test/ELF/linkerscript/compress-debug-sections.s
+++ test/ELF/linkerscript/compress-debug-sections.s
@@ -0,0 +1,20 @@
+# REQUIRES: x86, zlib
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
+# RUN:   %S/Inputs/compress-debug-sections.s -o %t1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2.o
+# RUN: echo "SECTIONS { .debug_str 0 : { *(.debug_str) } }" > %t.script
+# RUN: ld.lld %t1.o %t2.o %t.script -o %t --compress-debug-sections=zlib
+
+# RUN: llvm-dwarfdump %t -debug-dump=str | FileCheck %s
+# CHECK:     .debug_str contents:
+# CHECK-NEXT:  CCCCCCCCCCCCCCCCCCCCCCCCCCC
+# CHECK-NEXT:  DDDDDDDDDDDDDDDDDDDDDDDDDDD
+# CHECK-NEXT:  AAAAAAAAAAAAAAAAAAAAAAAAAAA
+# CHECK-NEXT:  BBBBBBBBBBBBBBBBBBBBBBBBBBB
+
+.section .debug_str,"MS", at progbits,1
+.Linfo_string0:
+  .asciz "AAAAAAAAAAAAAAAAAAAAAAAAAAA"
+.Linfo_string1:
+  .asciz "BBBBBBBBBBBBBBBBBBBBBBBBBBB"
Index: test/ELF/linkerscript/Inputs/compress-debug-sections.s
===================================================================
--- test/ELF/linkerscript/Inputs/compress-debug-sections.s
+++ test/ELF/linkerscript/Inputs/compress-debug-sections.s
@@ -0,0 +1,5 @@
+.section .debug_str,"MS", at progbits,1
+.Linfo_string0:
+  .asciz "CCCCCCCCCCCCCCCCCCCCCCCCCCC"
+.Linfo_string1:
+  .asciz "DDDDDDDDDDDDDDDDDDDDDDDDDDD"
Index: ELF/OutputSections.cpp
===================================================================
--- ELF/OutputSections.cpp
+++ ELF/OutputSections.cpp
@@ -93,6 +93,10 @@
       !Name.startswith(".debug_"))
     return;
 
+  // We call maybeCompress() early and for linkerscript case need to assign offsets,
+  // because that was not done yet. That finalizes mergeable synthetic sections.
+  assignOffsets();
+
   // Create a section header.
   ZDebugHeader.resize(sizeof(Elf_Chdr));
   auto *Hdr = reinterpret_cast<Elf_Chdr *>(ZDebugHeader.data());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32289.95938.patch
Type: text/x-patch
Size: 1994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170420/d109f741/attachment-0001.bin>


More information about the llvm-commits mailing list