This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
A symbol in a shared library, which has already been resolved.
- From: tanaka <tanaka at personal-media dot co dot jp>
- To: binutils at sources dot redhat dot com
- Date: Mon, 17 May 2004 19:48:04 +0900
- Subject: A symbol in a shared library, which has already been resolved.
Hello All,
This sample says,
>./libtest.so: undefined reference to `temtem'
.
MAIN() has already been resolved, without libtest.so.1.
Why MAIN() in libtest.so.1 is referenced?
--------- result ----------------
tanaka:/work/test/undef/$ ./mk.rc
./libtest.so: undefined reference to `temtem'
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
GNU ld version 2.13.90.0.18 20030206
tanaka:/work/test/undef/$
--------------------------------
Thanks.
t_tanaka
#!/bin/sh
#mk.rc
### This makes startup.
gcc -c crt0.S -o crt0.o
### This makes sample main program.
gcc -c test.c -o test.o
### This makes shared library.
gcc -fPIC -c MAIN.c -o MAIN.o
gcc -shared -Wl,-soname=libtest.so.1 MAIN.o -o libtest.so.1
ln -s libtest.so.1 libtest.so
### This makes static library.
gcc -c MAIN.c -o MAIN_st.o
ar r libtest.a MAIN_st.o
### This makes final object(Without libtest.so). This runs OK.
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test -L. crt0.o test.o
### This makes static linked final object. This runs OK.
ld -m elf_i386 -static -o test -L. crt0.o test.o -ltest
### This makes final object(With libtest.so). Why error occured?
ld -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test -L. crt0.o test.o -ltest
gcc -v
ld -v
/* crt0.S */
.text
.align 2
.globl _start
_start:
jmp MAIN
/* test.c */
void MAIN(void) { }
/* MAIN.c */
void MAIN(void) {
void temtem( void);
temtem();
}