[PATCH] D27276: [ELF, WIP] Allow defined symbols to be assigned from linker script

Meador Inge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 11:52:10 PST 2016


meadori created this revision.
meadori added reviewers: ruiu, atanasyan.
meadori added a subscriber: llvm-commits.

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 https://reviews.llvm.org/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.


https://reviews.llvm.org/D27276

Files:
  ELF/LinkerScript.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27276.79784.patch
Type: text/x-patch
Size: 4148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161130/40bdf682/attachment.bin>


More information about the llvm-commits mailing list