From Fedora Project Wiki

(Blanked the page)
Line 1: Line 1:
== Simpler Concrete Example Of DSO Linking Change in ld ==


I checked out a 'devel' version of deltarpm from :
<code>:pserver:anonymous@cvs.fedproject.org:/cvs/pkgs</code>
and ran 'make srpm' to 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: rpmdumpheader.o: undefined reference to symbol 'Fopen''''
'''/usr/bin/ld.bfd: note: 'Fopen' is defined in DSO /usr/lib/librpmio.so.0 so try adding it to the linker command line'''
'''/usr/lib/librpmio.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 -o rpmdumpheader
/usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crt1.o /usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crti.o /usr/lib/gcc/i686-redhat-linux/4.4.2/crtbegin.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/../../.. rpmdumpheader.o -lrpm -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-redhat-linux/4.4.2/crtend.o
/usr/lib/gcc/i686-redhat-linux/4.4.2/../../../crtn.o
collect2: ld returned 1 exit status
make: *** [rpmdumpheader] Error 1
So this would seem to indicate that the version of deltarpm used was using /usr/lib/librpmio.so.0 without explicitly linking to it. The solution would be to simply ensure that any binaries that use librpmio.so, have a -lrpmio added when linking is happening.
Making the following change to the Makefile fixes this problem :
rpmdumpheader: rpmdumpheader.o
-      $(CC) $(LDFLAGS) $^ -lrpm -o $@
'''+      $(CC) $(LDFLAGS) $^ -lrpm -lrpmio -o $@'''

Revision as of 02:05, 16 August 2011