This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Handle non-glob patterns before glob patterns in version scripts & fix a corner case of --dynamic-list
ClosedPublic

Authored by MaskRay on Jul 11 2019, 2:47 AM.

Details

Summary

This fixes PR38549, which is silently accepted by ld.bfd.
This seems correct because it makes sense to let non-glob patterns take
precedence over glob patterns.

lld issues an error because
assignWildcardVersion(ver, VER_NDX_LOCAL); is processed before assignExactVersion(ver, v.id, v.name);.

Move all assignWildcardVersion() calls after assignExactVersion() calls
to fix this.

Also, move handleDynamicList() to the bottom. computeBinding() called by
includeInDynsym() has this cryptic rule:

if (versionId == VER_NDX_LOCAL && isDefined() && !isPreemptible)
  return STB_LOCAL;

Before the change:

  • foo's version is set to VER_NDX_LOCAL due to local: *
  • handleDynamicList() is called
    • foo.computeBinding() is STB_LOCAL
    • foo.includeInDynsym() is false
    • foo.isPreemptible is not set (wrong)
  • foo's version is set to V1

After the change:

  • foo's version is set to VER_NDX_LOCAL due to local: *
  • foo's version is set to V1
  • handleDynamicList() is called
    • foo.computeBinding() is STB_GLOBAL
    • foo.includeInDynsym() is true
    • foo.isPreemptible is set (correct)

Event Timeline

MaskRay created this revision.Jul 11 2019, 2:47 AM
ruiu accepted this revision.Jul 11 2019, 3:27 AM

LGTM

This revision is now accepted and ready to land.Jul 11 2019, 3:27 AM
MaskRay updated this revision to Diff 209165.Jul 11 2019, 4:11 AM
MaskRay edited the summary of this revision. (Show Details)

Fix the markdown bullet points in the description

MaskRay edited the summary of this revision. (Show Details)Jul 11 2019, 4:12 AM
This revision was automatically updated to reflect the committed changes.