Bug 15153 - gold fails to detect undefined symbol
Summary: gold fails to detect undefined symbol
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-16 01:48 UTC by H.J. Lu
Modified: 2013-03-08 09:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2013-02-16 01:48:40 UTC
gold fails to detect undefined symbol:

[hjl@gnu-6 xxx]$ cat foo.c
extern int xxx __attribute__((weak));

extern void bar ();

int
main ()
{
  bar ();
  return xxx;
}
[hjl@gnu-6 xxx]$ cat yyy.c
extern int xxx;

int
bar (void)
{
  return xxx;
}
[hjl@gnu-6 xxx]$ make
gcc -Wl,--no-copy-dt-needed-entries    -c -o foo.o foo.c
gcc -Wl,--no-copy-dt-needed-entries -shared -fPIC -o libyyy.so yyy.c
gcc -Wl,--no-copy-dt-needed-entries -fuse-ld=gold -B./ -Wl,--no-allow-shlib-undefined -o y foo.o libyyy.so -Wl,-rpath,.
./y
./y: symbol lookup error: ./libyyy.so: undefined symbol: xxx
make: *** [all] Error 127
[hjl@gnu-6 xxx]$ 

ld detects the error:

[hjl@gnu-6 xxx]$ make x
gcc -Wl,--no-copy-dt-needed-entries -B./ -Wl,--no-allow-shlib-undefined -o x foo.o libyyy.so -Wl,-rpath,.
foo.o: In function `main':
foo.c:(.text+0x10): undefined reference to `xxx'
collect2: error: ld returned 1 exit status
make: *** [x] Error 1
[hjl@gnu-6 xxx]$