[llvm-objcopy] Drop GRP_COMDAT if the group signature is localized
authorFangrui Song <i@maskray.me>
Mon, 26 Jul 2021 16:05:18 +0000 (09:05 -0700)
committerFangrui Song <i@maskray.me>
Mon, 26 Jul 2021 16:05:18 +0000 (09:05 -0700)
commit792c206e2b63c16075d759d3abc3eb5399ed74fe
treed196b238e5a1846ddcc986a221f726b4cecdec82
parentc0da287c30c9f511ccb07fdd42c997be2caea9ec
[llvm-objcopy] Drop GRP_COMDAT if the group signature is localized

See [GRP_COMDAT group with STB_LOCAL signature](https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc)
objcopy PR: https://sourceware.org/bugzilla/show_bug.cgi?id=27931

GRP_COMDAT deduplication is purely based on the signature symbol name in
ld.lld/GNU ld/gold. The local/global status is not part of the equation.

If the signature symbol is localized by --localize-hidden or
--keep-global-symbol, the intention is likely to make the group fully
localized. Drop GRP_COMDAT to suppress deduplication.

Reviewed By: jhenderson

Differential Revision: https://reviews.llvm.org/D106782
llvm/test/tools/llvm-objcopy/ELF/group-reorder.test
llvm/test/tools/llvm-objcopy/ELF/group.test
llvm/test/tools/llvm-objcopy/ELF/remove-section-in-group.test
llvm/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test
llvm/tools/llvm-objcopy/ELF/Object.cpp