[WebAssembly] Add new relocation for location relative data
authorYuta Saito <kateinoigakukun@gmail.com>
Mon, 8 Mar 2021 19:23:33 +0000 (11:23 -0800)
committerSam Clegg <sbc@chromium.org>
Mon, 8 Mar 2021 19:34:10 +0000 (11:34 -0800)
commitaa0c571a5fa9130ccd932f9b6970440a1bae177f
tree05f5d6418d8126ce18c65017f675d22d6f363ec4
parentd9a29a67527fbabd0e0388aefa8e6aa9b19f3f03
[WebAssembly] Add new relocation for location relative data

This `R_WASM_MEMORY_ADDR_SELFREL_I32` relocation represents an offset
between its relocating address and the symbol address. It's very similar
to `R_X86_64_PC32` but restricted to be used for only data segments.

```
S + A - P
```

A: Represents the addend used to compute the value of the relocatable
field.
P: Represents the place of the storage unit being relocated.
S: Represents the value of the symbol whose index resides in the
relocation entry.

Proposal: https://github.com/WebAssembly/tool-conventions/issues/162

Differential Revision: https://reviews.llvm.org/D96659
13 files changed:
lld/test/wasm/reloc-relative.s [new file with mode: 0644]
lld/wasm/InputChunks.cpp
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
llvm/include/llvm/BinaryFormat/WasmRelocs.def
llvm/include/llvm/MC/MCWasmObjectWriter.h
llvm/lib/BinaryFormat/Wasm.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/RelocationResolver.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
llvm/test/MC/WebAssembly/bad-fixup-expr.s
llvm/test/MC/WebAssembly/reloc-relative.ll [new file with mode: 0644]