* 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>
+
+ * 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.
#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"
_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
#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 */
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
#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)))
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,
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,
#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
#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
#undef TARGET_NAME
#undef TARGET_STRING
+#undef TARGET_ARCHITECTURE
#undef TARGET_BIG_ENDIAN
#undef TARGET_ARCHIVE
/* 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 *,
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 *);