https://sourceware.org/bugzilla/show_bug.cgi?id=33370
Bug ID: 33370
Summary: gas: monolithic .sframe violates COMDAT group rule
Product: binutils
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: gas
Assignee: unassigned at sourceware dot org
Reporter: i at maskray dot me
Target Milestone: ---
https://maskray.me/blog/2021-07-25-comdat-and-section-group#group-signature-localization
The generic ABI says:
> A symbol table entry with STB_LOCAL binding that is defined relative to one
> of a group's sections, and that is contained in a symbol table section that
> is not part of the group, must be discarded if the group members are
> discarded. References to this symbol table entry from outside the group are
> not allowed.
Generally, if you want to reference a local symbol relative to a section in a
COMDAT group, the referencing section should be part of the same group.
.sframe
cat > a.cc <<'eof'
[[gnu::noinline]] inline int inl() { return 0; }
auto *fa = inl;
eof
cat > b.cc <<'eof'
[[gnu::noinline]] inline int inl() { return 0; }
auto *fb = inl;
eof
~/opt/gcc-15/bin/g++ -Wa,--gsframe -c a.cc b.cc
% ld.lld a.o b.o
ld.lld: error: relocation refers to a discarded section: .text._Z3inlv
>>> defined in b.o
>>> referenced by b.cc
>>> b.o:(.sframe+0x1c)
% gold a.o b.o
b.o(.sframe+0x1c): error: relocation refers to local symbol ".text._Z3inlv"
[2], which is defined in a discarded section
section group signature: "inl()"
prevailing definition is from a.o
% readelf -W -S a.o | grep sframe
[11] .sframe PROGBITS 0000000000000000 0000b0 00003f 00 A
0 0 8
[12] .rela.sframe RELA 0000000000000000 0001b0 000018 18 I
13 11 8
.sframe violates this rule.
--
You are receiving this mail because:
You are on the CC list for the bug.