https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120184
Bug ID: 120184
Summary: --gc-section can't discard unused section due to
fpatchable-function-entry ?
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: liuhongt at gcc dot gnu.org
Target Milestone: ---
cat test.c
int foo1(void)
{
static int foo_1;
return ++foo_1;
}
int foo2(void)
{
static int foo_2;
return ++foo_2;
}
int foo3(void)
{
static int foo_3;
return ++foo_3;
}
int main(void)
{
return foo1() + foo3();
}
with gcc -o result_issue -c test.c -ffunction-sections -fdata-sections
-fpatchable-function-entry=16,16 -Wl,--gc-sections
readelf -a result_isse
[ 6] __patchable_[...] PROGBITS 0000000000000000 00000070
0000000000000008 0000000000000000 WAL 4 0 8
[ 7] .rela__patch[...] RELA 0000000000000000 00000418
0000000000000018 0000000000000018 I 28 6 8
[ 8] .text.foo2 PROGBITS 0000000000000000 00000078
000000000000002b 0000000000000000 AX 0 0 1
[ 9] .rela.text.foo2 RELA 0000000000000000 00000430
0000000000000048 0000000000000018 I 28 8 8
foo2 is still there