PR gdb/11557
[deliverable/binutils-gdb.git] / bfd / mach-o-target.c
CommitLineData
3af9a47b 1/* Mach-O support for BFD.
4f608e79 2 Copyright 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2009, 2010
3af9a47b
NC
3 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
cd123cb7 9 the Free Software Foundation; either version 3 of the License, or
3af9a47b
NC
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
cd123cb7
NC
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
3af9a47b 21
154a1ee5
TG
22/* 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
154a1ee5
TG
28#define bfd_mach_o_close_and_cleanup _bfd_generic_close_and_cleanup
29#define bfd_mach_o_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
30#define bfd_mach_o_new_section_hook _bfd_generic_new_section_hook
31#define bfd_mach_o_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
154a1ee5 32#define bfd_mach_o_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
92bc0e80 33#define bfd_mach_o_bfd_is_local_label_name bfd_generic_is_local_label_name
154a1ee5
TG
34#define bfd_mach_o_get_lineno _bfd_nosymbols_get_lineno
35#define bfd_mach_o_find_nearest_line _bfd_nosymbols_find_nearest_line
36#define bfd_mach_o_find_inliner_info _bfd_nosymbols_find_inliner_info
37#define bfd_mach_o_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
38#define bfd_mach_o_read_minisymbols _bfd_generic_read_minisymbols
39#define bfd_mach_o_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
40#define bfd_mach_o_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
41#define bfd_mach_o_bfd_relax_section bfd_generic_relax_section
42#define bfd_mach_o_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
43#define bfd_mach_o_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
44#define bfd_mach_o_bfd_link_add_symbols _bfd_generic_link_add_symbols
45#define bfd_mach_o_bfd_link_just_syms _bfd_generic_link_just_syms
1338dd10
PB
46#define bfd_mach_o_bfd_copy_link_hash_symbol_type \
47 _bfd_generic_copy_link_hash_symbol_type
154a1ee5
TG
48#define bfd_mach_o_bfd_final_link _bfd_generic_final_link
49#define bfd_mach_o_bfd_link_split_section _bfd_generic_link_split_section
154a1ee5
TG
50#define bfd_mach_o_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
51#define bfd_mach_o_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
52#define bfd_mach_o_get_section_contents _bfd_generic_get_section_contents
53#define bfd_mach_o_bfd_gc_sections bfd_generic_gc_sections
54#define bfd_mach_o_bfd_merge_sections bfd_generic_merge_sections
55#define bfd_mach_o_bfd_is_group_section bfd_generic_is_group_section
56#define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
57#define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked
58#define bfd_mach_o_bfd_define_common_symbol bfd_generic_define_common_symbol
59#define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
60#define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p
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
92bc0e80
TG
65#define TARGET_NAME_BACKEND XCONCAT2(TARGET_NAME,_backend)
66
154a1ee5
TG
67#endif /* MACH_O_TARGET_COMMON_DEFINED */
68
3af9a47b
NC
69#ifndef TARGET_NAME
70#error TARGET_NAME must be defined
71#endif /* TARGET_NAME */
72
73#ifndef TARGET_STRING
74#error TARGET_STRING must be defined
75#endif /* TARGET_STRING */
76
42fa0891
TG
77#ifndef TARGET_ARCHITECTURE
78#error TARGET_ARCHITECTURE must be defined
79#endif /* TARGET_ARCHITECTURE */
80
3af9a47b
NC
81#ifndef TARGET_BIG_ENDIAN
82#error TARGET_BIG_ENDIAN must be defined
83#endif /* TARGET_BIG_ENDIAN */
84
85#ifndef TARGET_ARCHIVE
86#error TARGET_ARCHIVE must be defined
87#endif /* TARGET_ARCHIVE */
88
89#if ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN))
90#error Mach-O fat files must always be big-endian.
91#endif /* ((TARGET_ARCHIVE) && (! TARGET_BIG_ENDIAN)) */
92
92bc0e80
TG
93static const bfd_mach_o_backend_data TARGET_NAME_BACKEND =
94{
42fa0891 95 TARGET_ARCHITECTURE,
92bc0e80 96 bfd_mach_o_swap_reloc_in,
b32e07d7
TG
97 bfd_mach_o_swap_reloc_out,
98 bfd_mach_o_print_thread
92bc0e80
TG
99};
100
3af9a47b
NC
101const bfd_target TARGET_NAME =
102{
103 TARGET_STRING, /* Name. */
104 bfd_target_mach_o_flavour,
105#if TARGET_BIG_ENDIAN
106 BFD_ENDIAN_BIG, /* Target byte order. */
107 BFD_ENDIAN_BIG, /* Target headers byte order. */
108#else
109 BFD_ENDIAN_LITTLE, /* Target byte order. */
110 BFD_ENDIAN_LITTLE, /* Target headers byte order. */
111#endif
112 (HAS_RELOC | EXEC_P | /* Object flags. */
113 HAS_LINENO | HAS_DEBUG |
114 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
115 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
116 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* Section flags. */
117 '_', /* symbol_leading_char. */
118 ' ', /* ar_pad_char. */
119 16, /* ar_max_namelen. */
120
121#if TARGET_BIG_ENDIAN
122 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
123 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
124 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
125 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
126 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
127 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
128#else
129 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
130 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
131 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */
132 bfd_getl64, bfd_getl_signed_64, bfd_putl64,
133 bfd_getl32, bfd_getl_signed_32, bfd_putl32,
134 bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */
135#endif /* TARGET_BIG_ENDIAN */
136
137 { /* bfd_check_format. */
138#if TARGET_ARCHIVE
139 _bfd_dummy_target,
140 _bfd_dummy_target,
141 bfd_mach_o_archive_p,
142 _bfd_dummy_target,
143#else
144 _bfd_dummy_target,
145 bfd_mach_o_object_p,
15e1c58a 146 bfd_generic_archive_p,
3af9a47b
NC
147 bfd_mach_o_core_p
148#endif
149 },
150 { /* bfd_set_format. */
151 bfd_false,
152 bfd_mach_o_mkobject,
15e1c58a 153 _bfd_generic_mkarchive,
3af9a47b
NC
154 bfd_mach_o_mkobject,
155 },
156 { /* bfd_write_contents. */
157 bfd_false,
158 bfd_mach_o_write_contents,
15e1c58a 159 _bfd_write_archive_contents,
3af9a47b
NC
160 bfd_mach_o_write_contents,
161 },
162
163 BFD_JUMP_TABLE_GENERIC (bfd_mach_o),
164 BFD_JUMP_TABLE_COPY (bfd_mach_o),
165 BFD_JUMP_TABLE_CORE (bfd_mach_o),
15e1c58a 166#if TARGET_ARCHIVE
3af9a47b 167 BFD_JUMP_TABLE_ARCHIVE (bfd_mach_o),
15e1c58a 168#else
8f95b6e4 169 BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44),
15e1c58a 170#endif
3af9a47b 171 BFD_JUMP_TABLE_SYMBOLS (bfd_mach_o),
92bc0e80 172 BFD_JUMP_TABLE_RELOCS (bfd_mach_o),
3af9a47b
NC
173 BFD_JUMP_TABLE_WRITE (bfd_mach_o),
174 BFD_JUMP_TABLE_LINK (bfd_mach_o),
b32e07d7 175 BFD_JUMP_TABLE_DYNAMIC (bfd_mach_o),
3af9a47b 176
92bc0e80 177 /* Alternative endian target. */
3af9a47b
NC
178 NULL,
179
92bc0e80
TG
180 /* Back-end data. */
181 &TARGET_NAME_BACKEND
3af9a47b
NC
182};
183
This page took 0.405389 seconds and 4 git commands to generate.