OSDN Git Service

[WebAssembly] Add placeholders for R_WASM_TABLE_INDEX_REL_SLEB relocations
authorSam Clegg <sbc@chromium.org>
Fri, 29 May 2020 01:39:27 +0000 (18:39 -0700)
committerSam Clegg <sbc@chromium.org>
Fri, 29 May 2020 17:57:26 +0000 (10:57 -0700)
commit81443ac1bc710c89565ea1bce0eb566bf2cacd0d
treea4e99006d786fc15bdbcd55d6fa2c6207d38cbd2
parent61412b762df79328fa29dafdd1f8cc35792693ec
[WebAssembly] Add placeholders for R_WASM_TABLE_INDEX_REL_SLEB relocations

Previously in the object format we punted on this and simply wrote
zeros (and didn't include the function in the elem segment).  With
this change we write a meaningful value which is the segment
relative table index of the associated function.

This matches the that wasm-ld produces in `-r` mode.  This inconsistency
between the output the MC object writer and the wasm-ld object
writer could cause warnings to be emitted when reading back in the
output of `wasm-ld -r`.  See:
https://github.com/emscripten-core/emscripten/issues/11217

This only applies to this one relocation type which is only generated
when compiling in PIC mode.

Differential Revision: https://reviews.llvm.org/D80774
lld/wasm/InputFiles.cpp
lld/wasm/InputFiles.h
llvm/lib/MC/WasmObjectWriter.cpp
llvm/test/MC/WebAssembly/reloc-pic.s