forked from OSchip/llvm-project
[lld][WebAssembly] Fix for string tail merging and -r/--relocatable
Ensure that both SyntheticMergedChunk and all MergeInfoChunks that it comprises are assigned the correct output section. Without this we would crash when outputting relocations in --relocatable mode. Fixes: https://github.com/emscripten-core/emscripten/issues/14220 Differential Revision: https://reviews.llvm.org/D102806
This commit is contained in:
parent
c9dbaa4c86
commit
356b85edd7
|
@ -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
|
||||
|
|
|
@ -241,6 +241,7 @@ void CustomSection::finalizeInputSections() {
|
|||
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 @@ void CustomSection::finalizeInputSections() {
|
|||
mergedSection =
|
||||
make<SyntheticMergedChunk>(name, 0, WASM_SEG_FLAG_STRINGS);
|
||||
newSections.push_back(mergedSection);
|
||||
mergedSection->outputSec = this;
|
||||
}
|
||||
mergedSection->addMergeChunk(ms);
|
||||
}
|
||||
|
@ -272,7 +274,6 @@ void CustomSection::finalizeContents() {
|
|||
|
||||
for (InputChunk *section : inputSections) {
|
||||
assert(!section->discarded);
|
||||
section->outputSec = this;
|
||||
section->outSecOff = payloadSize;
|
||||
payloadSize += section->getSize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue