summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2019-01-17 18:14:09 +0000
committerWouter van Oortmerssen <aardappel@gmail.com>2019-01-17 18:14:09 +0000
commitf3b762a0b6cef251afef8907cb4cf5b35bffb0d8 (patch)
treeaf4c08803d459a5cf507925550e5913dc1db464d /llvm/lib/Object/WasmObjectFile.cpp
parent194d00e1425c8aceefc82d4410285310868d74de (diff)
downloadbcm5719-llvm-f3b762a0b6cef251afef8907cb4cf5b35bffb0d8.tar.gz
bcm5719-llvm-f3b762a0b6cef251afef8907cb4cf5b35bffb0d8.zip
[WebAssembly] Fixed objdump not parsing function headers.
Summary: objdump was interpreting the function header containing the locals declaration as instructions. To parse these without injecting target specific code in objdump, MCDisassembler::onSymbolStart was added to be implemented by the WebAssembly implemention. WasmObjectFile now returns a code offset for the "address" of a symbol, rather than the index. This is also more in-line with what other targets do. Also ensured that the AsmParser correctly puts each function in its own segment to enable this test case. Reviewers: sbc100, dschuff Subscribers: jgravelle-google, aheejin, sunfish, rupprecht, llvm-commits Differential Revision: https://reviews.llvm.org/D56684 llvm-svn: 351460
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index fd6ad9bdefe..12821748e91 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -1055,6 +1055,12 @@ wasm::WasmFunction &WasmObjectFile::getDefinedFunction(uint32_t Index) {
return Functions[Index - NumImportedFunctions];
}
+const wasm::WasmFunction &
+WasmObjectFile::getDefinedFunction(uint32_t Index) const {
+ assert(isDefinedFunctionIndex(Index));
+ return Functions[Index - NumImportedFunctions];
+}
+
wasm::WasmGlobal &WasmObjectFile::getDefinedGlobal(uint32_t Index) {
assert(isDefinedGlobalIndex(Index));
return Globals[Index - NumImportedGlobals];
@@ -1221,7 +1227,12 @@ Expected<StringRef> WasmObjectFile::getSymbolName(DataRefImpl Symb) const {
}
Expected<uint64_t> WasmObjectFile::getSymbolAddress(DataRefImpl Symb) const {
- return getSymbolValue(Symb);
+ auto &Sym = getWasmSymbol(Symb);
+ if (Sym.Info.Kind == wasm::WASM_SYMBOL_TYPE_FUNCTION &&
+ isDefinedFunctionIndex(Sym.Info.ElementIndex))
+ return getDefinedFunction(Sym.Info.ElementIndex).CodeSectionOffset;
+ else
+ return getSymbolValue(Symb);
}
uint64_t WasmObjectFile::getWasmSymbolValue(const WasmSymbol &Sym) const {
OpenPOWER on IntegriCloud