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]

Ping - PATCH v2: add mach-o handling in is32bit


Ping.

On Nov 7, 2008, at 11:23 AM, Tristan Gingold wrote:

Hi,

here is the new version of the patch, using BFD_VMA64 flag.
Currently only mach-o uses it but I plan to convert more targets.

Tested on macosX.

Tristan.

On Nov 6, 2008, at 4:56 PM, Nick Clifton wrote:
I think that I prefer a flag. It would be good to avoid adding target specific code to a supposedly generic file like bfd.c.

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

	* bfd.c: Add BFD_VMA64 flag.
	(is32bit): Return 0 if BFD_VMA64 flag is set.
	* bfd-in2.h: Regenerate.
	* mach-o.c (bfd_mach_o_scan): Set BFD_VMA64 if object file is 64bits.
	(bfd_mach_o_object_p): Do not recognize 64bits files unless BFD64 is
	defined.

*** bfd/bfd.c 17 Aug 2008 03:12:49 -0000 1.104
--- bfd/bfd.c 7 Nov 2008 10:15:16 -0000
*************** CODE_FRAGMENT
*** 145,150 ****
--- 145,154 ----
. to any input file. *}
.#define BFD_LINKER_CREATED 0x2000
.
+ . {* Target is 64 bits. This is used to display the right number of
+ . characters for an address. *}
+ .#define BFD_VMA64 0x4000
+ .
. {* Currently my_archive is tested before adding origin to
. anything. I believe that this can become always an add of
. origin, with origin set to 0 for non archive files. *}
*************** bfd_record_phdr (bfd *abfd,
*** 1466,1478 ****
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);
}
--- 1474,1489 ----
static bfd_boolean
is32bit (bfd *abfd)
{
+ if (bfd_get_file_flags (abfd) & BFD_VMA64)
+ return 0;
+
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 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);
 }
Index: bfd/mach-o.c
===================================================================
RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.30
diff -c -p -r1.30 mach-o.c
*** bfd/mach-o.c	6 Nov 2008 13:03:43 -0000	1.30
--- bfd/mach-o.c	7 Nov 2008 10:15:17 -0000
*************** bfd_mach_o_scan (bfd *abfd,
*** 1856,1862 ****
   mdata->header = *header;
   mdata->symbols = NULL;

!   abfd->flags = abfd->flags & (BFD_IN_MEMORY | BFD_IO_FUNCS);
   switch (header->filetype)
     {
     case BFD_MACH_O_MH_OBJECT:
--- 1856,1862 ----
   mdata->header = *header;
   mdata->symbols = NULL;

!   abfd->flags &= BFD_IN_MEMORY | BFD_IO_FUNCS;
   switch (header->filetype)
     {
     case BFD_MACH_O_MH_OBJECT:
*************** bfd_mach_o_scan (bfd *abfd,
*** 1871,1876 ****
--- 1871,1879 ----
       break;
     }

+   if (header->version == 2)
+     abfd->flags |= BFD_VMA64;
+
   abfd->tdata.mach_o_data = mdata;

bfd_mach_o_convert_architecture (header->cputype, header- >cpusubtype,
*************** bfd_mach_o_object_p (bfd *abfd)
*** 1968,1973 ****
--- 1971,1982 ----
&& abfd->xvec->header_byteorder == BFD_ENDIAN_LITTLE)))
goto wrong;


+ /* Do not recognize 64 bits files unless BFD64. */
+ #ifndef BFD64
+ if (header.version == 2)
+ goto wrong;
+ #endif
+
preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
if (preserve.marker == NULL
|| !bfd_preserve_save (abfd, &preserve))




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