Index: llvm/trunk/lib/Object/WasmObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/WasmObjectFile.cpp +++ llvm/trunk/lib/Object/WasmObjectFile.cpp @@ -1181,7 +1181,7 @@ return Header; } -void WasmObjectFile::moveSymbolNext(DataRefImpl &Symb) const { Symb.d.a++; } +void WasmObjectFile::moveSymbolNext(DataRefImpl &Symb) const { Symb.d.b++; } uint32_t WasmObjectFile::getSymbolFlags(DataRefImpl Symb) const { uint32_t Result = SymbolRef::SF_None; @@ -1203,18 +1203,20 @@ basic_symbol_iterator WasmObjectFile::symbol_begin() const { DataRefImpl Ref; - Ref.d.a = 0; + Ref.d.a = 1; // Arbitrary non-zero value so that Ref.p is non-null + Ref.d.b = 0; // Symbol index return BasicSymbolRef(Ref, this); } basic_symbol_iterator WasmObjectFile::symbol_end() const { DataRefImpl Ref; - Ref.d.a = Symbols.size(); + Ref.d.a = 1; // Arbitrary non-zero value so that Ref.p is non-null + Ref.d.b = Symbols.size(); // Symbol index return BasicSymbolRef(Ref, this); } const WasmSymbol &WasmObjectFile::getWasmSymbol(const DataRefImpl &Symb) const { - return Symbols[Symb.d.a]; + return Symbols[Symb.d.b]; } const WasmSymbol &WasmObjectFile::getWasmSymbol(const SymbolRef &Symb) const { Index: llvm/trunk/test/tools/llvm-nm/lit.local.cfg =================================================================== --- llvm/trunk/test/tools/llvm-nm/lit.local.cfg +++ llvm/trunk/test/tools/llvm-nm/lit.local.cfg @@ -1,4 +1,4 @@ if not 'X86' in config.root.targets: config.unsupported = True -config.suffixes = ['.s', '.test', '.yaml'] +config.suffixes = ['.ll', '.s', '.test', '.yaml'] Index: llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll =================================================================== --- llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll +++ llvm/trunk/test/tools/llvm-nm/wasm/extern-only.ll @@ -0,0 +1,23 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-unknown -o %t.o %s +; RUN: llvm-nm --extern-only %t.o | FileCheck %s + +; Verity that hidden symbols are listed even when --extern-only is passed + +define hidden i32 @foo() { +entry: + ret i32 42 +} + +define i32 @bar() { +entry: + ret i32 43 +} + +define internal i32 @baz() { +entry: + ret i32 44 +} + +; CHECK: 00000006 T bar +; CHECK-NOT: baz +; CHECK: 00000001 T foo