https://sourceware.org/bugzilla/show_bug.cgi?id=19719
Bug ID: 19719
Summary: Mixing PIC and non-PIC input files generates
unexpected result
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: ---
Target: x86
[hjl@gnu-6 weak-4]$ cat foo.c
extern int __attribute__ ((weak)) fun (void);
int
foo (void)
{
if (&fun != 0)
return fun ();
return 0;
}
[hjl@gnu-6 weak-4]$ cat bar.c
extern int __attribute__ ((weak)) fun (void);
int
bar (void)
{
if (&fun != 0)
return fun ();
return 0;
}
[hjl@gnu-6 weak-4]$ cat main.c
#include <stdlib.h>
extern int foo (void);
extern int bar (void);
int
main (void)
{
if (foo () != bar ())
abort ();
return 0;
}
[hjl@gnu-6 weak-4]$ cat fun1.c
/* Dummy */
[hjl@gnu-6 weak-4]$ cat fun2.c
int
fun (void)
{
return 20;
}
[hjl@gnu-6 weak-4]$ make
gcc -B./ -O2 -c -o foo.o foo.c
gcc -B./ -O2 -fPIC -c -o bar.o bar.c
gcc -B./ -O2 -c -o main.o main.c
gcc -B./ -shared -Wl,-soname,libfun.so -fPIC -O2 -o libfun1.so fun1.c
gcc -B./ -shared -Wl,-soname,libfun.so -fPIC -O2 -o libfun2.so fun2.c
ln -sf libfun1.so libfun.so
gcc -B./ -O2 -o x foo.o bar.o main.o libfun.so -Wl,-R,.
ln -sf libfun1.so libfun.so
./x
ln -sf libfun2.so libfun.so
./x
Makefile:20: recipe for target 'all' failed
make: *** [all] Aborted
[hjl@gnu-6 weak-4]$
--
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