summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/WasmObjectWriter.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-06-16 23:59:10 +0000
committerSam Clegg <sbc@chromium.org>2017-06-16 23:59:10 +0000
commit9d24fb7ff318d7a88f0fa3e63eb0df4acafd9805 (patch)
tree831fda1fcb2d777624a62553479acb958f043e43 /llvm/lib/MC/WasmObjectWriter.cpp
parent4f1fca270acd736cbde43773d1fd83b3b3d2164f (diff)
downloadbcm5719-llvm-9d24fb7ff318d7a88f0fa3e63eb0df4acafd9805.tar.gz
bcm5719-llvm-9d24fb7ff318d7a88f0fa3e63eb0df4acafd9805.zip
[WebAssembly] Use __stack_pointer global when writing wasm binary
This ensures that symbolic relocations are generated for stack pointer manipulations. These relocations are of type R_WEBASSEMBLY_GLOBAL_INDEX_LEB. This change also adds support for reading relocations of this type in WasmObjectFile.cpp. Since its a globally imported symbol this does mean that the get_global/set_global instruction won't be valid until the objects are linked that global used in no longer an imported global. Differential Revision: https://reviews.llvm.org/D34172 llvm-svn: 305616
Diffstat (limited to 'llvm/lib/MC/WasmObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index db304c027f9..7ac4fb8767e 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -406,6 +406,8 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
}
assert(!IsPCRel);
+ assert(SymA);
+
unsigned Type = getRelocType(Target, Fixup);
WasmRelocationEntry Rec(FixupOffset, SymA, C, Type, &FixupSection);
@@ -474,6 +476,7 @@ uint32_t WasmObjectWriter::getRelocationIndexValue(
assert(IndirectSymbolIndices.count(RelEntry.Symbol));
return IndirectSymbolIndices[RelEntry.Symbol];
case wasm::R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
+ case wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB:
case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32:
@@ -500,7 +503,8 @@ void WasmObjectWriter::applyRelocations(
switch (RelEntry.Type) {
case wasm::R_WEBASSEMBLY_TABLE_INDEX_SLEB:
case wasm::R_WEBASSEMBLY_FUNCTION_INDEX_LEB:
- case wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB: {
+ case wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB:
+ case wasm::R_WEBASSEMBLY_GLOBAL_INDEX_LEB: {
uint32_t Index = getRelocationIndexValue(RelEntry);
WritePatchableSLEB(Stream, Index, Offset);
break;
@@ -526,7 +530,7 @@ void WasmObjectWriter::applyRelocations(
break;
}
default:
- llvm_unreachable("unsupported relocation type");
+ llvm_unreachable("invalid relocation type");
}
}
}
OpenPOWER on IntegriCloud