Bug 27931 - objcopy --localize-hidden/--keep-global-symbol: drop GRP_COMDAT if the signature symbol becomes local?
Summary: objcopy --localize-hidden/--keep-global-symbol: drop GRP_COMDAT if the signat...
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-29 23:54 UTC by Fangrui Song
Modified: 2021-12-06 16:55 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2021-12-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-05-29 23:54:11 UTC
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.
Comment 1 Fangrui Song 2021-07-26 05:19:34 UTC
Ping:)

I am updating llvm-objcopy to drop GRP_COMDAT
Comment 2 Andrew Pinski 2021-12-05 08:55:39 UTC
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.
Comment 3 H.J. Lu 2021-12-06 16:55:45 UTC
A patch is posted at

https://sourceware.org/pipermail/binutils/2021-December/118824.html