[llvm] r364367 - [WebAssembly] Fix list of relocations with addends in lld
Keno Fischer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 17:52:42 PDT 2019
Author: kfischer
Date: Tue Jun 25 17:52:42 2019
New Revision: 364367
URL: http://llvm.org/viewvc/llvm-project?rev=364367&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm/BinaryFormat/Wasm.h
llvm/trunk/lib/BinaryFormat/Wasm.cpp
llvm/trunk/lib/MC/WasmObjectWriter.cpp
Modified: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Wasm.h?rev=364367&r1=364366&r2=364367&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h Tue Jun 25 17:52:42 2019
@@ -364,6 +364,7 @@ inline bool operator!=(const WasmGlobalT
std::string toString(WasmSymbolType type);
std::string relocTypetoString(uint32_t type);
+bool relocTypeHasAddend(uint32_t type);
} // end namespace wasm
} // end namespace llvm
Modified: llvm/trunk/lib/BinaryFormat/Wasm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/BinaryFormat/Wasm.cpp?rev=364367&r1=364366&r2=364367&view=diff
==============================================================================
--- llvm/trunk/lib/BinaryFormat/Wasm.cpp (original)
+++ llvm/trunk/lib/BinaryFormat/Wasm.cpp Tue Jun 25 17:52:42 2019
@@ -35,3 +35,17 @@ std::string llvm::wasm::relocTypetoStrin
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;
+ }
+}
Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=364367&r1=364366&r2=364367&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Tue Jun 25 17:52:42 2019
@@ -147,19 +147,7 @@ struct WasmRelocationEntry {
: Offset(Offset), Symbol(Symbol), Addend(Addend), Type(Type),
FixupSection(FixupSection) {}
- bool hasAddend() const {
- switch (Type) {
- case wasm::R_WASM_MEMORY_ADDR_LEB:
- case wasm::R_WASM_MEMORY_ADDR_SLEB:
- case wasm::R_WASM_MEMORY_ADDR_REL_SLEB:
- case wasm::R_WASM_MEMORY_ADDR_I32:
- case wasm::R_WASM_FUNCTION_OFFSET_I32:
- case wasm::R_WASM_SECTION_OFFSET_I32:
- return true;
- default:
- return false;
- }
- }
+ bool hasAddend() const { return wasm::relocTypeHasAddend(Type); }
void print(raw_ostream &Out) const {
Out << wasm::relocTypetoString(Type) << " Off=" << Offset
More information about the llvm-commits
mailing list