This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PowerPC32 .gnu.attributes in crt files


Since gcc-4.3.0, powerpc32 gcc has emitted object files with a
.gnu.attributes section that specifies whether hard or soft-float was
chosen when compiling, and whether the Alitivec ABI was in force.
Later versions of gcc extended these attributes, and added another to
specify the struct return ABI.  GNU ld warns if you try to link object
files with incompatible attributes.  This all sounds good, but the
scheme has a weakness:  The attributes are set based entirely on
compiler flags rather than whether the particular ABI incompatibility
occurs.  For example, the soft float / hard double / hard single
attribute will be on files that use no floating point at all.  gcc
doesn't provide an option to turn off the attributes.

This unfortunately results in crt1.o, crti.o etc. being marked as
incompatible with soft float;  The linker warns when building any
soft float binary, and because crt1.o is usually the first file
linked, builds the binary with an incorrect attribute.  Up until now,
I'd fixed my own system by simply stripping the attribute section from
/usr/lib/*crt*.o, but a system update reminded me that I should really
fix this upstream.

2011-02-18  Alan Modra  <amodra@gmail.com>

	* sysdeps/powerpc/powerpc32/Makefile (csu subdir): Arrange to
	strip .gnu.attributes section from objects.

diff --git a/sysdeps/powerpc/powerpc32/Makefile b/sysdeps/powerpc/powerpc32/Makefile
index 1d58a06..c1f33fc 100644
--- a/sysdeps/powerpc/powerpc32/Makefile
+++ b/sysdeps/powerpc/powerpc32/Makefile
@@ -27,6 +27,21 @@ CFLAGS-initfini.s += -fpic -O1
 # of the library should be able to control what goes into sdata.
 CFLAGS-init.o = -G0
 CFLAGS-gmon-start.o = -G0
+
+# crt1.o, crti.o, crtn.o and similar files are used when building -msoft-float
+# binaries as well hardware floating point binaries.  gcc always emits
+# a .gnu.attributes section, marking the startup files as hard-float.
+# This results in linker warnings when building soft-float binaries.
+# The crt files really are compatible with both hard and soft-float,
+# and similarly for the other .gnu.attributes.
+postclean-generated += stamp-attr
+subdir_lib: $(objpfx)stamp-attr
+$(objpfx)stamp-attr: $(extra-objs:%=$(objpfx)%)
+	for x in $?; do \
+	    objcopy -R .gnu.attributes $$x; \
+	done
+	touch $@
+
 endif
 ifeq (yes,$(build-shared))
 # Compatibility

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]