From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24248 invoked by alias); 18 Jul 2006 17:48:22 -0000 Received: (qmail 24240 invoked by uid 22791); 18 Jul 2006 17:48:21 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 18 Jul 2006 17:48:19 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.4/8.13.4) with ESMTP id k6IHlrQ1029808; Tue, 18 Jul 2006 19:47:53 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6) with ESMTP id k6IHlrEV019986; Tue, 18 Jul 2006 19:47:53 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6/Submit) id k6IHlq4u030827; Tue, 18 Jul 2006 19:47:52 +0200 (CEST) Date: Tue, 18 Jul 2006 17:48:00 -0000 Message-Id: <200607181747.k6IHlq4u030827@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: rearnsha@arm.com CC: gdb-patches@sourceware.org In-reply-to: <1153240315.20443.52.camel@pc960.cambridge.arm.com> (message from Richard Earnshaw on Tue, 18 Jul 2006 17:31:56 +0100) Subject: Re: Initialize default floating-point model on ARM for GNU binaries References: <200607172250.k6HMoIN2009013@elgar.sibelius.xs4all.nl> <1153240315.20443.52.camel@pc960.cambridge.arm.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00235.txt.bz2 > From: Richard Earnshaw > Date: Tue, 18 Jul 2006 17:31:56 +0100 > > The problem is that in the most common configuration still using the > legacy ELF format (arm-unknown-elf) the flags are generated incorrectly > by the compiler/assembler combination. These tools fail to correctly > set the softfpa bit in the ELF header and the result is that gdb will > think they contain FPA instructions when they do not. Thus I think this > change will cause a large number of new failures on arm-elf. > > I guess we could fudge this by making the auto-detect code fold case 0 > on to case EF_ARM_SOFT_FLOAT, but it would need a big comment to explain > the background. That doesn't sound like a bad idea. Here's a patch with a variant of this: leave things set to "auto" if no flag is set. That way the code path for arm-unknown-elf will be very close to what it is right now, which will default to "softfpa" in the end. ok? Index: ChangeLog from Mark Kettenis * arm-tdep.c (arm_gdbarch_init): Get default floating-point model from ELF flags for binaries produced by the GNU toolchain. Index: arm-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/arm-tdep.c,v retrieving revision 1.211 diff -u -p -r1.211 arm-tdep.c --- arm-tdep.c 16 Jul 2006 10:33:25 -0000 1.211 +++ arm-tdep.c 18 Jul 2006 17:43:47 -0000 @@ -2594,7 +2594,7 @@ arm_gdbarch_init (struct gdbarch_info in if (arm_abi == ARM_ABI_AUTO && info.abfd != NULL) { - int ei_osabi; + int ei_osabi, e_flags; switch (bfd_get_flavour (info.abfd)) { @@ -2611,19 +2611,18 @@ arm_gdbarch_init (struct gdbarch_info in case bfd_target_elf_flavour: ei_osabi = elf_elfheader (info.abfd)->e_ident[EI_OSABI]; + e_flags = elf_elfheader (info.abfd)->e_flags; + if (ei_osabi == ELFOSABI_ARM) { /* GNU tools used to use this value, but do not for EABI - objects. There's nowhere to tag an EABI version anyway, - so assume APCS. */ + objects. There's nowhere to tag an EABI version + anyway, so assume APCS. */ arm_abi = ARM_ABI_APCS; } else if (ei_osabi == ELFOSABI_NONE) { - int e_flags, eabi_ver; - - e_flags = elf_elfheader (info.abfd)->e_flags; - eabi_ver = EF_ARM_EABI_VERSION (e_flags); + int eabi_ver = EF_ARM_EABI_VERSION (e_flags); switch (eabi_ver) { @@ -2640,8 +2639,32 @@ arm_gdbarch_init (struct gdbarch_info in break; default: + /* Leave it as "auto". */ warning (_("unknown ARM EABI version 0x%x"), eabi_ver); - arm_abi = ARM_ABI_APCS; + break; + } + } + + if (fp_model == ARM_FLOAT_AUTO) + { + int e_flags = elf_elfheader (info.abfd)->e_flags; + + switch (e_flags & (EF_ARM_SOFT_FLOAT | EF_ARM_VFP_FLOAT)) + { + case 0: + /* Leave it as "auto". Strictly speaking this case + means FPA, but almost nobody uses that now, and + many toolchains fail to set the appropriate bits + for the floating-point model they use. */ + break; + case EF_ARM_SOFT_FLOAT: + fp_model = ARM_FLOAT_SOFT_FPA; + break; + case EF_ARM_VFP_FLOAT: + fp_model = ARM_FLOAT_VFP; + break; + case EF_ARM_SOFT_FLOAT | EF_ARM_VFP_FLOAT: + fp_model = ARM_FLOAT_SOFT_VFP; break; } }