https://sourceware.org/bugzilla/show_bug.cgi?id=20276
Bug ID: 20276
Summary: LD fails to handle common symbol with LTO
Product: binutils
Version: 2.27 (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 pr20267]$ cat main.c
int global_var;
extern void abort ();
int main(void)
{
if (global_var != 20)
abort ();
return 0;
}
[hjl@gnu-6 pr20267]$ cat foo.c
int global_var = 20;
[hjl@gnu-6 pr20267]$ make
gcc -B./ -O2 -flto -fno-lto -c main.c -o main.o
gcc -B./ -O2 -flto -c foo.c -o foo.o
ar cr --plugin `gcc -B./ -print-prog-name=liblto_plugin.so` libfoo.a foo.o
gcc -B./ -O2 -flto -o x main.o libfoo.a
gcc -B./ -O2 -flto -o y main.o foo.o
./ld: Warning: alignment 1 of symbol `global_var' in foo.o (symbol from plugin)
is smaller than 4 in main.o
main.o: In function `main':
main.c:(.text.startup+0x2): undefined reference to `global_var'
collect2: error: ld returned 1 exit status
Makefile:33: recipe for target 'y' failed
make: *** [y] Error 1
[hjl@gnu-6 pr20267]$
--
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