aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorTristan Gingold <gingold@adacore.com>2010-01-11 15:39:41 +0000
committerTristan Gingold <gingold@adacore.com>2010-01-11 15:39:41 +0000
commit42fa08916b972ce06b7bcdee8e0ce4171053cd89 (patch)
tree7dfede22b30634369294adc9839b73414f246fc2 /bfd
parentcba0723b0f0fb521d83dc1d7cd1cdcdb4991dd02 (diff)
downloadgdb-42fa08916b972ce06b7bcdee8e0ce4171053cd89.zip
gdb-42fa08916b972ce06b7bcdee8e0ce4171053cd89.tar.gz
gdb-42fa08916b972ce06b7bcdee8e0ce4171053cd89.tar.bz2
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog13
-rw-r--r--bfd/mach-o-i386.c1
-rw-r--r--bfd/mach-o-target.c6
-rw-r--r--bfd/mach-o.c43
-rw-r--r--bfd/mach-o.h3
5 files changed, 64 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index aaf3186..22b26ab 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,18 @@
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.
2010-01-11 Nick Clifton <nickc@redhat.com>
diff --git a/bfd/mach-o-i386.c b/bfd/mach-o-i386.c
index 53de64e..e46cbc6 100644
--- a/bfd/mach-o-i386.c
+++ b/bfd/mach-o-i386.c
@@ -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"
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 2a30b2e..8edf547 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -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
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index ae86c4e..abfd7c1 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -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
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 62f7709..bdd7632 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -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 *);