cat > ./a.s <<eof .section .text._Z3foov,"axG",@progbits,_Z3foov,comdat .hidden _Z3foov .weak _Z3foov .type _Z3foov,@function _Z3foov: ret eof cc -c a.s GRP_COMDAT deduplication is based on name, so after objcopy --localize-hidden, the group may keep deduplication semantics. This may be undesired if the user intention is to make the hidden symbols fully internal. % objcopy --localize-hidden a.o b.o && readelf -Ws -x .group b.o Symbol table '.symtab' contains 8 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FUNC LOCAL HIDDEN 5 _Z3foov 2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 3: 0000000000000000 0 SECTION LOCAL DEFAULT 2 4: 0000000000000000 0 SECTION LOCAL DEFAULT 3 5: 0000000000000000 0 SECTION LOCAL DEFAULT 4 6: 0000000000000000 0 SECTION LOCAL DEFAULT 5 7: 0000000000000000 0 SECTION LOCAL DEFAULT 6 Hex dump of section '.group': 0x00000000 01000000 05000000 ........ -G is similar. See https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc "GRP_COMDAT group with STB_LOCAL signature" for a generic-abi discussion.
Ping:) I am updating llvm-objcopy to drop GRP_COMDAT
There was an old (7 years ago) bug filed against GCC about __x86.get_pc_thunk and "objcopy --keep-global-symbol" (https://gcc.gnu.org/PR59842) which seems like the same issue here.
A patch is posted at https://sourceware.org/pipermail/binutils/2021-December/118824.html