https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110729
Bug ID: 110729
Summary: -fpatchable-function-entries:
__patchable_function_entries has wrong sh_link
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: i at maskray dot me
Target Milestone: ---
Noticed by Ziwei Mao.
% cat a.c
void f() {}
void g() {}
void h() {}
% gcc -ffunction-sections -fpatchable-function-entry=2 -c a.c
% gcc -ffunction-sections -fpatchable-function-entry=2 -S a.c
a.o has .text.f, .text.g, and .text.h, but just one
__patchable_function_entries section.
% grep __patchable_function_entries a.s
.section __patchable_function_entries,"awo",@progbits,f
.section __patchable_function_entries,"awo",@progbits,f
.section __patchable_function_entries,"awo",@progbits,f
I think the second and the third __patchable_function_entries should reference
g and h, respectively. Otherwise, if f is discarded by ld --gc-sections, the
whole __patchable_function_entries (also used by g and h) will be discarded.
(Also, if g is discarded, its __patchable_function_entries fragment may be
retained if f is retained.)