[lld] r357710 - [WebAssembly] Add new explicit relocation types for PIC relocations
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 10:43:50 PDT 2019
Author: sbc
Date: Thu Apr 4 10:43:50 2019
New Revision: 357710
URL: http://llvm.org/viewvc/llvm-project?rev=357710&view=rev
Log:
[WebAssembly] Add new explicit relocation types for PIC relocations
See https://github.com/WebAssembly/tool-conventions/pull/106
Differential Revision: https://reviews.llvm.org/D59907
Modified:
lld/trunk/wasm/InputChunks.cpp
lld/trunk/wasm/InputFiles.cpp
Modified: lld/trunk/wasm/InputChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputChunks.cpp?rev=357710&r1=357709&r2=357710&view=diff
==============================================================================
--- lld/trunk/wasm/InputChunks.cpp (original)
+++ lld/trunk/wasm/InputChunks.cpp Thu Apr 4 10:43:50 2019
@@ -59,7 +59,9 @@ void InputChunk::verifyRelocTargets() co
ExistingValue = decodeULEB128(Loc, &BytesRead);
break;
case R_WASM_TABLE_INDEX_SLEB:
+ case R_WASM_TABLE_INDEX_REL_SLEB:
case R_WASM_MEMORY_ADDR_SLEB:
+ case R_WASM_MEMORY_ADDR_REL_SLEB:
ExistingValue = static_cast<uint32_t>(decodeSLEB128(Loc, &BytesRead));
break;
case R_WASM_TABLE_INDEX_I32:
@@ -119,7 +121,9 @@ void InputChunk::writeTo(uint8_t *Buf) c
encodeULEB128(Value, Loc, 5);
break;
case R_WASM_TABLE_INDEX_SLEB:
+ case R_WASM_TABLE_INDEX_REL_SLEB:
case R_WASM_MEMORY_ADDR_SLEB:
+ case R_WASM_MEMORY_ADDR_REL_SLEB:
encodeSLEB128(static_cast<int32_t>(Value), Loc, 5);
break;
case R_WASM_TABLE_INDEX_I32:
Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=357710&r1=357709&r2=357710&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Thu Apr 4 10:43:50 2019
@@ -99,13 +99,15 @@ uint32_t ObjFile::calcNewAddend(const Wa
uint32_t ObjFile::calcExpectedValue(const WasmRelocation &Reloc) const {
switch (Reloc.Type) {
case R_WASM_TABLE_INDEX_I32:
- case R_WASM_TABLE_INDEX_SLEB: {
+ case R_WASM_TABLE_INDEX_SLEB:
+ case R_WASM_TABLE_INDEX_REL_SLEB: {
const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index];
return TableEntries[Sym.Info.ElementIndex];
}
case R_WASM_MEMORY_ADDR_SLEB:
case R_WASM_MEMORY_ADDR_I32:
- case R_WASM_MEMORY_ADDR_LEB: {
+ case R_WASM_MEMORY_ADDR_LEB:
+ case R_WASM_MEMORY_ADDR_REL_SLEB: {
const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index];
if (Sym.isUndefined())
return 0;
@@ -140,10 +142,12 @@ uint32_t ObjFile::calcNewValue(const Was
switch (Reloc.Type) {
case R_WASM_TABLE_INDEX_I32:
case R_WASM_TABLE_INDEX_SLEB:
+ case R_WASM_TABLE_INDEX_REL_SLEB:
return getFunctionSymbol(Reloc.Index)->getTableIndex();
case R_WASM_MEMORY_ADDR_SLEB:
case R_WASM_MEMORY_ADDR_I32:
case R_WASM_MEMORY_ADDR_LEB:
+ case R_WASM_MEMORY_ADDR_REL_SLEB:
if (auto *Sym = dyn_cast<DefinedData>(getDataSymbol(Reloc.Index)))
if (Sym->isLive())
return Sym->getVirtualAddress() + Reloc.Addend;
More information about the llvm-commits
mailing list