[MC][WebAssembly] Fix crash when relocation addend underlows U32
authorSam Clegg <sbc@chromium.org>
Thu, 24 Feb 2022 06:23:05 +0000 (22:23 -0800)
committerSam Clegg <sbc@chromium.org>
Fri, 25 Feb 2022 15:13:15 +0000 (07:13 -0800)
commit4c75521ce0b1ac55fba1a91ef5156fc811f5dfcb
tree1a5ff97789d1dfad4325ee9a877ca0763e55b122
parentdb7b1af8ef8f59600cbb6e529164acdbe4c8f0a2
[MC][WebAssembly] Fix crash when relocation addend underlows U32

For the object file writer we need to allow the underflow (ar write
zero), but for the final linker output we should probably generate an
error (I've left that as a TODO for now).

Fixes: https://github.com/llvm/llvm-project/issues/54012

Differential Revision: https://reviews.llvm.org/D120522
lld/test/wasm/reloc-addend.s
lld/wasm/InputChunks.cpp
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
llvm/lib/MC/WasmObjectWriter.cpp
llvm/test/MC/WebAssembly/reloc-code.s