[llvm] r257416 - [WebAssembly] Define WebAssembly-specific relocation codes.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 15:58:36 PST 2016


On 19 January 2016 at 16:33, Dan Gohman <sunfish at mozilla.com> wrote:
> WebAssembly functions are not loaded into the application address space.
> Functions are identified, both statically, and in dynamic function pointer
> values, through special index values (ignoring certain optimizations).
>
> Many ELF tools have relocation infrastructure that is very focused on
> resolving a relocation by supplying a virtual address, or some function of
> the virtual address. For example, in lld, the relocateOne hook isn't told
> what symbol it's relocating or what its type is; it just gets passed the
> resolved virtual address for the symbol. It is also told the relocation
> code, so by using R_WEBASSEMBLY_FUNCTION, which comes from
> VK_WebAssembly_FUNCTION, we can at least inform it that it needs to do
> something different.
>
> Of course, it's also presumably possible to modify lld and other tools to
> keep track of symbols in more places, and use their types to decide what to
> do. I decided against this because it is also nice to have each relocation
> code be used for a specific kind of value -- R_WEBASSEMBLY_DATA for virtual
> addresses, and R_WEBASSEMBLY_FUNCTION for function indices. In theory, a
> smart linker that knows the symbol types could even check that functions
> always use R_WEBASSEMBLY_FUNCTION, for example.
>
> Another consideration is that not all ELF producers set .type for all
> symbols. One can argue about whether this is a bug in those producers or
> not, but using a relocation code seemed like it might be a little more
> robust.
>
> All that said, I'm definitely open to feedback here.

Sounds reasonable given the explanation. If the two relocations write
different values they should be two relocations. How are data
relocations represented BTW? So far the psabi is

* R_WEBASSEMBLY_FUNCTION: Write the the index value of the function.
* R_WEBASSEMBLY_DATA: ?

Do you guys use Rel or Rela? Do addends even make sense?

Cheers,
Rafael


More information about the llvm-commits mailing list