Index: test/MC/WebAssembly/weak-alias.ll =================================================================== --- /dev/null +++ test/MC/WebAssembly/weak-alias.ll @@ -0,0 +1,33 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s + +; foo_alias() function is weak alias of function foo() +; Generates two exports of the same function, one of them weak + +@foo_alias = weak hidden alias i32 (...), bitcast (i32 ()* @foo to i32 (...)*) + +define hidden i32 @foo() #0 { +entry: + ret i32 0 +} + +; CHECK: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: foo +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: foo_alias +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 + + +; CHECK: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: foo +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: SymbolInfo: +; CHECK-NEXT: - Name: foo_alias +; CHECK-NEXT: Flags: 1 +; CHECK-NEXT: ... Index: test/MC/WebAssembly/weak.ll =================================================================== --- /dev/null +++ test/MC/WebAssembly/weak.ll @@ -0,0 +1,34 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s + +; Weak external data reference +@weak_external_data = extern_weak global i32, align 4 + +; Weak function definition +define weak hidden i32 @weak_function() local_unnamed_addr #0 { +entry: + %0 = load i32, i32* @weak_external_data, align 4 + ret i32 %0 +} + +; CHECK: - Type: IMPORT +; CHECK-NEXT: Imports: +; CHECK-NEXT: - Module: env +; CHECK-NEXT: Field: weak_external_data +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: GlobalType: I32 +; CHECK-NEXT: GlobalMutable: false + + +; CHECK: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: weak_function +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: SymbolInfo: +; CHECK-NEXT: - Name: weak_external_data +; CHECK-NEXT: Flags: 1 +; CHECK-NEXT: - Name: weak_function +; CHECK-NEXT: Flags: 1 +; CHECK-NEXT: ... Index: test/tools/llvm-readobj/symbols.test =================================================================== --- test/tools/llvm-readobj/symbols.test +++ test/tools/llvm-readobj/symbols.test @@ -75,17 +75,21 @@ WASM-NEXT: Symbol { WASM-NEXT: Name: bar WASM-NEXT: Type: GLOBAL_IMPORT (0x2) +WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: Symbol { WASM-NEXT: Name: baz WASM-NEXT: Type: GLOBAL_IMPORT (0x2) +WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: Symbol { WASM-NEXT: Name: foo WASM-NEXT: Type: FUNCTION_EXPORT (0x1) +WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: Symbol { WASM-NEXT: Name: foo WASM-NEXT: Type: DEBUG_FUNCTION_NAME (0x4) +WASM-NEXT: Flags: 0x0 WASM-NEXT: } WASM-NEXT: ] Index: tools/llvm-readobj/WasmDumper.cpp =================================================================== --- tools/llvm-readobj/WasmDumper.cpp +++ tools/llvm-readobj/WasmDumper.cpp @@ -183,6 +183,7 @@ WasmSymbol Symbol = Obj->getWasmSymbol(Sym.getRawDataRefImpl()); W.printString("Name", Symbol.Name); W.printEnum("Type", static_cast(Symbol.Type), makeArrayRef(WasmSymbolTypes)); + W.printHex("Flags", Symbol.Flags); } }