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 @@ -11,6 +11,7 @@ # 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 +# RUN: llvm-readobj -x .debug_str_offsets %tO0.wasm | FileCheck %s --check-prefixes CHECK-OFFSETS .section .debug_str,"S",@ .Linfo_string0: @@ -21,6 +22,11 @@ .section .debug_other,"",@ .int32 .Linfo_string0 +.section .debug_str_offsets,"",@ + .int32 .Linfo_string0 + .int32 .Linfo_string0 + .int32 .Linfo_string0 + # CHECK: Hex dump of section '.debug_str': # CHECK-O0: 0x00000000 636c616e 67207665 7273696f 6e203133 clang version 13 @@ -30,3 +36,6 @@ # CHECK-O1: 0x00000000 666f6f62 61720066 6f6f0063 6c616e67 foobar.foo.clang # CHECK-O1: 0x00000010 20766572 73696f6e 2031332e 302e3000 version 13.0.0. + +# CHECK-OFFSETS: Hex dump of section '.debug_str_offsets': +# CHECK-OFFSETS: 0x00000000 00000000 00000000 00000000 ............ diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -368,8 +368,11 @@ // currently go by the name alone. // TODO(sbc): Add ability for wasm sections to carry flags so we don't // need to use names here. - return sec.Name.startswith(".debug_str") || - sec.Name.startswith(".debug_line_str"); + // For now, keep in sync with uses of wasm::WASM_SEG_FLAG_STRINGS in + // MCObjectFileInfo::initWasmMCObjectFileInfo which creates these custom + // sections. + return sec.Name == ".debug_str" || sec.Name == ".debug_str.dwo" || + sec.Name == ".debug_line_str"; } static bool shouldMerge(const WasmSegment &seg) {