This is an archive of the discontinued LLVM Phabricator instance.

[ARM][LLD] Synthetic symbol definitions for ARM static linking
ClosedPublic

Authored by peter.smith on Oct 26 2016, 3:58 AM.

Details

Summary

When static linking in ARM (like Mips) __tls_get_addr is defined by the library so we should not define it as a synthetic.

We also need to add exidx_start and exidx_end for the .ARM.exidx section as the static libc library startup code is expecting them to be defined by the default linker script for static linking on ARM when GNU ld is used.

Extract from arm-linux-gnueabihf-ld --static --verbose
PROVIDE_HIDDEN (__exidx_start = .);
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
PROVIDE_HIDDEN (__exidx_end = .);

There is still more work to do for static linking to work on ARM, there are problems with ifunc, TLS and unresolved weak references. I have patches ready for most of these.

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith retitled this revision from to [ARM][LLD] Synthetic symbol definitions for ARM static linking.
peter.smith updated this object.
peter.smith added reviewers: ruiu, rafael.
peter.smith added a subscriber: llvm-commits.
ruiu accepted this revision.Oct 26 2016, 1:28 PM
ruiu edited edge metadata.

LGTM

ELF/Writer.cpp
961 ↗(On Diff #75843)

Does ".ARM.exidx" always exist? If not, you want to do something like this

if (OutputSectionBase<ELFT> *Sec = findSection(".ARM.exidx")
  Define("__exidx_start", "__exidx_end", Sec);
This revision is now accepted and ready to land.Oct 26 2016, 1:28 PM
This revision was automatically updated to reflect the committed changes.

Thanks for the suggestion, I've incorporated it and committed in r285279