[PATCH] D102806: [lld][WebAssembly] Fix for string tail merging and -r/--relocatable

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 19 13:54:41 PDT 2021


sbc100 updated this revision to Diff 346557.
sbc100 added a comment.

- update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102806

Files:
  lld/test/wasm/merge-string-debug.s
  lld/wasm/OutputSections.cpp


Index: lld/wasm/OutputSections.cpp
===================================================================
--- lld/wasm/OutputSections.cpp
+++ lld/wasm/OutputSections.cpp
@@ -241,6 +241,7 @@
   std::vector<InputChunk *> newSections;
 
   for (InputChunk *s : inputSections) {
+    s->outputSec = this;
     MergeInputChunk *ms = dyn_cast<MergeInputChunk>(s);
     if (!ms) {
       newSections.push_back(s);
@@ -251,6 +252,7 @@
       mergedSection =
           make<SyntheticMergedChunk>(name, 0, WASM_SEG_FLAG_STRINGS);
       newSections.push_back(mergedSection);
+      mergedSection->outputSec = this;
     }
     mergedSection->addMergeChunk(ms);
   }
@@ -272,7 +274,6 @@
 
   for (InputChunk *section : inputSections) {
     assert(!section->discarded);
-    section->outputSec = this;
     section->outSecOff = payloadSize;
     payloadSize += section->getSize();
   }
Index: lld/test/wasm/merge-string-debug.s
===================================================================
--- lld/test/wasm/merge-string-debug.s
+++ lld/test/wasm/merge-string-debug.s
@@ -4,13 +4,23 @@
 # RUN: wasm-ld %t.o %t2.o -o %t.wasm --no-entry
 # RUN: llvm-readobj -x .debug_str %t.wasm | FileCheck %s --check-prefixes CHECK,CHECK-O1
 
+# Check that we -r/--reclocatable can handle string merging too
+# RUN: wasm-ld --relocatable %t.o %t2.o -o %t3.o
+# RUN: wasm-ld -O1 %t3.o -o %t.wasm --no-entry
+# RUN: llvm-readobj -x .debug_str %t.wasm | FileCheck %s --check-prefixes CHECK,CHECK-O1
+
 # RUN: wasm-ld -O0 %t.o %t2.o -o %tO0.wasm --no-entry
 # RUN: llvm-readobj -x .debug_str %tO0.wasm | FileCheck %s --check-prefixes CHECK,CHECK-O0
 
 .section .debug_str,"S",@
+.Linfo_string0:
   .asciz "clang version 13.0.0"
+.Linfo_string1:
   .asciz "foobar"
 
+.section .debug_other,"",@
+  .int32 .Linfo_string0
+
 # CHECK: Hex dump of section '.debug_str':
 
 # CHECK-O0: 0x00000000 636c616e 67207665 7273696f 6e203133 clang version 13


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102806.346557.patch
Type: text/x-patch
Size: 1917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210519/05774f08/attachment.bin>


More information about the llvm-commits mailing list