diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -656,6 +656,7 @@ StringRef CachedName = Entry.first.SectionName; MCSymbol *Begin = createSymbol(CachedName, true, false); + Symbols[Begin->getName()] = Begin; cast(Begin)->setType(wasm::WASM_SYMBOL_TYPE_SECTION); MCSectionWasm *Result = new (WasmAllocator.Allocate()) diff --git a/llvm/test/MC/WebAssembly/section-symbol.s b/llvm/test/MC/WebAssembly/section-symbol.s new file mode 100644 --- /dev/null +++ b/llvm/test/MC/WebAssembly/section-symbol.s @@ -0,0 +1,16 @@ +# RUN: llvm-mc -triple=wasm32 < %s | FileCheck %s + +# check that we can refer to section symbols of other sections. +# getWasmSection currently forces the section symbol to have a suffix. + +# TODO: fix the 0-suffix: https://bugs.llvm.org/show_bug.cgi?id=49252 + + .section .debug_abbrev,"",@ + .int8 1 + .section .debug_info,"",@ + .int32 .debug_abbrev0 + +# CHECK: .section .debug_abbrev,"",@ +# CHECK-NEXT: .int8 1 +# CHECK-NEXT: .section .debug_info,"",@ +# CHECK-NEXT: .int32 .debug_abbrev0