diff --git a/lld/test/wasm/merge-string-debug.s b/lld/test/wasm/merge-string-debug.s --- a/lld/test/wasm/merge-string-debug.s +++ b/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 diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp --- a/lld/wasm/OutputSections.cpp +++ b/lld/wasm/OutputSections.cpp @@ -241,6 +241,7 @@ std::vector newSections; for (InputChunk *s : inputSections) { + s->outputSec = this; MergeInputChunk *ms = dyn_cast(s); if (!ms) { newSections.push_back(s); @@ -251,6 +252,7 @@ mergedSection = make(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(); }