[PATCH] D54249: [WebAssembly] Initial support for shared objects (-shared)
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 13 08:49:11 PST 2018
sbc100 added inline comments.
================
Comment at: wasm/Driver.cpp:395
!Config->Relocatable);
+ Config->Pie = Args.hasFlag(OPT_pie, OPT_no_pie, false);
Config->PrintGcSections =
----------------
ruiu wrote:
> This may be a silly question, but in wasm, what is the notion of position-independent executable? Are executable expected to be loaded at a fixed address by default, and you can opt out with `-pie`? The notion of PIE is dependent on the memory layout of the physical machine, and that's quite different from wasm's memory model.
The meaning of `-fPIC/-fpie` is a little different for wasm. Since the code its JITd rather than mmaped, all the code is position independent by defintion. However there are two things these flags are needed for:
1. For `-fPIC` code the location of global data is not known at link time, so global data accesses are offset from the `__memory_base` import.
2. All indirect function calls need to go via the indirect function table, but for `-fPIE` the region of the table we are using is not known until runtime so we need to be offset all table indexes by `__table_base`.
This means that code compiled with `-fPIC` pays a slight performance cost for accessing global data and calling non-hidden function.
In these respect `-shared` and `-fpie` produce very similar results (both these options set Config->Pie which triggers most of this behaviour).
For an executable compiled without `-fpie` the location of __memory_base and __table_base is fixed at link time so slightly more efficient even when given code compiled with -fPIC.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D54249
More information about the llvm-commits
mailing list