https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95928
Bug ID: 95928
Summary: LTO through ar breaks weak function resolution
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: andi-gcc at firstfloor dot org
CC: marxin at gcc dot gnu.org
Target Milestone: ---
Target: x86_64-linux
Created attachment 48791
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48791&action=edit
dummy.c
With the attached test case (extracted from the Linux kernel) the expected
behavior is that the strong version of __x64_sys_capget overrides the weak
version in sys_ni.i
This works with LTO when the object files are linked directly, but doesn't work
(weak version of function is output) when the linking is through a .a file.
Works
gcc -flto -c sys_ni.i
gcc -flto -c capability.i
gcc -O2 -flto dummy.c sys_ni.o capability.o
# sys_ni_syscall doesn't appear, so the strong version is chosen
objdump --disassemble=__x64_sys_capget | grep sys_ni_syscall
Breaks:
gcc -flto -c sys_ni.i
gcc -flto -c capability.i
rm -f x.a
gcc-ar q x.a sys_ni.o capability.o
gcc -O2 -flto dummy.c x.a
# sys_ni_syscall appears, so the weak version is incorrectly chosen
objdump --disassemble=__x64_sys_capget | grep sys_ni_syscall
This seems to be a regression, it worked on gcc-7, but breaks on gcc 9/10.
Don't have any immediate versions to test.