https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119369

--- Comment #5 from Andrew Stubbs <ams at gcc dot gnu.org> ---
A post-linker could be included as part of the mkoffload process (or maybe we
could fix up the weak directives in the assembler as part of the pre-assembler
step we already have).

Either way, there's no mkoffload in the pipeline for the standalone tests.
However, given that weak symbols are known to be half-broken then maybe
-fno-weak is the correct solution in that configuration?

The way the old workaround worked was it would hide *all* the relocations from
the runtime loader by editing the ELF file in memory, and then fix up the
relocations manually, in GPU memory, after the loader had chosen the load
address. This was suboptimal because device memcpy is slow (adding to the
initial setup overhead only), but means we have full control over runtime
symbol resolution.

It's frustrating though because, as you can see from the old code, processing
relocations is not hard, and adding weak symbol support would be fairly
straight-forward, so you'd hope the driver could already handle it. :(

IIUC, the reason the weak symbols are not resolved already is because we use
--pie with --export-dynamic.  The latter ought not be necessary, but it is used
because that's what LLVM uses (or used to use during the v3 era) and is
therefore the path of least resistance within the driver code (as in, this is
the reason we could stop resolving our own relocations).  It's possible that we
don't have to do this any more?

Reply via email to