From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 Description of problem: I am working on building an Oracle 10g label with PBO using gcc 3.2.3 on RHAS 3 [Red Hat Enterprise Linux AS release 3 (Taroon) Kernel \r on an \m] When I try to compile using options -fprofile-arcs -fno-omit-pointer with a shared object, the following error is raised :- /usr/bin/ld: mypgm: hidden symbol `__bb_init_func' in /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/libgcc.a(_bb.oS) is referenced by DSO collect2: ld returned 1 exit status make: *** [mypgm] Error 1 Below is the information about the relevant packages :- >>> uname -a @ Linux enterprise.us.oracle.com 2.4.21-3.ELsmp #1 SMP Fri Sep 19 14:06:12 EDT 2003 i686 i686 i386 GNU/Linux >>> gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/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.3 20030502 (Red Hat Linux 3.2.3-20) >>> rpm -qa | grep gcc gcc-3.2.3-20 gcc-c++-3.2.3-20 libgcc-3.2.3-20 >>> rpm -qa | grep glib glibc-devel-2.3.2-95.2 glibc-common-2.3.2-95.2 glib-1.2.10-11.1 glibc-headers-2.3.2-95.2 glibc-2.3.2-95.2 glib2-2.2.3-2.0 glibc-kernheaders-2.4-8.34 >>> rpm -qa | grep binutils binutils-2.14.90.0.4-25 Please find below a test case to reproduce the problem. FILE - 1 --------- /*************** Makefile starts here *********************/ #Location of the shared library MYLIBPATH=/location/of/my/shared/lib #Gcc flags PROF=-fprofile-arcs -fno-omit-frame-pointer all : mypgm mypgm: mypgm.c libmy.so gcc -o mypgm -lmy -L${MYLIBPATH} mypgm.c libmy.so : myfunc1.o myfunc2.o ld -shared -olibmy.so myfunc1.o myfunc2.o cp -a libmy.so ${MYLIBPATH} myfunc1.o : myfunc1.c gcc -c -fPIC ${PROF} myfunc1.c myfunc2.o : myfunc2.c gcc -c -fPIC ${PROF} myfunc2.c clean : rm -rf *.o *.so rm -rf ${MYLIBPATH}/* rm -rf mypgm /********************* Makefile ends here ***********************/ FILE - 2 --------- /********************* mypgm.c starts here *********************/ #include<stdio.h> extern void myfunc1(int); extern void myfunc2(int); main() { int i=1 ; printf("\n From mypgm.c ", i); while (i){ i++ ; myfunc1(i); i++ ; myfunc2(i); printf("ENTER 0 to stop or any other number to continue "); scanf("%d",&i); } } /********************** mypgm.c ends here ***********************/ FILE - 3 -------- /********************** myfunc1.c starts here *******************/ void myfunc1( int i ) { printf("\n < %d > From myfunc1.c ", i); } /******************* myfunc1.c ends here ************************/ FILE - 4 -------- /********************** myfunc2.c starts here *******************/ void myfunc2( int i ) { printf("\n < %d > From myfunc2.c ", i); } /******************* myfunc2.c ends here ************************/ I suspect that this is a problem with ld. Version-Release number of selected component (if applicable): How reproducible: Didn't try Additional info:
please explain why this is a kernel bug?
This is because -fprofile-arcs is only supported for the main application. It will not work as currently implemented for shared libraries.
Actually, the primary error is using ld -shared instead of gcc -shared. With that change it links just fine on RHEL3. ld ought to be used directly only when you know exactly what you are doing and take care of all the necessary options/arguments that are needed for successful link. gcc driver knows the details and handles all of it for you. FYI in this case you weren't linking with -lgcc.