[PATCH] D46134: [WebAssembly] objdump: Don't assume all relocations have symbols
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 26 10:08:28 PDT 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330959: [WebAssembly] objdump: Don't assume all relocations have symbols (authored by sbc, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D46134
Files:
llvm/trunk/test/tools/llvm-objdump/WebAssembly/relocations.test
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
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
@@ -920,10 +920,14 @@
symbol_iterator SI = RelRef.getSymbol();
std::string fmtbuf;
raw_string_ostream fmt(fmtbuf);
- Expected<StringRef> SymNameOrErr = SI->getName();
- if (!SymNameOrErr) {
+ if (SI == Obj->symbol_end()) {
+ // Not all wasm relocations have symbols associated with them.
+ // In particular R_WEBASSEMBLY_TYPE_INDEX_LEB.
fmt << Rel.Index;
} else {
+ Expected<StringRef> SymNameOrErr = SI->getName();
+ if (!SymNameOrErr)
+ return errorToErrorCode(SymNameOrErr.takeError());
StringRef SymName = *SymNameOrErr;
Result.append(SymName.begin(), SymName.end());
}
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
@@ -1,8 +1,16 @@
; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj %s -o - | llvm-objdump -r - | FileCheck %s
- at foo1 = hidden global i32 1, align 4
- at foo2 = hidden global i32 1, align 4
- at bar = hidden global i32* @foo2, align 4
+ at foo = external global i32, align 4
+ at bar = global i32* @foo, align 4
+
+define void @make_call(void ()* nocapture %func) {
+entry:
+ call void %func()
+ ret void
+}
+
+; CHECK: RELOCATION RECORDS FOR [CODE]:
+; CHECK-NEXT: 00000006 R_WEBASSEMBLY_TYPE_INDEX_LEB 1+0
; CHECK: RELOCATION RECORDS FOR [DATA]:
-; CHECK-NEXT: 00000018 R_WEBASSEMBLY_MEMORY_ADDR_I32 foo2+0
+; CHECK-NEXT: 00000006 R_WEBASSEMBLY_MEMORY_ADDR_I32 foo+0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46134.144149.patch
Type: text/x-patch
Size: 1809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180426/a1376097/attachment-0001.bin>
More information about the llvm-commits
mailing list