aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2020-01-22 17:40:11 -0800
committerDerek Schuff <dschuff@chromium.org>2020-01-28 09:55:38 -0800
commitda6a896e6b1b1e397297b08a565940f1e0391cb7 (patch)
tree32747154ffc49f302a3b20cacdfecac0498cf495 /llvm/lib/Object/WasmObjectFile.cpp
parent2e5d20bd478868c80aa595e969d17734690f9b4d (diff)
downloadllvm-da6a896e6b1b1e397297b08a565940f1e0391cb7.zip
llvm-da6a896e6b1b1e397297b08a565940f1e0391cb7.tar.gz
llvm-da6a896e6b1b1e397297b08a565940f1e0391cb7.tar.bz2
[WebAssembly] Add WebAssembly support to llvm-symbolizer
The only thing missing for basic llvm-symbolizer support is the ability on lib/Object to get a wasm symbol's section ID, which allows sorting and computation of the symbols' sizes. Also, when the WasmAsmParser switches sections on new functions, also add the section to the list of Dwarf sections if Dwarf is being generated for assembly; this allows writing of simple tests. Reviewers: sbc100, jhenderson, aardappel Differential Revision: https://reviews.llvm.org/D73246
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index ab8918c..813ced1 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -1365,26 +1365,30 @@ WasmObjectFile::getSymbolSection(DataRefImpl Symb) const {
return section_end();
DataRefImpl Ref;
+ Ref.d.a = getSymbolSectionIdImpl(Sym);
+ return section_iterator(SectionRef(Ref, this));
+}
+
+uint32_t WasmObjectFile::getSymbolSectionId(SymbolRef Symb) const {
+ const WasmSymbol &Sym = getWasmSymbol(Symb);
+ return getSymbolSectionIdImpl(Sym);
+}
+
+uint32_t WasmObjectFile::getSymbolSectionIdImpl(const WasmSymbol &Sym) const {
switch (Sym.Info.Kind) {
case wasm::WASM_SYMBOL_TYPE_FUNCTION:
- Ref.d.a = CodeSection;
- break;
+ return CodeSection;
case wasm::WASM_SYMBOL_TYPE_GLOBAL:
- Ref.d.a = GlobalSection;
- break;
+ return GlobalSection;
case wasm::WASM_SYMBOL_TYPE_DATA:
- Ref.d.a = DataSection;
- break;
+ return DataSection;
case wasm::WASM_SYMBOL_TYPE_SECTION:
- Ref.d.a = Sym.Info.ElementIndex;
- break;
+ return Sym.Info.ElementIndex;
case wasm::WASM_SYMBOL_TYPE_EVENT:
- Ref.d.a = EventSection;
- break;
+ return EventSection;
default:
llvm_unreachable("Unknown WasmSymbol::SymbolType");
}
- return section_iterator(SectionRef(Ref, this));
}
void WasmObjectFile::moveSectionNext(DataRefImpl &Sec) const { Sec.d.a++; }