gcc does not use the pic version libiberty.a if built

Peter S. Mazinger ps.m@gmx.net
Tue Nov 9 08:53:00 GMT 2004


Hello!

gcc builds 2 versions of libiberty.a, one w/ pic and one w/o, but uses 
only the non-pic version later for the intermediate execs (gen*)
On a system, that supports text relocations, but text relocation is 
not allowed due to restrictions in libc or kernel these binaries will all 
fail if built as PIE (the binaries end up w/ text relocations)

The same can also be observed in binutils and RedHat "circumvents" this, 
by rebuilding libiberty.a a second time separately by adding -fPIC to 
CFLAGS (because this libiberty.a is used system-wide, and not the one 
provided by gcc)

The attached patch solves the problem by overwriting the non-pic version 
w/ the pic version, if the pic version is built.

Index: libiberty/ChangeLog

from Peter S. Mazinger <ps.m@gmx.net>

	* if pic version of libiberty.a is built, make also use of it

Peter

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2
-------------- next part --------------
--- libiberty/Makefile.in.mps	2004-05-13 15:53:17.000000000 +0200
+++ libiberty/Makefile.in	2004-05-13 15:52:53.000000000 +0200
@@ -224,6 +224,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA
 	  $(AR) $(AR_FLAGS) $(TARGETLIB) \
 	    $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
 	  $(RANLIB) $(TARGETLIB); \
+	  cp $(TARGETLIB) ../ ; \
 	  cd ..; \
 	else true; fi
 


More information about the Gcc-patches mailing list