Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Initialize default floating-point model on ARM for GNU binaries
@ 2006-07-17 22:50 Mark Kettenis
  2006-07-18 16:32 ` Richard Earnshaw
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2006-07-17 22:50 UTC (permalink / raw)
  To: rearnsha; +Cc: gdb-patches

Hi Richard,

Here's a patch to select the default floating-point model based on
flags set in the ELF header of binaries produced by the GNU toolchain.
It carefully avoids doing this for binaries conforming to the (new)
official EABI.  I removed the setting of the ABI for unrecognized EABI
versions.  These will default to ARM_ABI_ACPS anyway, later on.

With this patch, GDB correctly recognizes that OpenBSD/arm binaries
use the "sofvfp" floating-point model, which reduces the number of
testsuite failures considerably.

ok?

Mark

P.S. It seems the code to detect the correct floating-point model is
somewhat busted; arm-linux-tdep.c, armnbsd-tdep.c and now
armobsd-tdep.c contain code to set tdep->fp_model if it is still set
to ARM_FLOAT_AUTO, but that never seems to happen.


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* 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 17 Jul 2006 22:38:29 -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,29 @@ 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:
+		  fp_model = ARM_FLOAT_FPA;
+		  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;
 		}
 	    }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Initialize default floating-point model on ARM for GNU binaries
  2006-07-17 22:50 Initialize default floating-point model on ARM for GNU binaries Mark Kettenis
@ 2006-07-18 16:32 ` Richard Earnshaw
  2006-07-18 17:48   ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Earnshaw @ 2006-07-18 16:32 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Mon, 2006-07-17 at 23:50, Mark Kettenis wrote:
> Hi Richard,
> 
> Here's a patch to select the default floating-point model based on
> flags set in the ELF header of binaries produced by the GNU toolchain.
> It carefully avoids doing this for binaries conforming to the (new)
> official EABI.  I removed the setting of the ABI for unrecognized EABI
> versions.  These will default to ARM_ABI_ACPS anyway, later on.
> 
> With this patch, GDB correctly recognizes that OpenBSD/arm binaries
> use the "sofvfp" floating-point model, which reduces the number of
> testsuite failures considerably.
> 
> ok?
> 
> Mark
> 
> P.S. It seems the code to detect the correct floating-point model is
> somewhat busted; arm-linux-tdep.c, armnbsd-tdep.c and now
> armobsd-tdep.c contain code to set tdep->fp_model if it is still set
> to ARM_FLOAT_AUTO, but that never seems to happen.
> 
> 
> Index: ChangeLog
> from  Mark Kettenis  <kettenis@gnu.org>
> 
> 	* arm-tdep.c (arm_gdbarch_init): Get default floating-point model
> 	from ELF flags for binaries produced by the GNU toolchain.

I fear this isn't going to work; though not because of anything you've
done (in principle, I think your changes are fine).

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.

R.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Initialize default floating-point model on ARM for GNU binaries
  2006-07-18 16:32 ` Richard Earnshaw
@ 2006-07-18 17:48   ` Mark Kettenis
  2006-07-19  8:37     ` Richard Earnshaw
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Kettenis @ 2006-07-18 17:48 UTC (permalink / raw)
  To: rearnsha; +Cc: gdb-patches

> From: Richard Earnshaw <rearnsha@arm.com>
> 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  <kettenis@gnu.org>

	* 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;
 		}
 	    }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Initialize default floating-point model on ARM for GNU binaries
  2006-07-18 17:48   ` Mark Kettenis
@ 2006-07-19  8:37     ` Richard Earnshaw
  2006-07-19 20:37       ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Earnshaw @ 2006-07-19  8:37 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Tue, 2006-07-18 at 18:47, Mark Kettenis wrote:
> > From: Richard Earnshaw <rearnsha@arm.com>
> > 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  <kettenis@gnu.org>
> 
> 	* arm-tdep.c (arm_gdbarch_init): Get default floating-point model
> 	from ELF flags for binaries produced by the GNU toolchain.

Thanks, this is fine.

R.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Initialize default floating-point model on ARM for GNU binaries
  2006-07-19  8:37     ` Richard Earnshaw
@ 2006-07-19 20:37       ` Mark Kettenis
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Kettenis @ 2006-07-19 20:37 UTC (permalink / raw)
  To: rearnsha; +Cc: gdb-patches

> > Index: ChangeLog
> > from  Mark Kettenis  <kettenis@gnu.org>
> > 
> > 	* arm-tdep.c (arm_gdbarch_init): Get default floating-point model
> > 	from ELF flags for binaries produced by the GNU toolchain.
> 
> Thanks, this is fine.

Good, Committed


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-19 20:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-17 22:50 Initialize default floating-point model on ARM for GNU binaries Mark Kettenis
2006-07-18 16:32 ` Richard Earnshaw
2006-07-18 17:48   ` Mark Kettenis
2006-07-19  8:37     ` Richard Earnshaw
2006-07-19 20:37       ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox