[PATCH] D102973: [ELF] Suppress GRP_COMDAT deduplication if the signature symbol is STB_LOCAL

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 22 19:01:27 PDT 2021


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

The ELF spec says:

> GRP_COMDAT: This is a COMDAT group. It may duplicate another COMDAT group in another object file, where duplication is defined as having the same group signature.

The wording "having the same group signature" is not clear.  GNU ld/gold/LLD
simply use the symbol name as the deduplication key.  Another interpretation is
that we should respect the regular symbol resolution rule and treat a STB_LOCAL
signature different from another object file with the same name.
I think the STB_LOCAL interpretation aligns with the ELF spirit.

Compilers don't produce local signature symbols. However, a local signature
symbol may be created by
`objcopy --localize-hidden/--keep-global-symbol` or IR internalization (if we
apply D53234 <https://reviews.llvm.org/D53234>). I feel that it is useful to suppress GRP_COMDAT deduplication
when the signature symbol is STB_LOCAL.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102973

Files:
  lld/ELF/InputFiles.cpp
  lld/ELF/InputFiles.h
  lld/ELF/Relocations.cpp
  lld/test/ELF/comdat-local.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102973.347226.patch
Type: text/x-patch
Size: 4791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210523/1d877fe2/attachment.bin>


More information about the llvm-commits mailing list