1 |
24 |
jeremybenn |
/* Mach-O support for BFD.
|
2 |
225 |
jeremybenn |
Copyright 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2009
|
3 |
24 |
jeremybenn |
Free Software Foundation, Inc.
|
4 |
|
|
|
5 |
|
|
This file is part of BFD, the Binary File Descriptor library.
|
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify
|
8 |
|
|
it under the terms of the GNU General Public License as published by
|
9 |
|
|
the Free Software Foundation; either version 3 of the License, or
|
10 |
|
|
(at your option) any later version.
|
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful,
|
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
GNU General Public License for more details.
|
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License
|
18 |
|
|
along with this program; if not, write to the Free Software
|
19 |
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
20 |
|
|
MA 02110-1301, USA. */
|
21 |
|
|
|
22 |
225 |
jeremybenn |
/* Define generic entry points here so that we don't need to duplicate the
|
23 |
|
|
defines in every target. But define once as this file may be included
|
24 |
|
|
several times. */
|
25 |
|
|
#ifndef MACH_O_TARGET_COMMON_DEFINED
|
26 |
|
|
#define MACH_O_TARGET_COMMON_DEFINED
|
27 |
|
|
|
28 |
|
|
#define bfd_mach_o_mkarchive _bfd_noarchive_mkarchive
|
29 |
|
|
#define bfd_mach_o_read_ar_hdr _bfd_noarchive_read_ar_hdr
|
30 |
|
|
#define bfd_mach_o_slurp_armap _bfd_noarchive_slurp_armap
|
31 |
|
|
#define bfd_mach_o_slurp_extended_name_table _bfd_noarchive_slurp_extended_name_table
|
32 |
|
|
#define bfd_mach_o_construct_extended_name_table _bfd_noarchive_construct_extended_name_table
|
33 |
|
|
#define bfd_mach_o_truncate_arname _bfd_noarchive_truncate_arname
|
34 |
|
|
#define bfd_mach_o_write_armap _bfd_noarchive_write_armap
|
35 |
|
|
#define bfd_mach_o_get_elt_at_index _bfd_noarchive_get_elt_at_index
|
36 |
|
|
#define bfd_mach_o_generic_stat_arch_elt _bfd_noarchive_generic_stat_arch_elt
|
37 |
|
|
#define bfd_mach_o_update_armap_timestamp _bfd_noarchive_update_armap_timestamp
|
38 |
|
|
#define bfd_mach_o_close_and_cleanup _bfd_generic_close_and_cleanup
|
39 |
|
|
#define bfd_mach_o_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
|
40 |
|
|
#define bfd_mach_o_new_section_hook _bfd_generic_new_section_hook
|
41 |
|
|
#define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
|
42 |
|
|
#define bfd_mach_o_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
|
43 |
|
|
#define bfd_mach_o_bfd_is_local_label_name bfd_generic_is_local_label_name
|
44 |
|
|
#define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
|
45 |
|
|
#define bfd_mach_o_find_nearest_line _bfd_nosymbols_find_nearest_line
|
46 |
|
|
#define bfd_mach_o_find_inliner_info _bfd_nosymbols_find_inliner_info
|
47 |
|
|
#define bfd_mach_o_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
|
48 |
|
|
#define bfd_mach_o_read_minisymbols _bfd_generic_read_minisymbols
|
49 |
|
|
#define bfd_mach_o_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
|
50 |
|
|
#define bfd_mach_o_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
|
51 |
|
|
#define bfd_mach_o_bfd_relax_section bfd_generic_relax_section
|
52 |
|
|
#define bfd_mach_o_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
53 |
|
|
#define bfd_mach_o_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
|
54 |
|
|
#define bfd_mach_o_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
55 |
|
|
#define bfd_mach_o_bfd_link_just_syms _bfd_generic_link_just_syms
|
56 |
|
|
#define bfd_mach_o_bfd_final_link _bfd_generic_final_link
|
57 |
|
|
#define bfd_mach_o_bfd_link_split_section _bfd_generic_link_split_section
|
58 |
|
|
#define bfd_mach_o_set_arch_mach bfd_default_set_arch_mach
|
59 |
|
|
#define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
|
60 |
|
|
#define bfd_mach_o_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
|
61 |
|
|
#define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents
|
62 |
|
|
#define bfd_mach_o_bfd_gc_sections bfd_generic_gc_sections
|
63 |
|
|
#define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections
|
64 |
|
|
#define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section
|
65 |
|
|
#define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
|
66 |
|
|
#define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked
|
67 |
|
|
#define bfd_mach_o_bfd_define_common_symbol bfd_generic_define_common_symbol
|
68 |
|
|
#define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
|
69 |
|
|
#define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p
|
70 |
|
|
|
71 |
|
|
#define bfd_mach_o_get_dynamic_symtab_upper_bound bfd_mach_o_get_symtab_upper_bound
|
72 |
|
|
#define bfd_mach_o_canonicalize_dynamic_symtab bfd_mach_o_canonicalize_symtab
|
73 |
|
|
#define bfd_mach_o_get_synthetic_symtab _bfd_nodynamic_get_synthetic_symtab
|
74 |
|
|
|
75 |
|
|
#define TARGET_NAME_BACKEND XCONCAT2(TARGET_NAME,_backend)
|
76 |
|
|
|
77 |
|
|
#endif /* MACH_O_TARGET_COMMON_DEFINED */
|
78 |
|
|
|
79 |
24 |
jeremybenn |
#ifndef TARGET_NAME
|
80 |
|
|
#error TARGET_NAME must be defined
|
81 |
|
|
#endif /* TARGET_NAME */
|
82 |
|
|
|
83 |
|
|
#ifndef TARGET_STRING
|
84 |
|
|
#error TARGET_STRING must be defined
|
85 |
|
|
#endif /* TARGET_STRING */
|
86 |
|
|
|
87 |
|
|
#ifndef TARGET_BIG_ENDIAN
|
88 |
|
|
#error TARGET_BIG_ENDIAN must be defined
|
89 |
|
|
#endif /* TARGET_BIG_ENDIAN */
|
90 |
|
|
|
91 |
|
|
#ifndef TARGET_ARCHIVE
|
92 |
|
|
#error TARGET_ARCHIVE must be defined
|
93 |
|
|
#endif /* TARGET_ARCHIVE */
|
94 |
|
|
|
95 |
|
|
#if ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN))
|
96 |
|
|
#error Mach-O fat files must always be big-endian.
|
97 |
|
|
#endif /* ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN)) */
|
98 |
|
|
|
99 |
225 |
jeremybenn |
static const bfd_mach_o_backend_data TARGET_NAME_BACKEND =
|
100 |
|
|
{
|
101 |
|
|
bfd_mach_o_swap_reloc_in,
|
102 |
|
|
bfd_mach_o_swap_reloc_out,
|
103 |
|
|
bfd_mach_o_print_thread
|
104 |
|
|
};
|
105 |
|
|
|
106 |
24 |
jeremybenn |
const bfd_target TARGET_NAME =
|
107 |
|
|
{
|
108 |
|
|
TARGET_STRING, /* Name. */
|
109 |
|
|
bfd_target_mach_o_flavour,
|
110 |
|
|
#if TARGET_BIG_ENDIAN
|
111 |
|
|
BFD_ENDIAN_BIG, /* Target byte order. */
|
112 |
|
|
BFD_ENDIAN_BIG, /* Target headers byte order. */
|
113 |
|
|
#else
|
114 |
|
|
BFD_ENDIAN_LITTLE, /* Target byte order. */
|
115 |
|
|
BFD_ENDIAN_LITTLE, /* Target headers byte order. */
|
116 |
|
|
#endif
|
117 |
|
|
(HAS_RELOC | EXEC_P | /* Object flags. */
|
118 |
|
|
HAS_LINENO | HAS_DEBUG |
|
119 |
|
|
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
120 |
|
|
(SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
|
121 |
|
|
| SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
|
122 |
|
|
'_', /* symbol_leading_char. */
|
123 |
|
|
' ', /* ar_pad_char. */
|
124 |
|
|
16, /* ar_max_namelen. */
|
125 |
|
|
|
126 |
|
|
#if TARGET_BIG_ENDIAN
|
127 |
|
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
128 |
|
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
129 |
|
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
|
130 |
|
|
bfd_getb64, bfd_getb_signed_64, bfd_putb64,
|
131 |
|
|
bfd_getb32, bfd_getb_signed_32, bfd_putb32,
|
132 |
|
|
bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
|
133 |
|
|
#else
|
134 |
|
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
135 |
|
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
136 |
|
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
|
137 |
|
|
bfd_getl64, bfd_getl_signed_64, bfd_putl64,
|
138 |
|
|
bfd_getl32, bfd_getl_signed_32, bfd_putl32,
|
139 |
|
|
bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
|
140 |
|
|
#endif /* TARGET_BIG_ENDIAN */
|
141 |
|
|
|
142 |
|
|
{ /* bfd_check_format. */
|
143 |
|
|
#if TARGET_ARCHIVE
|
144 |
|
|
_bfd_dummy_target,
|
145 |
|
|
_bfd_dummy_target,
|
146 |
|
|
bfd_mach_o_archive_p,
|
147 |
|
|
_bfd_dummy_target,
|
148 |
|
|
#else
|
149 |
|
|
_bfd_dummy_target,
|
150 |
|
|
bfd_mach_o_object_p,
|
151 |
225 |
jeremybenn |
bfd_generic_archive_p,
|
152 |
24 |
jeremybenn |
bfd_mach_o_core_p
|
153 |
|
|
#endif
|
154 |
|
|
},
|
155 |
|
|
{ /* bfd_set_format. */
|
156 |
|
|
bfd_false,
|
157 |
|
|
bfd_mach_o_mkobject,
|
158 |
225 |
jeremybenn |
_bfd_generic_mkarchive,
|
159 |
24 |
jeremybenn |
bfd_mach_o_mkobject,
|
160 |
|
|
},
|
161 |
|
|
{ /* bfd_write_contents. */
|
162 |
|
|
bfd_false,
|
163 |
|
|
bfd_mach_o_write_contents,
|
164 |
225 |
jeremybenn |
_bfd_write_archive_contents,
|
165 |
24 |
jeremybenn |
bfd_mach_o_write_contents,
|
166 |
|
|
},
|
167 |
|
|
|
168 |
|
|
BFD_JUMP_TABLE_GENERIC (bfd_mach_o),
|
169 |
|
|
BFD_JUMP_TABLE_COPY (bfd_mach_o),
|
170 |
|
|
BFD_JUMP_TABLE_CORE (bfd_mach_o),
|
171 |
225 |
jeremybenn |
#if TARGET_ARCHIVE
|
172 |
24 |
jeremybenn |
BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o),
|
173 |
225 |
jeremybenn |
#else
|
174 |
|
|
BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd),
|
175 |
|
|
#endif
|
176 |
24 |
jeremybenn |
BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o),
|
177 |
225 |
jeremybenn |
BFD_JUMP_TABLE_RELOCS (bfd_mach_o),
|
178 |
24 |
jeremybenn |
BFD_JUMP_TABLE_WRITE (bfd_mach_o),
|
179 |
|
|
BFD_JUMP_TABLE_LINK (bfd_mach_o),
|
180 |
225 |
jeremybenn |
BFD_JUMP_TABLE_DYNAMIC (bfd_mach_o),
|
181 |
24 |
jeremybenn |
|
182 |
225 |
jeremybenn |
/* Alternative endian target. */
|
183 |
24 |
jeremybenn |
NULL,
|
184 |
|
|
|
185 |
225 |
jeremybenn |
/* Back-end data. */
|
186 |
|
|
&TARGET_NAME_BACKEND
|
187 |
24 |
jeremybenn |
};
|
188 |
|
|
|