[PATCH] D46092: [WebAssembly] Implement getRelocationValueString()
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 26 09:45:17 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330957: [WebAssembly] Implement getRelocationValueString() (authored by sbc, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D46092
Files:
llvm/trunk/lib/Object/WasmObjectFile.cpp
llvm/trunk/test/Object/objdump-relocations.test
llvm/trunk/test/tools/llvm-objdump/WebAssembly/relocations.test
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/trunk/lib/Object/WasmObjectFile.cpp
===================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp
@@ -1139,10 +1139,14 @@
return Rel.Offset;
}
-symbol_iterator WasmObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
- llvm_unreachable("not yet implemented");
- SymbolRef Ref;
- return symbol_iterator(Ref);
+symbol_iterator WasmObjectFile::getRelocationSymbol(DataRefImpl Ref) const {
+ const wasm::WasmRelocation &Rel = getWasmRelocation(Ref);
+ if (Rel.Type == wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB)
+ return symbol_end();
+ DataRefImpl Sym;
+ Sym.d.a = Rel.Index;
+ Sym.d.b = 0;
+ return symbol_iterator(SymbolRef(Sym, this));
}
uint64_t WasmObjectFile::getRelocationType(DataRefImpl Ref) const {
Index: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
@@ -917,9 +917,17 @@
const RelocationRef &RelRef,
SmallVectorImpl<char> &Result) {
const wasm::WasmRelocation& Rel = Obj->getWasmRelocation(RelRef);
+ symbol_iterator SI = RelRef.getSymbol();
std::string fmtbuf;
raw_string_ostream fmt(fmtbuf);
- fmt << Rel.Index << (Rel.Addend < 0 ? "" : "+") << Rel.Addend;
+ Expected<StringRef> SymNameOrErr = SI->getName();
+ if (!SymNameOrErr) {
+ fmt << Rel.Index;
+ } else {
+ StringRef SymName = *SymNameOrErr;
+ Result.append(SymName.begin(), SymName.end());
+ }
+ fmt << (Rel.Addend < 0 ? "" : "+") << Rel.Addend;
fmt.flush();
Result.append(fmtbuf.begin(), fmtbuf.end());
return std::error_code();
Index: llvm/trunk/test/Object/objdump-relocations.test
===================================================================
--- llvm/trunk/test/Object/objdump-relocations.test
+++ llvm/trunk/test/Object/objdump-relocations.test
@@ -60,9 +60,9 @@
ELF-MIPSEL: R_MIPS_CALL16 SomeOtherFunction
WASM: CODE
-WASM-NEXT: R_WEBASSEMBLY_MEMORY_ADDR_SLEB 1+0
-WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 2+0
-WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB 3+0
+WASM-NEXT: R_WEBASSEMBLY_MEMORY_ADDR_SLEB .L.str+0
+WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB puts+0
+WASM-NEXT: R_WEBASSEMBLY_FUNCTION_INDEX_LEB SomeOtherFunction+0
ELF-complex-x86-64: .text
ELF-complex-x86-64-NEXT: R_X86_64_8 .data-4
Index: llvm/trunk/test/tools/llvm-objdump/WebAssembly/relocations.test
===================================================================
--- llvm/trunk/test/tools/llvm-objdump/WebAssembly/relocations.test
+++ llvm/trunk/test/tools/llvm-objdump/WebAssembly/relocations.test
@@ -5,4 +5,4 @@
@bar = hidden global i32* @foo2, align 4
; CHECK: RELOCATION RECORDS FOR [DATA]:
-; CHECK-NEXT: 00000018 R_WEBASSEMBLY_MEMORY_ADDR_I32 1+0
+; CHECK-NEXT: 00000018 R_WEBASSEMBLY_MEMORY_ADDR_I32 foo2+0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46092.144144.patch
Type: text/x-patch
Size: 3026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180426/383f9fc4/attachment.bin>
More information about the llvm-commits
mailing list