This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports 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]

Re: ARM hard-float ABI: add ldconfig flag value


On Fri, Aug 03, 2012 at 05:45:26PM +0100, Steve McIntyre wrote:
>Hi Roland,
>
>On Thu, Aug 02, 2012 at 11:26:02AM -0700, Roland McGrath wrote:
>>> >That may have been the original intent of the ELF spec.  But on GNU systems
>>> >this field has been coopted for purposes that are specific only to the GNU
>>> >dynamic linker (and linker), not to any machine or operating system.
>>> 
>>> Can you point me at any docs or code for that, please? 
>>
>>Search around for ELFOSABI_GNU (previously called ELFOSABI_LINUX)
>>in libc and binutils.
>
>Thanks for that.
>
>Right, I see the ifunc stuff. I'm a little surprised to see this field
>being appropriated in this way, but OK... I understand it's not going
>to fly with any other uses. I'm looking into adding some extra flags
>for e_flags instead.

Hi again,

How about the following patch? I've discussed this approach with the
ARM ABI folks and they're happy to go with it, I hope you are
too. Rather than use up any more of the e_flags flag space, I'm
proposing to re-use some of the older flags as Roland suggested. The
old flags

#define EF_ARM_SOFT_FLOAT       0x200
#define EF_ARM_VFP_FLOAT        0x400

are only valid for really old versions of the ARM ABI, so for EABI v5
(the current ABI) I'm proposing to add new names for the same values:

#define EF_ARM_EABI_FLOAT_SOFT  0x200
#define EF_ARM_EABI_FLOAT_HARD  0x400

which will specifically only be used with that ABI version.

With a similar patch to binutils to generate the new flags when
desired, the following code makes ld.so DTRT for me: rejecting new
binaries with the wrong ABI flag but accepting either new binaries
with the right ABI flag and older binaries that have neither flag set.

Assuming this code is acceptable, I'll next submit a patch for
ldconfig to also use the new flags for distinguishing ABIs when adding
libraries to ld.so.cache, using FLAG_ARM_HFABI as previously posted.

diff --git a/elf/elf.h b/elf/elf.h
index 71cfdb8..d143447 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -2250,6 +2250,9 @@ typedef Elf32_Addr Elf32_Conflict;
 #define EF_ARM_VFP_FLOAT       0x400
 #define EF_ARM_MAVERICK_FLOAT  0x800
 
+#define EF_ARM_EABI_FLOAT_SOFT  0x200   /* NB conflicts with EF_ARM_SOFT_FLOAT.  */
+#define EF_ARM_EABI_FLOAT_HARD  0x400   /* NB conflicts with EF_ARM_VFP_FLOAT.  */
+
 
 /* Other constants defined in the ARM ELF spec. version B-01.  */
 /* NB. These conflict with values defined above.  */
diff --git a/ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h b/ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h
index 8980bb1..adb99ac 100644
--- a/ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h
+++ b/ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h
@@ -27,10 +27,22 @@
 
 #define EXTRA_OSABI ELFOSABI_ARM_AEABI
 
+#ifdef __ARM_PCS_VFP
+#define VALID_FLOAT_ABI(x) \
+  ((EF_ARM_EABI_VERSION((x)) != EF_ARM_EABI_VER5)      \
+   || ! ((x) & EF_ARM_EABI_FLOAT_SOFT))
+#else
+#define VALID_FLOAT_ABI(x) \
+  ((EF_ARM_EABI_VERSION((x)) != EF_ARM_EABI_VER5)      \
+   || ! ((x) & EF_ARM_EABI_FLOAT_HARD))
+#endif
+
+#undef VALID_ELF_HEADER
 #define VALID_ELF_HEADER(hdr,exp,size)         \
-  (memcmp (hdr, exp, size) == 0                \
+  ((memcmp (hdr, exp, size) == 0               \
    || memcmp (hdr, expected2, size) == 0       \
-   || memcmp (hdr, expected3, size) == 0)
+    || memcmp (hdr, expected3, size) == 0)     \
+   && VALID_FLOAT_ABI(ehdr->e_flags))
 #define VALID_ELF_OSABI(osabi)         (osabi == ELFOSABI_SYSV         \
                                         || osabi == EXTRA_OSABI        \
                                         || osabi == ELFOSABI_LINUX)

Cheers,
-- 
Steve McIntyre                                steve.mcintyre@linaro.org
<http://www.linaro.org/> Linaro.org | Open source software for ARM SoCs


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