Index: lib/MC/WasmObjectWriter.cpp =================================================================== --- lib/MC/WasmObjectWriter.cpp +++ lib/MC/WasmObjectWriter.cpp @@ -1420,7 +1420,7 @@ LLVM_DEBUG(dbgs() << WS.getName() << ": weak alias of '" << *ResolvedSym << "'\n"); - if (WS.isFunction()) { + if (ResolvedSym->isFunction()) { assert(WasmIndices.count(ResolvedSym) > 0); uint32_t WasmIndex = WasmIndices.find(ResolvedSym)->second; WasmIndices[&WS] = WasmIndex; @@ -1456,10 +1456,17 @@ Flags |= wasm::WASM_SYMBOL_UNDEFINED; wasm::WasmSymbolInfo Info; + bool isData = WS.isData(); + if (WS.isVariable()) { + const MCSymbolWasm *ResolvedSym = ResolveSymbol(WS); + Info.Kind = ResolvedSym->getType(); + isData = ResolvedSym->isData(); + } else { + Info.Kind = WS.getType(); + } Info.Name = WS.getName(); - Info.Kind = WS.getType(); Info.Flags = Flags; - if (!WS.isData()) { + if (!isData) { assert(WasmIndices.count(&WS) > 0); Info.ElementIndex = WasmIndices.find(&WS)->second; } else if (WS.isDefined()) { Index: test/MC/WebAssembly/function-alias.ll =================================================================== --- /dev/null +++ test/MC/WebAssembly/function-alias.ll @@ -0,0 +1,29 @@ +; RUN: llc -filetype=obj %s -o - | llvm-readobj -symbols | FileCheck %s + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown-wasm" + +@foo = alias i8, bitcast (void ()* @func to i8*) +@bar = alias void (), void ()* @func + +define void @func() { + ret void +} + +; CHECK: Symbols [ +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: func +; CHECK-NEXT: Type: FUNCTION (0x0) +; CHECK-NEXT: Flags: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Type: FUNCTION (0x0) +; CHECK-NEXT: Flags: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: bar +; CHECK-NEXT: Type: FUNCTION (0x0) +; CHECK-NEXT: Flags: 0x0 +; CHECK-NEXT: } +; CHECK-NEXT: ]