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