aboutsummaryrefslogtreecommitdiff
path: root/bfd/mach-o.c
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/mach-o.c
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/mach-o.c')
-rw-r--r--bfd/mach-o.c43
1 files changed, 42 insertions, 1 deletions
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