This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Refine --export-dynamic-symbol semantics to be compatible GNU ld 2.35
ClosedPublic

Authored by MaskRay on May 23 2020, 8:03 PM.

Details

Summary

GNU ld from binutils 2.35 onwards will likely support
--export-dynamic-symbol but with different semantics.
https://sourceware.org/pipermail/binutils/2020-May/111302.html

Differences:

  1. -export-dynamic-symbol is not supported
  2. --export-dynamic-symbol takes a glob argument
  3. --export-dynamic-symbol can suppress binding the references to the definition within the shared object if (-Bsymbolic or -Bsymbolic-functions)
  4. --export-dynamic-symbol does not imply -u

I don't think the first three points can affect any user.
For the fourth point, Not implying -u can lead to some archive members unfetched.
Add -u foo to restore the previous behavior.

Exact semantics:

  • -no-pie or -pie: matched non-local defined symbols will be added to the dynamic symbol table.
  • -shared: matched non-local STV_DEFAULT symbols will not be bound to definitions within the shared object even if they would otherwise be due to -Bsymbolic, -Bsymbolic-functions, or --dynamic-list.

Diff Detail

Event Timeline

MaskRay created this revision.May 23 2020, 8:03 PM
MaskRay updated this revision to Diff 265906.May 23 2020, 8:10 PM

Improve tests

Looks reasonable to me. Our documentation and help for dynamic-list is a bit sparse, it may be worth emphasising that it implies -bsymbolic (if I've understood correctly).

lld/ELF/Options.td
148–153

May be worth adding that this implies -bsymbolic apart from symbols in dynamic-list.

lld/docs/ld.lld.1
159–163

May be worth adding that this implies -bsymbolic apart from symbols in dynamic-list.

MaskRay updated this revision to Diff 266574.May 27 2020, 9:17 AM
MaskRay edited the summary of this revision. (Show Details)

Improve documentation

MaskRay marked 2 inline comments as done.May 27 2020, 9:22 AM
psmith accepted this revision.May 27 2020, 11:06 AM

Thanks for the update. I'm happy with the changes.

This revision is now accepted and ready to land.May 27 2020, 11:06 AM

(I have no comments for this. Happy if other people are happy).

MaskRay edited the summary of this revision. (Show Details)Jun 1 2020, 11:23 AM
MaskRay edited the summary of this revision. (Show Details)Jun 1 2020, 11:25 AM
MaskRay updated this revision to Diff 267679.Jun 1 2020, 11:28 AM

Add MetaVarName<"<file>"> to dynamic_list

This revision was automatically updated to reflect the committed changes.