diff options
author | Sam Clegg <sbc@chromium.org> | 2021-01-21 12:07:43 -0800 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2021-01-21 13:58:28 -0800 |
commit | d75b3719828f3e0c9736476e50a08e5083f90c0b (patch) | |
tree | bf480935101088b32457444014447c139921d074 /llvm/lib/Object/WasmObjectFile.cpp | |
parent | bd3a387ee76f58caa0d7901f3f84e9bb3d006f27 (diff) | |
download | llvm-d75b3719828f3e0c9736476e50a08e5083f90c0b.zip llvm-d75b3719828f3e0c9736476e50a08e5083f90c0b.tar.gz llvm-d75b3719828f3e0c9736476e50a08e5083f90c0b.tar.bz2 |
[WebAssembly] Test that invalid symbol/relocation types generate errors
See https://bugs.llvm.org/show_bug.cgi?id=48827
Differential Revision: https://reviews.llvm.org/D95163
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index a349dde..65adec3 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -693,7 +693,8 @@ Error WasmObjectFile::parseLinkingSectionSymtab(ReadContext &Ctx) { } default: - return make_error<GenericBinaryError>("Invalid symbol type", + return make_error<GenericBinaryError>("Invalid symbol type: " + + Twine(unsigned(Info.Kind)), object_error::parse_failed); } @@ -850,14 +851,15 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) { uint32_t PreviousOffset = 0; while (RelocCount--) { wasm::WasmRelocation Reloc = {}; - Reloc.Type = readVaruint32(Ctx); + uint32_t type = readVaruint32(Ctx); + Reloc.Type = type; Reloc.Offset = readVaruint32(Ctx); if (Reloc.Offset < PreviousOffset) return make_error<GenericBinaryError>("Relocations not in offset order", object_error::parse_failed); PreviousOffset = Reloc.Offset; Reloc.Index = readVaruint32(Ctx); - switch (Reloc.Type) { + switch (type) { case wasm::R_WASM_FUNCTION_INDEX_LEB: case wasm::R_WASM_TABLE_INDEX_SLEB: case wasm::R_WASM_TABLE_INDEX_SLEB64: @@ -935,9 +937,8 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) { Reloc.Addend = readVarint32(Ctx); break; default: - return make_error<GenericBinaryError>("Bad relocation type: " + - Twine(Reloc.Type), - object_error::parse_failed); + return make_error<GenericBinaryError>( + "Bad relocation type: " + Twine(type), object_error::parse_failed); } // Relocations must fit inside the section, and must appear in order. They |