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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 02:47:26 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: dim, grimar, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

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)


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D64550

Files:
  ELF/SymbolTable.cpp
  ELF/SymbolTable.h
  test/ELF/dynamic-list-preempt.s
  test/ELF/version-script-reassign.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64550.209150.patch
Type: text/x-patch
Size: 5578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190711/2fc963de/attachment.bin>


More information about the llvm-commits mailing list