[lld] c1a59fa - [lld][WebAssemlby] Fix for string merging of -dwarf-5 sections
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 1 14:34:33 PDT 2021
Author: Sam Clegg
Date: 2021-06-01T14:33:56-07:00
New Revision: c1a59fa550818c6d3c229b43918b5045d7df83e6
URL: https://github.com/llvm/llvm-project/commit/c1a59fa550818c6d3c229b43918b5045d7df83e6
DIFF: https://github.com/llvm/llvm-project/commit/c1a59fa550818c6d3c229b43918b5045d7df83e6.diff
LOG: [lld][WebAssemlby] Fix for string merging of -dwarf-5 sections
We were mistakenly treating `.debug_str_offsets` as a string mergable
section when it is not (it contains integers not strings). This is an
indication that we really should find a way to store flags for custom
sections.
Fixes: https://bugs.llvm.org/show_bug.cgi?id=48828
Fixes: https://bugs.chromium.org/p/chromium/issues/detail?id=1172217
Differential Revision: https://reviews.llvm.org/D103486
Added:
Modified:
lld/test/wasm/merge-string-debug.s
lld/wasm/InputFiles.cpp
Removed:
################################################################################
diff --git a/lld/test/wasm/merge-string-debug.s b/lld/test/wasm/merge-string-debug.s
index 961cdabb0c850..73e31d5361f41 100644
--- 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
index faf7bbcfa926e..4688590415055 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -368,8 +368,11 @@ static bool shouldMerge(const WasmSection &sec) {
// 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) {
More information about the llvm-commits
mailing list