summaryrefslogtreecommitdiffstats
path: root/llvm/lib/BinaryFormat/Wasm.cpp
diff options
context:
space:
mode:
authorKeno Fischer <keno@alumni.harvard.edu>2019-06-26 00:52:42 +0000
committerKeno Fischer <keno@alumni.harvard.edu>2019-06-26 00:52:42 +0000
commitcadcb9eb6131e30b38e67991fbf034e22c7c0bfd (patch)
tree45eba5441be38ddb5d86c63266d712efc2c78fe6 /llvm/lib/BinaryFormat/Wasm.cpp
parent5242fbde5a2610bc72b09bfae03f916f1c78e53d (diff)
downloadbcm5719-llvm-cadcb9eb6131e30b38e67991fbf034e22c7c0bfd.tar.gz
bcm5719-llvm-cadcb9eb6131e30b38e67991fbf034e22c7c0bfd.zip
[WebAssembly] Fix list of relocations with addends in lld
Summary: The list of relocations with addend in lld was missing `R_WASM_MEMORY_ADDR_REL_SLEB`, causing `wasm-ld` to generate corrupted output. This fixes that problem and while we're at it pulls the list of such relocations into the Wasm.h header, to avoid duplicating it in multiple places. Reviewers: sbc100 Differential Revision: https://reviews.llvm.org/D63696 llvm-svn: 364367
Diffstat (limited to 'llvm/lib/BinaryFormat/Wasm.cpp')
-rw-r--r--llvm/lib/BinaryFormat/Wasm.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/BinaryFormat/Wasm.cpp b/llvm/lib/BinaryFormat/Wasm.cpp
index 1d36b2cb6fb..d46be481edb 100644
--- a/llvm/lib/BinaryFormat/Wasm.cpp
+++ b/llvm/lib/BinaryFormat/Wasm.cpp
@@ -35,3 +35,17 @@ std::string llvm::wasm::relocTypetoString(uint32_t Type) {
llvm_unreachable("unknown reloc type");
}
}
+
+bool llvm::wasm::relocTypeHasAddend(uint32_t Type) {
+ switch (Type) {
+ case R_WASM_MEMORY_ADDR_LEB:
+ case R_WASM_MEMORY_ADDR_SLEB:
+ case R_WASM_MEMORY_ADDR_REL_SLEB:
+ case R_WASM_MEMORY_ADDR_I32:
+ case R_WASM_FUNCTION_OFFSET_I32:
+ case R_WASM_SECTION_OFFSET_I32:
+ return true;
+ default:
+ return false;
+ }
+}
OpenPOWER on IntegriCloud