1 /* Mach-O support for BFD.
2 Copyright (C) 1999-2014 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
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
24 #ifndef MACH_O_TARGET_COMMON_DEFINED
25 #define MACH_O_TARGET_COMMON_DEFINED
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_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
35 #define bfd_mach_o_read_minisymbols _bfd_generic_read_minisymbols
36 #define bfd_mach_o_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
37 #define bfd_mach_o_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
38 #define bfd_mach_o_bfd_relax_section bfd_generic_relax_section
39 #define bfd_mach_o_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
40 #define bfd_mach_o_bfd_link_add_symbols _bfd_generic_link_add_symbols
41 #define bfd_mach_o_bfd_link_just_syms _bfd_generic_link_just_syms
42 #define bfd_mach_o_bfd_copy_link_hash_symbol_type \
43 _bfd_generic_copy_link_hash_symbol_type
44 #define bfd_mach_o_bfd_final_link _bfd_generic_final_link
45 #define bfd_mach_o_bfd_link_split_section _bfd_generic_link_split_section
46 #define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
47 #define bfd_mach_o_bfd_set_private_flags bfd_mach_o_bfd_set_private_flags
48 #define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents
49 #define bfd_mach_o_bfd_gc_sections bfd_generic_gc_sections
50 #define bfd_mach_o_bfd_lookup_section_flags bfd_generic_lookup_section_flags
51 #define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections
52 #define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section
53 #define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
54 #define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked
55 #define bfd_mach_o_bfd_define_common_symbol bfd_generic_define_common_symbol
56 #define bfd_mach_o_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
57 #define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p
58 #define bfd_mach_o_core_file_pid _bfd_nocore_core_file_pid
60 #define bfd_mach_o_get_dynamic_symtab_upper_bound bfd_mach_o_get_symtab_upper_bound
61 #define bfd_mach_o_canonicalize_dynamic_symtab bfd_mach_o_canonicalize_symtab
63 #define TARGET_NAME_BACKEND XCONCAT2(TARGET_NAME,_backend)
65 #endif /* MACH_O_TARGET_COMMON_DEFINED */
68 #error TARGET_NAME must be defined
69 #endif /* TARGET_NAME */
72 #error TARGET_STRING must be defined
73 #endif /* TARGET_STRING */
75 #ifndef TARGET_ARCHITECTURE
76 #error TARGET_ARCHITECTURE must be defined
77 #endif /* TARGET_ARCHITECTURE */
79 #ifndef TARGET_BIG_ENDIAN
80 #error TARGET_BIG_ENDIAN must be defined
81 #endif /* TARGET_BIG_ENDIAN */
83 #ifndef TARGET_ARCHIVE
84 #error TARGET_ARCHIVE must be defined
85 #endif /* TARGET_ARCHIVE */
87 #ifndef TARGET_PAGESIZE
88 #error TARGET_PAGESIZE must be defined
91 #if ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN))
92 #error Mach-O fat files must always be big-endian.
93 #endif /* ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN)) */
95 static const bfd_mach_o_backend_data TARGET_NAME_BACKEND
=
99 bfd_mach_o_swap_reloc_in
,
100 bfd_mach_o_swap_reloc_out
,
101 bfd_mach_o_print_thread
,
102 bfd_mach_o_tgt_seg_table
,
103 bfd_mach_o_section_type_valid_for_tgt
106 const bfd_target TARGET_NAME
=
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. */
114 BFD_ENDIAN_LITTLE
, /* Target byte order. */
115 BFD_ENDIAN_LITTLE
, /* Target headers byte order. */
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 TARGET_PRIORITY
, /* match priority. */
127 #if TARGET_BIG_ENDIAN
128 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
129 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
130 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* Data. */
131 bfd_getb64
, bfd_getb_signed_64
, bfd_putb64
,
132 bfd_getb32
, bfd_getb_signed_32
, bfd_putb32
,
133 bfd_getb16
, bfd_getb_signed_16
, bfd_putb16
, /* Hdrs. */
135 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
136 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
137 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* data */
138 bfd_getl64
, bfd_getl_signed_64
, bfd_putl64
,
139 bfd_getl32
, bfd_getl_signed_32
, bfd_putl32
,
140 bfd_getl16
, bfd_getl_signed_16
, bfd_putl16
, /* hdrs */
141 #endif /* TARGET_BIG_ENDIAN */
143 { /* bfd_check_format. */
147 bfd_mach_o_archive_p
,
152 bfd_generic_archive_p
,
156 { /* bfd_set_format. */
159 _bfd_generic_mkarchive
,
162 { /* bfd_write_contents. */
164 bfd_mach_o_write_contents
,
165 _bfd_write_archive_contents
,
166 bfd_mach_o_write_contents
,
169 BFD_JUMP_TABLE_GENERIC (bfd_mach_o
),
170 BFD_JUMP_TABLE_COPY (bfd_mach_o
),
171 BFD_JUMP_TABLE_CORE (bfd_mach_o
),
173 BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o
),
175 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44
),
177 BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o
),
178 BFD_JUMP_TABLE_RELOCS (bfd_mach_o
),
179 BFD_JUMP_TABLE_WRITE (bfd_mach_o
),
180 BFD_JUMP_TABLE_LINK (bfd_mach_o
),
181 BFD_JUMP_TABLE_DYNAMIC (bfd_mach_o
),
183 /* Alternative endian target. */