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]

[PATCH 1/2] glibc-ports: Use /lib/ld-linux-armhf.so.3 as the dynamiclinker for the ARM hard-float ABI.


The dynamic linker name should be /lib/ld-linux-armhf.so.3 when
compiling glibc with a compiler and flags that would cause the ARM
hard-float ABI to be selected. The following patch implements the
selection of the correct dynamic linker name for ARM given the new
alternate name for the hard-float ABI.

The compiler defines __ARM_PCS_VFP when the hard-float ABI is being
used. The sysdeps/arm/configure.in check sets HAVE_ARM_PCS_VFP when it
detects that the compiler *and* flags would select the hard-float ABI.
The shlib-versions file then uses %ifdef HAVE_ARM_PCS_VFP to select
the alternate dynamic linker; we can do this because shlib-versions is
handled by the implicit rule which uses -include to include
include/libc-symbols.h which in turn includes config.h. The file
shlib-versions is run through sed to convert the %ifdef into #ifdef,
and cpp does the final processing.

Interestingly the patch *could* have been a one-line change to add
%ifdef __ARM_PCS_VFP, but this is not possible since the implicit rule
that runs cpp also adds -undef which removes all of the compiler
builtin defines. Trying to remove the -undef is difficult because the
implicit rule is used in contexts where the compiler builtin defines
should not be present. Adding a new implicit rule in the makefile just
for shlib-versions processing was, in my opinion, less clear than this
current patch.

This patch is significantly better than original WIP patch which added
an additional sysdep directory with an alternate shlib-versions file.
By adding an alternate directory you must also mirror the structure of
all the sub-machine (armv7 and armv6t2) directories and include
Implies to add them back into the build.

Tested by building a multilib'd compiler and compiling glibc for at
least the soft-float (armv5te) and hard-float (armv7-a) cases, and
verifying that glibc installs the correct dynamic loader in each case.

Testing requires a recent gcc with Michael Hope and Richard Earnshaw's
final patches to default to the original soft-float loader or select
the new hard-float loader if -mfloat-abi=hard is used (see
http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01335.html).

I additionally tested some compatibility cases where an old toolchain
was used to build an application and run it against the new sysroot
with a compat symlink e.g. ld-linux.so.3 -> ld-2.xx.so and
ld-linux-armhf.so.3 -> ld-2.xx.so, and everything worked as expected.

OK to commit?

2012-05-06  Carlos O'Donell  <carlos_odonell@mentor.com>
	    Khem Raj <raj.khem@gmail.com>

	* sysdeps/arm/configure.in: Set libc_cv_arm_pcs_vfp.
	If libc_cv_arm_pcs_vfp equals yes then define HAVE_ARM_PCS_VFP.
	* sysdeps/arm/configure: Regenerate.
	* sysdeps/arm/shlib-versions: If HAVE_ARM_PCS_VFP is defined
	then use ld=/lib/ld-linux-armhf.so.3.

diff --git a/sysdeps/arm/configure.in b/sysdeps/arm/configure.in
index 706add2..60d4093 100644
--- a/sysdeps/arm/configure.in
+++ b/sysdeps/arm/configure.in
@@ -49,3 +49,28 @@ EOF
 if test $libc_cv_asm_cfi_directive_sections != yes; then
   AC_MSG_ERROR([need .cfi_sections in this configuration])
 fi
+
+AC_CACHE_CHECK([whether the compiler is using the ARM hard-float ABI],
+  [libc_cv_arm_pcs_vfp],
+  [archcppflag=`echo "" |
+       $CC $CFLAGS $CPPFLAGS -E -dM - |
+       grep __ARM_PCS_VFP |
+       sed -e 's/^#define //' -e 's/ .*//'`
+  # We check to see if the compiler and flags are
+  # selecting the hard-float ABI and if they are then
+  # we set libc_cv_arm_pcs_vfp to yes which causes
+  # HAVE_ARM_PCS_VFP to be defined in config.h and
+  # in include/libc-symbols.h and thus availabile to
+  # shlib-versions to select the appropriate name for
+  # the dynamic linker via %ifdef.
+  case x$archcppflag in
+  x__ARM_PCS_VFP)
+    libc_cv_arm_pcs_vfp=yes
+    ;;
+  *)
+    libc_cv_arm_pcs_vfp=no
+    ;;
+  esac])
+if test $libc_cv_arm_pcs_vfp = yes; then
+  AC_DEFINE(HAVE_ARM_PCS_VFP)
+fi
diff --git a/sysdeps/arm/shlib-versions b/sysdeps/arm/shlib-versions
index 626d58b..d500166 100644
--- a/sysdeps/arm/shlib-versions
+++ b/sysdeps/arm/shlib-versions
@@ -1,3 +1,9 @@
 arm.*-.*-linux-gnueabi.*       DEFAULT                 GLIBC_2.4

+%ifdef HAVE_ARM_PCS_VFP
+# The EABI-derived hard-float ABI uses a new dynamic linker.
+arm.*-.*-linux-gnueabi.*       ld=ld-linux-armhf.so.3
+%else
+# The EABI-derived soft-float ABI continues to use ld-linux.so.3.
 arm.*-.*-linux-gnueabi.*       ld=ld-linux.so.3
+%endif
===

Note:
- Updated "Regeneration" with instructions on regenerating the
configure fragment for ports machines.
http://sourceware.org/glibc/wiki/Regeneration

Cheers,
Carlos.


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