2010-01-11 Tristan Gingold <gingold@adacore.com>

* mach-o.h (bfd_mach_o_backend_data): Add arch field.
	(bfd_mach_o_set_arch_mach): New prototype.
	* mach-o.c (bfd_mach_o_mkobject): Define with bfd_mach_o_gen_mkobject.
	(bfd_mach_o_set_arch_mach): New function.
	(bfd_mach_o_gen_mkobject): New function.
	Set TARGET_ARCHITECTURE for the generic back-ends.
	* mach-o-target.c (bfd_mach_o_set_arch_mach): Remove define.
	Check that TARGET_ARCHITECTURE is defined.
	Add TARGET_ARCHITECTURE in TARGET_NAME_BACKEND structure.
	* mach-o-i386.c (TARGET_ARCHITECTURE): Define.
This commit is contained in:
Tristan Gingold 2010-01-11 15:39:41 +00:00
parent cba0723b0f
commit 42fa08916b
5 changed files with 64 additions and 2 deletions

View File

@ -1,3 +1,16 @@
2010-01-11 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_backend_data): Add arch field.
(bfd_mach_o_set_arch_mach): New prototype.
* mach-o.c (bfd_mach_o_mkobject): Define with bfd_mach_o_gen_mkobject.
(bfd_mach_o_set_arch_mach): New function.
(bfd_mach_o_gen_mkobject): New function.
Set TARGET_ARCHITECTURE for the generic back-ends.
* mach-o-target.c (bfd_mach_o_set_arch_mach): Remove define.
Check that TARGET_ARCHITECTURE is defined.
Add TARGET_ARCHITECTURE in TARGET_NAME_BACKEND structure.
* mach-o-i386.c (TARGET_ARCHITECTURE): Define.
2010-01-11 Tristan Gingold <gingold@adacore.com>
* archive.c (bfd_slurp_armap): Also check for Mach-O sorted armap.

View File

@ -288,6 +288,7 @@ bfd_mach_o_i386_print_thread (bfd *abfd, bfd_mach_o_thread_flavour *thread,
#define TARGET_NAME mach_o_i386_vec
#define TARGET_STRING "mach-o-i386"
#define TARGET_ARCHITECTURE bfd_arch_i386
#define TARGET_BIG_ENDIAN 0
#define TARGET_ARCHIVE 0
#include "mach-o-target.c"

View File

@ -57,7 +57,6 @@
_bfd_generic_copy_link_hash_symbol_type
#define bfd_mach_o_bfd_final_link _bfd_generic_final_link
#define bfd_mach_o_bfd_link_split_section _bfd_generic_link_split_section
#define bfd_mach_o_set_arch_mach bfd_default_set_arch_mach
#define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define bfd_mach_o_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
#define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents
@ -85,6 +84,10 @@
#error TARGET_STRING must be defined
#endif /* TARGET_STRING */
#ifndef TARGET_ARCHITECTURE
#error TARGET_ARCHITECTURE must be defined
#endif /* TARGET_ARCHITECTURE */
#ifndef TARGET_BIG_ENDIAN
#error TARGET_BIG_ENDIAN must be defined
#endif /* TARGET_BIG_ENDIAN */
@ -99,6 +102,7 @@
static const bfd_mach_o_backend_data TARGET_NAME_BACKEND =
{
TARGET_ARCHITECTURE,
bfd_mach_o_swap_reloc_in,
bfd_mach_o_swap_reloc_out,
bfd_mach_o_print_thread

View File

@ -29,7 +29,7 @@
#define bfd_mach_o_object_p bfd_mach_o_gen_object_p
#define bfd_mach_o_core_p bfd_mach_o_gen_core_p
#define bfd_mach_o_mkobject bfd_false
#define bfd_mach_o_mkobject bfd_mach_o_gen_mkobject
#define FILE_ALIGN(off, algn) \
(((off) + ((file_ptr) 1 << (algn)) - 1) & ((file_ptr) -1 << (algn)))
@ -2672,6 +2672,23 @@ bfd_mach_o_scan_start_address (bfd *abfd)
return 0;
}
bfd_boolean
bfd_mach_o_set_arch_mach (bfd *abfd,
enum bfd_architecture arch,
unsigned long machine)
{
bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
/* If this isn't the right architecture for this backend, and this
isn't the generic backend, fail. */
if (arch != bed->arch
&& arch != bfd_arch_unknown
&& bed->arch != bfd_arch_unknown)
return FALSE;
return bfd_default_set_arch_mach (abfd, arch, machine);
}
int
bfd_mach_o_scan (bfd *abfd,
bfd_mach_o_header *header,
@ -2771,6 +2788,24 @@ bfd_mach_o_mkobject_init (bfd *abfd)
return TRUE;
}
static bfd_boolean
bfd_mach_o_gen_mkobject (bfd *abfd)
{
bfd_mach_o_data_struct *mdata;
if (!bfd_mach_o_mkobject_init (abfd))
return FALSE;
mdata = bfd_mach_o_get_data (abfd);
mdata->header.magic = BFD_MACH_O_MH_MAGIC;
mdata->header.cputype = 0;
mdata->header.cpusubtype = 0;
mdata->header.byteorder = abfd->xvec->byteorder;
mdata->header.version = 1;
return TRUE;
}
const bfd_target *
bfd_mach_o_header_p (bfd *abfd,
bfd_mach_o_filetype filetype,
@ -3960,17 +3995,20 @@ bfd_mach_o_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
#define TARGET_NAME mach_o_be_vec
#define TARGET_STRING "mach-o-be"
#define TARGET_ARCHITECTURE bfd_arch_unknown
#define TARGET_BIG_ENDIAN 1
#define TARGET_ARCHIVE 0
#include "mach-o-target.c"
#undef TARGET_NAME
#undef TARGET_STRING
#undef TARGET_ARCHITECTURE
#undef TARGET_BIG_ENDIAN
#undef TARGET_ARCHIVE
#define TARGET_NAME mach_o_le_vec
#define TARGET_STRING "mach-o-le"
#define TARGET_ARCHITECTURE bfd_arch_unknown
#define TARGET_BIG_ENDIAN 0
#define TARGET_ARCHIVE 0
@ -3978,11 +4016,13 @@ bfd_mach_o_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
#undef TARGET_NAME
#undef TARGET_STRING
#undef TARGET_ARCHITECTURE
#undef TARGET_BIG_ENDIAN
#undef TARGET_ARCHIVE
#define TARGET_NAME mach_o_fat_vec
#define TARGET_STRING "mach-o-fat"
#define TARGET_ARCHITECTURE bfd_arch_unknown
#define TARGET_BIG_ENDIAN 1
#define TARGET_ARCHIVE 1
@ -3990,5 +4030,6 @@ bfd_mach_o_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
#undef TARGET_NAME
#undef TARGET_STRING
#undef TARGET_ARCHITECTURE
#undef TARGET_BIG_ENDIAN
#undef TARGET_ARCHIVE

View File

@ -845,6 +845,7 @@ bfd_mach_o_data_struct;
/* Target specific routines. */
typedef struct bfd_mach_o_backend_data
{
enum bfd_architecture arch;
bfd_boolean (*_bfd_mach_o_swap_reloc_in)(arelent *, bfd_mach_o_reloc_info *);
bfd_boolean (*_bfd_mach_o_swap_reloc_out)(arelent *, bfd_mach_o_reloc_info *);
bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *,
@ -865,6 +866,8 @@ const bfd_target *bfd_mach_o_object_p (bfd *);
const bfd_target *bfd_mach_o_core_p (bfd *);
const bfd_target *bfd_mach_o_archive_p (bfd *);
bfd *bfd_mach_o_openr_next_archived_file (bfd *, bfd *);
bfd_boolean bfd_mach_o_set_arch_mach (bfd *, enum bfd_architecture,
unsigned long);
int bfd_mach_o_lookup_section (bfd *, asection *, bfd_mach_o_load_command **, bfd_mach_o_section **);
int bfd_mach_o_lookup_command (bfd *, bfd_mach_o_load_command_type, bfd_mach_o_load_command **);
bfd_boolean bfd_mach_o_write_contents (bfd *);