[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/24486] New: ld shouldn't complain undefined weak refereence
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/24486] New: ld shouldn't complain undefined weak refereence |
Date: |
Thu, 25 Apr 2019 20:33:08 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=24486
Bug ID: 24486
Summary: ld shouldn't complain undefined weak refereence
Product: binutils
Version: 2.33 (HEAD)
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
address@hidden lto-6]$ cat foo.c
extern void bar (void) __attribute__((weak));
void
foo (void)
{
if (bar)
bar ();
}
address@hidden lto-6]$ cat lib.c
int FLAGS_verbose;
address@hidden lto-6]$ cat x.c
extern int FLAGS_verbose;
extern void bar (void);
int
a(const char *b) {
return FLAGS_verbose;
}
void unused (void) { bar(); }
int main() { a(""); return 0; }
address@hidden lto-6]$ make clean
rm -f *.o *.so x *.out ./*.s ./*.res
address@hidden lto-6]$ cat foo.c
extern void bar (void) __attribute__((weak));
void
foo (void)
{
if (bar)
bar ();
}
address@hidden lto-6]$ cat lib.c
int FLAGS_verbose;
address@hidden lto-6]$ cat x.c
extern int FLAGS_verbose;
extern void bar (void);
int
a(void) {
return FLAGS_verbose;
}
void unused (void) { bar(); }
int main() { return a (); }
address@hidden lto-6]$ make
gcc -B./ -O -flto -c -o x.o x.c
gcc -B./ -O -c -o lib.o lib.c
gcc -B./ -O -fpic -c -o foo.o foo.c
gcc -B./ -shared -O -o libfoo.so foo.o
gcc -B./ -shared -O -o libx.so lib.o libfoo.so
gcc -B./ -o x x.o libx.so -Wl,--as-needed -L. -lfoo
./ld: ./libfoo.so: undefined reference to `bar'
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: x] Error 1
address@hidden lto-6]$ readelf -s ./libfoo.so | grep bar
2: 0000000000000000 0 NOTYPE WEAK DEFAULT UND bar
Weak undefined reference is OK.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/24486] New: ld shouldn't complain undefined weak refereence,
hjl.tools at gmail dot com <=