https://sourceware.org/bugzilla/show_bug.cgi?id=18954
Bug ID: 18954
Summary: LTO drops weak binding with "ld -r"
Product: binutils
Version: 2.26 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
[hjl@gnu-6 lto]$ cat test.c
extern int x;
void foobar (void) { x--; }
[hjl@gnu-6 lto]$ cat test-weak.c
#include <stdio.h>
int x;
__attribute__((weak))
void foobar (void) { x++; }
int main (void)
{
foobar ();
if (x == -1)
printf ("OK\n");
return 0;
}
[hjl@gnu-6 lto]$ make
gcc -flto -O2 -c -o test-weak.o test-weak.c
gcc -flto -O2 -nostdlib -r -o test-intermediate.o test-weak.o
readelf -sW test-intermediate.o | grep foobar
10: 0000000000000000 8 FUNC GLOBAL DEFAULT 1 foobar
gcc -flto -O2 -c -o test.o test.c
gcc -flto -O2 test-intermediate.o test.o -o prog
test.o (symbol from plugin): In function `foobar':
(.text+0x0): multiple definition of `foobar'
test-intermediate.o:(.text+0x0): first defined here
/tmp/cciS2u59.ltrans0.ltrans.o: In function `foobar':
<artificial>:(.text+0x0): multiple definition of `foobar'
test-intermediate.o:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'prog' failed
make: *** [prog] Error 1
[hjl@gnu-6 lto]$
Linker shouldn't set LDPR_PREVAILING_DEF_IRONLY on a weakdef
for relocatable output.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils