From Fedora Project Wiki

Concrete Example Of DSO Linking Change in ld

I checked out a version of Systemtap from :

:pserver:anonymous@cvs.fedproject.org:/cvs/pkgs

and ran 'make srpm' do produce a source rpm in order to do a mock build. I ran this build with the new binutils rpm (http://roland.fedorapeople.org/ld-test/) so that it would have the version of ld with the proposed changes. After running the build the following error appeared in the log file :

RPM build errors:
/usr/bin/ld.bfd: stap.13165.test: undefined reference to symbol 'pthread_cancel@@GLIBC_2.0'
/usr/bin/ld.bfd: note: 'pthread_cancel@@GLIBC_2.0' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line
/lib/libpthread.so.0: could not read symbols: Invalid operation
*** /usr/bin/ld: ld behavior mismatch! ***
*** /usr/bin/ld.bfd succeeeded ***
*** /usr/bin/ld.bfd --no-add-needed exits 1 ***
*** arguments: --eh-frame-hdr --build-id -m elf_i386 --hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -pie -o stap 
/usr/lib/gcc/i686-redhat-linux/4.4.2/../../../Scrt1.o /usr/lib/gcc/i686- redhat-linux/4.4.2/../../../crti.o /usr/lib/gcc/i686-redhat-linux/4.4.2/crtbeginS.o
-L/usr/lib/gcc/i686-redhat-linux/4.4.2 -L/usr/lib/gcc/i686-redhat-linux/4.4.2 -L/usr/lib/gcc/i686-redhat- linux/4.4.2/../../.. -z relro -z now stap-main.o 
stap-parse.o stap-staptree.o stap-elaborate.o stap-translate.o stap-tapsets.o stap-buildrun.o stap-loc2c.o stap-hash.o stap-mdfour.o  stap-cache.o stap-util.o
stap-coveragedb.o stap-dwarf_wrappers.o stap-tapset-been.o stap-tapset-procfs.o stap-tapset-timers.o stap-tapset-perfmon.o stap-tapset-mark.o stap-tapset-itrace.o
stap-tapset-utrace.o stap-task_finder.o stap-dwflpp.o stap-rpm_finder.o --start-group -ldw -lebl --end-group -lelf -lsqlite3 -lrpm -ldl -lstdc++ -lm -lgcc_s -lgcc 
-lc -lgcc_s -lgcc /usr/lib /gcc/i686-redhat-linux/4.4.2/crtendS.o /usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crtn.o 
collect2: ld returned 1 exit status
make[2]: *** [stap] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

So this would seem to indicate that the version of Systemtap used was using /lib/libpthread.so.0 without explicitly linking to it. The solution would be to simply ensure that in the configure.ac file, -lpthread is added where the libraries are specified.