This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: add mach-o handling in is32bit


Hi,

the current implementation of bfd.c(is32bit) is a little bit kludgy and this patch
won't improve the situation...


bfd.c:is32bit is required to correctly display 64bits vma and the mach- o target supports
both 32 bits and 64 bits files so we can't guess on target name.


An other possibility is to create a new flag for the bfd structure: BFD_VMA64.
Tell me if the patch is good as is or if you prefer to have a flag (or another way).


(Tested on macosx and x86_64 gnu/linux)

Tristan.

bfd/
2008-11-06  Tristan Gingold  <gingold@adacore.com>

* bfd.c (is32bit): Add a test for mach-o flavour.


*** bfd.c 17 Aug 2008 03:12:49 -0000 1.104 --- bfd.c 6 Nov 2008 13:32:48 -0000 *************** *** 297,302 **** --- 297,303 ---- #include "libecoff.h" #undef obj_symbols #include "elf-bfd.h" + #include "mach-o.h"

#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
***************
*** 1466,1480 ****
static bfd_boolean
is32bit (bfd *abfd)
{
! if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
{
! const struct elf_backend_data *bed = get_elf_backend_data (abfd);
! return bed->s->elfclass == ELFCLASS32;
}
-
- /* For non-ELF, make a guess based on the target name. */
- return (strstr (bfd_get_target (abfd), "64") == NULL
- && strcmp (bfd_get_target (abfd), "mmo") != 0);
}
#endif


--- 1467,1491 ----
  static bfd_boolean
  is32bit (bfd *abfd)
  {
!   switch (bfd_get_flavour (abfd))
      {
!     case bfd_target_elf_flavour:
!       {
! 	const struct elf_backend_data *bed = get_elf_backend_data (abfd);
! 	return bed->s->elfclass == ELFCLASS32;
!       }
!       break;
!     case bfd_target_mach_o_flavour:
!       {
! 	const struct mach_o_data_struct *data = bfd_get_mach_o_data (abfd);
! 	return (data->header.cputype & BFD_MACH_O_CPU_IS64BIT) == 0;
!       }
!       break;
!     default:
!       /* For other targets, make a guess based on the target name.  */
!       return (strstr (bfd_get_target (abfd), "64") == NULL
! 	      && strcmp (bfd_get_target (abfd), "mmo") != 0);
      }
  }
  #endif





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