Hi All,
I have been working on extending LLD to handle assigning new values to symbols that are already defined via the linker script (e.g. override). This is common in some scripts that have (mainly from bare-metal GCC toolchains). The attached patch mostly works, but it has some problems related to linker-defined symbols that I will describe next. I am *not* submitting this patch as a formal submission, but a request for feedback.
As mentioned, this patch mostly works for overriding a symbol's value from the linker script, but currently falls over with respect to _gp on MIPS. In particular, the test added for D27036 fails. The reason being is that _gp is defined relative to .got. Thus consider a script with something like:
_gp = 0x100; .got : { *(.got) }
_gp gets a value of &.got + 0x100. The *new* definition from the linker script gets defined in .got too.
FWIW, in most MIPS toolchains I have work with _gp is an absolute symbol and *not* a .got relative one and the default linker scripts have things like:
HIDDEN (_gp = ALIGN (16) + 0x7ff0); .got : { *(.got) }
Comments on the general symbol override functionality and the MIPS related issue are most welcome.
It is probably easier to add a dummy symbol and then replace that unconditionally like this.
You can remove Symbol *Sym from the parameter list of this function.