[PATCH] D107235: [ELF] Combine foo at v1 and foo with the same versionId if both are definedDue to an assembler design flaw (IMO), `.symver foo, foo at v1` produces two symbols`foo` and `foo at v1` if `foo` is defined.* `v1 {};` keeps `foo` as is but GNU ld will...

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 31 22:48:16 PDT 2021


MaskRay created this revision.
MaskRay added reviewers: grimar, peter.smith.
Herald added subscribers: dmgreen, arichardson, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

...eliminate `foo`

- `v1 { foo; };` can match `foo` but GNU ld will eliminate it.
- `v2 { foo; };` converts `foo` to `foo at v2` and GNU ld will keep `foo@@v2`. (Tested by symver.s)

This patch implements the behavior by reusing the symbol redirection mechanism
in D92259 <https://reviews.llvm.org/D92259>. The new test symver-non-default.s checks the first two cases.

Without the patch, the second case will produce `foo at v1` and `foo@@v1` which
looks weird and makes foo unnecessarily default versioned.

Note: `.symver foo,foo at v1,remove` exists but the unfortunate `foo` will not go
away anytime soon.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107235

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/symver-non-default.s
  lld/test/ELF/version-script-symver.s
  lld/test/ELF/version-symbol-undef.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107235.363335.patch
Type: text/x-patch
Size: 6918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210801/071573a4/attachment.bin>


More information about the llvm-commits mailing list