[Bug lto/67548] New: [5/6 Regression] LTO drops weak binding with "ld -r"
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Sep 11 12:16:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67548
Bug ID: 67548
Summary: [5/6 Regression] LTO drops weak binding with "ld -r"
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.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]$
More information about the Gcc-bugs
mailing list