diff options
author | Sam Clegg <sbc@chromium.org> | 2017-04-26 00:02:31 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-04-26 00:02:31 +0000 |
commit | cc182aaaef21864df857d0bf3e9844a0db8d2403 (patch) | |
tree | fec0fb85d52fba64410a70516d2eb2df5e9fdcb1 /llvm/lib | |
parent | ff49a055655c78704ee8ddf912f14162142e7bc0 (diff) | |
download | bcm5719-llvm-cc182aaaef21864df857d0bf3e9844a0db8d2403.tar.gz bcm5719-llvm-cc182aaaef21864df857d0bf3e9844a0db8d2403.zip |
[WebAssembly] Allow for signed relocation addends
Summary:
Addends are used as offsets to addresses of globals
and can be both positive and negative. This change
prints libObject in line with the spec and the MC
layer.
Subscribers: jfb, dschuff
Differential Revision: https://reviews.llvm.org/D32507
llvm-svn: 301369
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/ObjectYAML/WasmYAML.cpp | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index e1b3c4e1f39..4e1f237e17c 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -316,14 +316,15 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, const uint8_t *Ptr, case wasm::R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case wasm::R_WEBASSEMBLY_TABLE_INDEX_SLEB: case wasm::R_WEBASSEMBLY_TABLE_INDEX_I32: + case wasm::R_WEBASSEMBLY_TYPE_INDEX_LEB: break; case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_LEB: case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_SLEB: case wasm::R_WEBASSEMBLY_GLOBAL_ADDR_I32: - Reloc.Addend = readVaruint32(Ptr); + Reloc.Addend = readVarint32(Ptr); break; default: - return make_error<GenericBinaryError>("Bad relocation type", + return make_error<GenericBinaryError>("Bad relocation type: " + Twine(Reloc.Type), object_error::parse_failed); } Section->Relocations.push_back(Reloc); diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp index 1c7c07ae29e..9b1ff7e5dc1 100644 --- a/llvm/lib/ObjectYAML/WasmYAML.cpp +++ b/llvm/lib/ObjectYAML/WasmYAML.cpp @@ -223,7 +223,7 @@ void MappingTraits<WasmYAML::Relocation>::mapping( IO.mapRequired("Type", Relocation.Type); IO.mapRequired("Index", Relocation.Index); IO.mapRequired("Offset", Relocation.Offset); - IO.mapRequired("Addend", Relocation.Addend); + IO.mapOptional("Addend", Relocation.Addend, 0); } void MappingTraits<WasmYAML::LocalDecl>::mapping( |