From 2a193e0d12b5fd52366d7c2b42fb3d37af27bb74 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 29 Jan 2019 22:22:32 +0000 Subject: [WebAssembly] Ensure BasicSymbolRef.getRawDataRefImpl().p is non-null Store a non-zero value to ref.d.a and use ref.d.b to store the symbol index. This means that ref.p is never null, which was confusing llvm-nm. Fixes PR40497 Differential Revision: https://reviews.llvm.org/D57373 llvm-svn: 352551 --- llvm/lib/Object/WasmObjectFile.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Object/WasmObjectFile.cpp') diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index ce77ad98948..6f0a5a4f66f 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -1181,7 +1181,7 @@ const wasm::WasmObjectHeader &WasmObjectFile::getHeader() const { 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 @@ uint32_t WasmObjectFile::getSymbolFlags(DataRefImpl Symb) const { 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 { -- cgit v1.2.3