Missing ChangeLog and files for commit 8b00c176168dc7b0d78d0dc1f7d42f915375dc4a
[deliverable/binutils-gdb.git] / bfd / mach-o-target.c
CommitLineData
3af9a47b 1/* Mach-O support for BFD.
2571583a 2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
3af9a47b
NC
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
cd123cb7 8 the Free Software Foundation; either version 3 of the License, or
3af9a47b
NC
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
68ffbac6 17 along with this program; if not, write to the Free Software
cd123cb7
NC
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
3af9a47b 20
154a1ee5
TG
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
154a1ee5 27#define bfd_mach_o_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
154a1ee5 28#define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
c5012cd8 29#define bfd_mach_o_bfd_print_private_bfd_data _bfd_generic_bfd_print_private_bfd_data
154a1ee5 30#define bfd_mach_o_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
92bc0e80 31#define bfd_mach_o_bfd_is_local_label_name bfd_generic_is_local_label_name
154a1ee5 32#define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
154a1ee5 33#define bfd_mach_o_find_inliner_info _bfd_nosymbols_find_inliner_info
60bb06bc 34#define bfd_mach_o_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string
154a1ee5
TG
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
154a1ee5
TG
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
1338dd10
PB
43#define bfd_mach_o_bfd_copy_link_hash_symbol_type \
44 _bfd_generic_copy_link_hash_symbol_type
154a1ee5
TG
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
4f3b23b3 47#define bfd_mach_o_bfd_link_check_relocs _bfd_generic_link_check_relocs
154a1ee5 48#define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
0c9ef0f0 49#define bfd_mach_o_bfd_set_private_flags bfd_mach_o_bfd_set_private_flags
154a1ee5
TG
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
ae17ab41 52#define bfd_mach_o_bfd_lookup_section_flags bfd_generic_lookup_section_flags
154a1ee5
TG
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
967b2c53 58#define bfd_mach_o_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
154a1ee5 59#define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p
261b8d08 60#define bfd_mach_o_core_file_pid _bfd_nocore_core_file_pid
154a1ee5 61
b32e07d7
TG
62#define bfd_mach_o_get_dynamic_symtab_upper_bound bfd_mach_o_get_symtab_upper_bound
63#define bfd_mach_o_canonicalize_dynamic_symtab bfd_mach_o_canonicalize_symtab
b32e07d7 64
47daa70f
TG
65/* For Mach-O special archives. */
66#define bfd_mach_o_read_ar_hdr _bfd_noarchive_read_ar_hdr
67#define bfd_mach_o_write_ar_hdr _bfd_noarchive_write_ar_hdr
68#define bfd_mach_o_slurp_armap _bfd_noarchive_slurp_armap
69#define bfd_mach_o_slurp_extended_name_table _bfd_noarchive_slurp_extended_name_table
70#define bfd_mach_o_construct_extended_name_table _bfd_noarchive_construct_extended_name_table
71#define bfd_mach_o_truncate_arname _bfd_noarchive_truncate_arname
72#define bfd_mach_o_write_armap _bfd_noarchive_write_armap
73#define bfd_mach_o_get_elt_at_index _bfd_noarchive_get_elt_at_index
74#define bfd_mach_o_update_armap_timestamp _bfd_noarchive_update_armap_timestamp
75
92bc0e80
TG
76#define TARGET_NAME_BACKEND XCONCAT2(TARGET_NAME,_backend)
77
154a1ee5
TG
78#endif /* MACH_O_TARGET_COMMON_DEFINED */
79
3af9a47b
NC
80#ifndef TARGET_NAME
81#error TARGET_NAME must be defined
82#endif /* TARGET_NAME */
83
84#ifndef TARGET_STRING
85#error TARGET_STRING must be defined
86#endif /* TARGET_STRING */
87
42fa0891
TG
88#ifndef TARGET_ARCHITECTURE
89#error TARGET_ARCHITECTURE must be defined
90#endif /* TARGET_ARCHITECTURE */
91
3af9a47b
NC
92#ifndef TARGET_BIG_ENDIAN
93#error TARGET_BIG_ENDIAN must be defined
94#endif /* TARGET_BIG_ENDIAN */
95
96#ifndef TARGET_ARCHIVE
97#error TARGET_ARCHIVE must be defined
98#endif /* TARGET_ARCHIVE */
99
4384b284
TG
100#ifndef TARGET_PAGESIZE
101#error TARGET_PAGESIZE must be defined
102#endif
103
92bc0e80
TG
104static const bfd_mach_o_backend_data TARGET_NAME_BACKEND =
105{
42fa0891 106 TARGET_ARCHITECTURE,
4384b284 107 TARGET_PAGESIZE,
bcb51645 108 bfd_mach_o_canonicalize_one_reloc,
b32e07d7 109 bfd_mach_o_swap_reloc_out,
a4551119 110 bfd_mach_o_print_thread,
ab76eeaf
IS
111 bfd_mach_o_tgt_seg_table,
112 bfd_mach_o_section_type_valid_for_tgt
92bc0e80
TG
113};
114
3af9a47b
NC
115const bfd_target TARGET_NAME =
116{
117 TARGET_STRING, /* Name. */
118 bfd_target_mach_o_flavour,
119#if TARGET_BIG_ENDIAN
120 BFD_ENDIAN_BIG, /* Target byte order. */
121 BFD_ENDIAN_BIG, /* Target headers byte order. */
122#else
123 BFD_ENDIAN_LITTLE, /* Target byte order. */
124 BFD_ENDIAN_LITTLE, /* Target headers byte order. */
125#endif
126 (HAS_RELOC | EXEC_P | /* Object flags. */
127 HAS_LINENO | HAS_DEBUG |
128 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
129 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
130 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
131 '_', /* symbol_leading_char. */
132 ' ', /* ar_pad_char. */
133 16, /* ar_max_namelen. */
b93a1992 134 TARGET_PRIORITY, /* match priority. */
3af9a47b
NC
135
136#if TARGET_BIG_ENDIAN
137 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
138 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
139 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
140 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
141 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
142 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
143#else
144 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
145 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
146 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
147 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
148 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
149 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
150#endif /* TARGET_BIG_ENDIAN */
151
152 { /* bfd_check_format. */
153#if TARGET_ARCHIVE
154 _bfd_dummy_target,
155 _bfd_dummy_target,
156 bfd_mach_o_archive_p,
157 _bfd_dummy_target,
158#else
159 _bfd_dummy_target,
160 bfd_mach_o_object_p,
15e1c58a 161 bfd_generic_archive_p,
3af9a47b
NC
162 bfd_mach_o_core_p
163#endif
164 },
165 { /* bfd_set_format. */
166 bfd_false,
167 bfd_mach_o_mkobject,
15e1c58a 168 _bfd_generic_mkarchive,
3af9a47b
NC
169 bfd_mach_o_mkobject,
170 },
171 { /* bfd_write_contents. */
172 bfd_false,
173 bfd_mach_o_write_contents,
15e1c58a 174 _bfd_write_archive_contents,
3af9a47b
NC
175 bfd_mach_o_write_contents,
176 },
177
178 BFD_JUMP_TABLE_GENERIC (bfd_mach_o),
179 BFD_JUMP_TABLE_COPY (bfd_mach_o),
180 BFD_JUMP_TABLE_CORE (bfd_mach_o),
15e1c58a 181#if TARGET_ARCHIVE
3af9a47b 182 BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o),
15e1c58a 183#else
8f95b6e4 184 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44),
15e1c58a 185#endif
3af9a47b 186 BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o),
92bc0e80 187 BFD_JUMP_TABLE_RELOCS (bfd_mach_o),
3af9a47b
NC
188 BFD_JUMP_TABLE_WRITE (bfd_mach_o),
189 BFD_JUMP_TABLE_LINK (bfd_mach_o),
b32e07d7 190 BFD_JUMP_TABLE_DYNAMIC (bfd_mach_o),
3af9a47b 191
92bc0e80 192 /* Alternative endian target. */
3af9a47b
NC
193 NULL,
194
92bc0e80
TG
195 /* Back-end data. */
196 &TARGET_NAME_BACKEND
3af9a47b
NC
197};
198
This page took 0.695612 seconds and 4 git commands to generate.