Bug 5789 - Linker doesn't check weak and hidden symbols
Summary: Linker doesn't check weak and hidden symbols
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-23 23:07 UTC by H.J. Lu
Modified: 2008-03-24 13:39 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 2008-02-23 23:07:29 UTC
bash-3.2$ cat x.c
extern void foo() __attribute__((weak,visibility("hidden")));
extern int puts( char const* );
int main()
{
        foo ? foo() : puts( "foo == null, skipped." );
        return 0;
}
bash-3.2$ /usr/gcc-4.4/bin/gcc -B./ -fPIC -g   -c -o x.o x.c
bash-3.2$ ./ld -shared -o libx.so x.o
./ld: x.o: relocation R_X86_64_PC32 against `foo' can not be used when making a
shared object; recompile with -fPIC
./ld: final link failed: Bad value
bash-3.2$ /usr/gcc-4.4/bin/gcc -B./ -fPIC -g   -c -o x.o x.c -m32
bash-3.2$ ld -m elf_i386 -shared -o libx.so x.o
bash-3.2$ 

Linker should issue clear error message for both cases.
Comment 2 H.J. Lu 2008-03-24 13:39:41 UTC
Fixed by

http://sourceware.org/ml/binutils/2008-03/msg00111.html