Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 13032

Summary: R_PPC_REL24 relocs are not allowed in ppc32 shared libs
Product: Gentoo Linux Reporter: Olaf Hering <gentoo>
Component: Current packagesAssignee: Jonathan Nall <nall>
Status: RESOLVED FIXED    
Severity: blocker CC: azarah, nall
Priority: High    
Version: unspecified   
Hardware: PPC   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Olaf Hering 2003-01-01 12:14:48 UTC
for i in `find  /opt/kde-3.1rc5/lib /usr/qt/3/lib  /usr/X11R6/lib/ /usr/lib/
-type f ` ; do objdump -R $i 2>/dev/null | grep -q R_PPC_REL24 && echo $i ; done
...
/opt/kde-3.1rc5/lib/kfmclient.so
/opt/kde-3.1rc5/lib/keditbookmarks.so
/opt/kde-3.1rc5/lib/libkonqsidebarplugin.so.0.0.0
/opt/kde-3.1rc5/lib/libkonq_sidebar_tree.so
/opt/kde-3.1rc5/lib/kdesktop.so
/usr/qt/3/lib/libqt-mt.so.3.1.0
/usr/lib/perl5/site_perl/5.6.1/powerpc-linux/auto/PDL/Slatec/Slatec.so


A shared lib must NEVER have a R_PPC_REL24 reloc in objdump -R output.
There is -fPIC missing somewhere.

I believe the libqt was linked against some static X lib:

006236ac R_PPC_REL24       XextCreateExtension
006238c4 R_PPC_REL24       XextCreateExtension
00623ad4 R_PPC_REL24       XextCreateExtension
00623cec R_PPC_REL24       XextCreateExtension
00623f04 R_PPC_REL24       XextCreateExtension
006240e4 R_PPC_REL24       XextCreateExtension
00624384 R_PPC_REL24       XextCreateExtension
0062448c R_PPC_REL24       XextCreateExtension
006236cc R_PPC_REL24       XextFindDisplay
006238e4 R_PPC_REL24       XextFindDisplay
00623af4 R_PPC_REL24       XextFindDisplay
00623d0c R_PPC_REL24       XextFindDisplay
00623f24 R_PPC_REL24       XextFindDisplay
00624104 R_PPC_REL24       XextFindDisplay
006243a4 R_PPC_REL24       XextFindDisplay
006244ac R_PPC_REL24       XextFindDisplay
006236fc R_PPC_REL24       XMissingExtension
00623914 R_PPC_REL24       XMissingExtension
00623b24 R_PPC_REL24       XMissingExtension
00623d3c R_PPC_REL24       XMissingExtension
00624138 R_PPC_REL24       XMissingExtension
006237a0 R_PPC_REL24       _XReply
006239b0 R_PPC_REL24       _XReply
00623bc0 R_PPC_REL24       _XReply
00623de0 R_PPC_REL24       _XReply
00623fb4 R_PPC_REL24       _XReply
006241d0 R_PPC_REL24       _XReply
00623840 R_PPC_REL24       _XFlush
00623a50 R_PPC_REL24       _XFlush
00623c60 R_PPC_REL24       _XFlush
00623e90 R_PPC_REL24       _XFlush
00624064 R_PPC_REL24       _XFlush
00624304 R_PPC_REL24       _XFlush
00623880 R_PPC_REL24       XextAddDisplay
00623a90 R_PPC_REL24       XextAddDisplay
00623ca0 R_PPC_REL24       XextAddDisplay
00623ed0 R_PPC_REL24       XextAddDisplay
006240a4 R_PPC_REL24       XextAddDisplay
00624344 R_PPC_REL24       XextAddDisplay
00624428 R_PPC_REL24       XextAddDisplay
00624530 R_PPC_REL24       XextAddDisplay
00624234 R_PPC_REL24       malloc
00624440 R_PPC_REL24       malloc
00624264 R_PPC_REL24       _XRead
006242f8 R_PPC_REL24       _XEatData
00624544 R_PPC_REL24       XPanoramiXQueryVersion
00624570 R_PPC_REL24       XextRemoveDisplay

....
 -L/usr/X11R6/lib -L/usr/X11R6/lib -ldl -lpthread -lmng -ljpeg -lpng -lz
-lpthread -lGL -lXmu -lSM -lICE -ldl -lXext -lX11 -lm -lXinerama -lXrender -lXft
-lfreetype  -lXi
....

XF4.3 has this missing -fPIC probably fixed, earlier versions need a hacked
makefile to rebuild the buggy shared libs with -fPIC before "make install"
Comment 1 Mark Guertin 2003-01-01 16:28:51 UTC
Thanks Olaf, will look into this stuff :) 
Comment 2 Olaf Hering 2003-01-02 06:37:51 UTC
a workaround that can be applied right away on 4.2 looks like that.
4.3pre does still need it, too. But it already has some infrastructure to pass
-fPIC depending on the arch, its just poorly used or buggy.


Index: config/cf/Library.tmpl
===================================================================
RCS file: /cvs/xc/config/cf/Library.tmpl,v
retrieving revision 3.20
diff -u -r3.20 Library.tmpl
--- config/cf/Library.tmpl      2002/11/25 14:04:47     3.20
+++ config/cf/Library.tmpl      2003/01/02 12:34:17
@@ -304,8 +304,8 @@
        _NormalLibMkdir()                                               @@\
        _ExtraLibMkdir()                                                @@\
                                                                        @@\
-_CompileObj(.c.Osuf:,$(_NOOP_))                                                @@\
-_CompileObjCplusplus(.SRCsuf.Osuf:,$(_NOOP_))                          @@\
+_CompileObj(.c.Osuf:,$(PICFLAGS))                                      @@\
+_CompileObjCplusplus(.SRCsuf.Osuf:,$(CXXPICFLAGS))                     @@\
                                                                        @@\
 clean::                                                                        @@\
        _DebuggedCleanDir()                                             @@\
Comment 3 Mark Guertin 2003-01-02 10:50:56 UTC
Ahh yep thanks.  This is fixed up in the xfree-4.2.1-r2 ebuild, but is still not
set to ppc 'stable' yet (working on some strange keycode issue with it still)

Once 4.2.1-r2 makes stable I will close this

Thanks again Olaf
Comment 4 Olaf Hering 2003-01-03 11:41:37 UTC
the patch posted above doesnt solve much, this one works better for the time being:

--- xfree-4.2.1-r2.ebuild       2002-12-30 18:23:06.000000000 +0100
+++ xfree-4.2.1-r3.ebuild       2003-01-03 16:11:34.000000000 +0100
@@ -302,6 +302,21 @@
        einfo "Building XFree86..."
        emake World || die
 
+       cd lib
+       my_NOFPIC_LIBS=$((find * -name "*.a" | grep -v module ; find * -name
unshared -type d ) | xargs -n1 dirname | sort -u)
+       echo "possible libs without -fPIC: $my_NOFPIC_LIBS"
+       for i in $my_NOFPIC_LIBS lbxutil/{delta,image,lbx_zlib}; do
+       oPWD=$PWD
+       cd $i
+       pwd
+       rm -fv *.o unshared/*.o
+       cp -av Makefile Makefile.without.fPIC
+       sed 's#\(-fsigned-char\|-pipe\)#& -fPIC#' < Makefile > Makefile.fPIC
+       mv -v Makefile.fPIC Makefile
+       cd $oPWD
+       done
+       make
+
        if [ -n "`use nls`" ]
        then
                cd ${S}/nls


there are alot more libs without fPIC:


for i in $(find /gentoo/usr/ -type f -name "*.a"  | grep -vw modules) ; do
objdump -r $i | grep -qw R_PPC_REL24 && echo $i ; done | sort | o -S
Comment 5 Mark Guertin 2003-01-03 13:07:29 UTC
Olaf: I'm passing this one off to nall as he is much more knowledgable on this
than I am
Comment 6 Olaf Hering 2003-01-03 17:59:03 UTC
it is incorrect to check the .a files for R_PPC_REL24 relocs.

But there should be a post-build check for .so files, like that:

find $BUILD_ROOT -type f -name "*.*so" | xargs -n1 objdump -R | grep -wq
R_PPC_REL24 && exit 1

You can run that one to check how many libs miss -fPIC:

for i in `find /lib/ /usr/lib/ /usr/X11R6/lib/ /usr/kde /usr/qt -name "*.*so*"
-type f` ; do objdump -R $i 2>/dev/null | grep -wq R_PPC_REL24 && echo $i ; done

/usr/lib/perl5/site_perl/5.6.1/powerpc-linux/auto/PDL/Slatec/Slatec.so
/usr/qt/3/lib/libqt-mt.so.3.1.0
/usr/qt/3/plugins/designer/libcppeditor.so
Comment 7 Mark Guertin 2003-01-05 01:05:20 UTC
Ahh ok.  That was the sme info we found as well, was just applicable for .so 
files.  
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2003-01-05 08:09:56 UTC
Err, ok, what is the status on this ?  Is -fPIC patches in -r2 not sufficient
enouth ?  Did you recompile QT after xfree, as it will be needed (if I remember
correctly, it link to the static version of xinerama lib, but ask Cretin about
this ...)?
Comment 9 Olaf Hering 2003-01-05 08:47:31 UTC
4.2-r2 has a libXinerama.a without -fPIC
4.3pre has it with -fPIC

I did recompile qt after building all .a files with -fPIC and a selfcompiled KDE
3.1rc6 does not fail with reloc errors.
It would be the best to compile only the really needed .a files with -fPIC,
libXinerama.a is an candidate for that. I do not see any patch to build
libXinerama.a with -fPIC.

I have only a few packages compiled, are there other .so files that do still
have these R_PPC_REL24 relocs?

I have 2 left (but they do not cause problems for me):
/usr/lib/perl5/site_perl/5.6.1/powerpc-linux/auto/PDL/Slatec/Slatec.so
/usr/qt/3/plugins/designer/libcppeditor.so

libcppeditor.so is linked static with /usr/qt/3/lib/libeditor.a
this smells like a qt bug.

Slatec.so comes from FORTRAN sources:
/var/tmp/portage/PDL-2.3.2-r2/work/PDL-2.3.2/Lib/Slatec
g77 -c -o slatec/xgetua.o -O slatec/xgetua.f
Comment 10 Martin Schlemmer (RETIRED) gentoo-dev 2003-01-07 12:16:15 UTC
Ill see if I can backport the Imakefile fixes from 4.3 to 4.2.1 as soon as I
get the time.
Comment 11 Mark Guertin 2003-01-14 10:55:38 UTC
Olaf:

I've built a little tool to test pacakges for this, and from what I can see the
other 2 small ones that don't cause problems are the only other two that are
currently around, and I have a large amount of pkgs tested now.

There is an upcoming xfree-4.2.1-r3 ebuild that should have most of this stuff
fixed up.

Also kde-3.1_rc6 did have some other problems wrt this stuff (even compiled
against a good xfree).  Did some sanity checking before trying to prelink and
noticed these problems.

We're working on things though :)  Thanks for your time on this stuff again
Comment 12 Jonathan Nall 2003-01-14 11:25:48 UTC
i have a local portage that will perform ARCH-specific tests on an install area
before merging it. if it finds errors (such as this), it will throw an error and
tell the user to file a bug here. i'll file a bug against portage to get this
functionality.
Comment 13 Jonathan Nall 2003-02-03 16:50:06 UTC
this is fixed in CVS.

thanks so much for the info on this, olaf. we're integrating this into our QA testing.