From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29836 invoked by alias); 8 Aug 2012 13:41:21 -0000 Received: (qmail 29822 invoked by uid 22791); 8 Aug 2012 13:41:19 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from cheddar.halon.org.uk (HELO cheddar.halon.org.uk) (217.10.144.130) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Aug 2012 13:41:05 +0000 Received: from bsmtp by cheddar.halon.org.uk with local-bsmtp (Exim 4.72) (envelope-from ) id 1Sz6VS-0007mO-A7; Wed, 08 Aug 2012 14:41:02 +0100 Received: from stemci01 by e102122-lin with local (Exim 4.76) (envelope-from ) id 1Sz6Ue-0004pm-FP; Wed, 08 Aug 2012 14:40:12 +0100 Date: Wed, 08 Aug 2012 13:41:00 -0000 From: Steve McIntyre To: Roland McGrath Cc: libc-alpha@sourceware.org, libc-ports@sourceware.org Subject: Re: ARM hard-float ABI: add ldconfig flag value Message-ID: <20120808134012.GA25789@linaro.org> References: <20120727160941.GA13597@linaro.org> <20120802165658.GG24537@linaro.org> <20120802172843.AC5092C0DF@topped-with-meat.com> <20120802174900.GH24537@linaro.org> <20120802175430.CF1652C0DF@topped-with-meat.com> <20120802181352.GJ24537@linaro.org> <20120802182602.77E082C0A8@topped-with-meat.com> <20120803164526.GO24537@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120803164526.GO24537@linaro.org> X-attached: none User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00045.txt.bz2 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 Linaro.org | Open source software for ARM SoCs