]>
Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | /* libbfd.h -- Declarations used by bfd library *implementation*. |
2 | (This include file is not for users of the library.) | |
7c192733 | 3 | |
d87bef3a | 4 | Copyright (C) 1990-2023 Free Software Foundation, Inc. |
7c192733 | 5 | |
252b5132 RH |
6 | Written by Cygnus Support. |
7 | ||
cd123cb7 NC |
8 | This file is part of BFD, the Binary File Descriptor library. |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 3 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
23 | MA 02110-1301, USA. */ | |
252b5132 | 24 | |
0b439543 AM |
25 | #ifndef _LIBBFD_H |
26 | #define _LIBBFD_H 1 | |
27 | ||
8722de9c AM |
28 | #ifndef ATTRIBUTE_HIDDEN |
29 | #if HAVE_HIDDEN | |
30 | #define ATTRIBUTE_HIDDEN __attribute__ ((__visibility__ ("hidden"))) | |
31 | #else | |
32 | #define ATTRIBUTE_HIDDEN | |
33 | #endif | |
34 | #endif | |
35 | ||
109f7096 BE |
36 | #include "hashtab.h" |
37 | ||
55172d69 PA |
38 | #ifdef __cplusplus |
39 | extern "C" { | |
40 | #endif | |
41 | ||
252b5132 RH |
42 | /* If you want to read and write large blocks, you might want to do it |
43 | in quanta of this amount */ | |
44 | #define DEFAULT_BUFFERSIZE 8192 | |
45 | ||
46 | /* Set a tdata field. Can't use the other macros for this, since they | |
47 | do casts, and casting to the left of assignment isn't portable. */ | |
c58b9523 | 48 | #define set_tdata(bfd, v) ((bfd)->tdata.any = (v)) |
252b5132 RH |
49 | |
50 | /* If BFD_IN_MEMORY is set for a BFD, then the iostream fields points | |
51 | to an instance of this structure. */ | |
52 | ||
53 | struct bfd_in_memory | |
54 | { | |
55 | /* Size of buffer. */ | |
56 | bfd_size_type size; | |
57 | /* Buffer holding contents of BFD. */ | |
58 | bfd_byte *buffer; | |
59 | }; | |
60 | ||
66eb6687 AM |
61 | struct section_hash_entry |
62 | { | |
63 | struct bfd_hash_entry root; | |
64 | asection section; | |
65 | }; | |
66 | ||
7cf7fcc8 | 67 | /* Unique section id. */ |
8722de9c | 68 | extern unsigned int _bfd_section_id ATTRIBUTE_HIDDEN; |
7cf7fcc8 | 69 | |
252b5132 RH |
70 | /* tdata for an archive. For an input archive, cache |
71 | needs to be free()'d. For an output archive, symdefs do. */ | |
72 | ||
f1bb16f8 NC |
73 | struct artdata |
74 | { | |
252b5132 RH |
75 | file_ptr first_file_filepos; |
76 | /* Speed up searching the armap */ | |
109f7096 | 77 | htab_t cache; |
f1bb16f8 NC |
78 | bfd *archive_head; /* Only interesting in output routines. */ |
79 | carsym *symdefs; /* The symdef entries. */ | |
80 | symindex symdef_count; /* How many there are. */ | |
81 | char *extended_names; /* Clever intel extension. */ | |
82 | bfd_size_type extended_names_size; /* Size of extended names. */ | |
83 | /* When more compilers are standard C, this can be a time_t. */ | |
252b5132 RH |
84 | long armap_timestamp; /* Timestamp value written into armap. |
85 | This is used for BSD archives to check | |
86 | that the timestamp is recent enough | |
87 | for the BSD linker to not complain, | |
88 | just before we finish writing an | |
89 | archive. */ | |
90 | file_ptr armap_datepos; /* Position within archive to seek to | |
91 | rewrite the date field. */ | |
c58b9523 | 92 | void *tdata; /* Backend specific information. */ |
252b5132 RH |
93 | }; |
94 | ||
95 | #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data) | |
96 | ||
97 | /* Goes in bfd's arelt_data slot */ | |
f1bb16f8 NC |
98 | struct areltdata |
99 | { | |
100 | char * arch_header; /* It's actually a string. */ | |
101 | bfd_size_type parsed_size; /* Octets of filesize not including ar_hdr. */ | |
102 | bfd_size_type extra_size; /* BSD4.4: extra bytes after the header. */ | |
103 | char *filename; /* Null-terminated. */ | |
104 | file_ptr origin; /* For element of a thin archive. */ | |
eeb1f9ae AM |
105 | void *parent_cache; /* Where and how to find this member. */ |
106 | file_ptr key; | |
252b5132 RH |
107 | }; |
108 | ||
109 | #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size) | |
110 | ||
c58b9523 | 111 | extern void *bfd_malloc |
8722de9c | 112 | (bfd_size_type) ATTRIBUTE_HIDDEN; |
252b5132 | 113 | |
89bdc77e AM |
114 | static inline char * |
115 | bfd_strdup (const char *str) | |
116 | { | |
117 | size_t len = strlen (str) + 1; | |
118 | char *buf = bfd_malloc (len); | |
119 | if (buf != NULL) | |
120 | memcpy (buf, str, len); | |
121 | return buf; | |
122 | } | |
252b5132 RH |
123 | /* These routines allocate and free things on the BFD's objalloc. */ |
124 | ||
b34976b6 | 125 | extern void bfd_release |
8722de9c AM |
126 | (bfd *, void *) ATTRIBUTE_HIDDEN; |
127 | ||
128 | extern bfd * _bfd_create_empty_archive_element_shell | |
129 | (bfd *) ATTRIBUTE_HIDDEN; | |
130 | extern bfd * _bfd_look_for_bfd_in_cache | |
131 | (bfd *, file_ptr) ATTRIBUTE_HIDDEN; | |
0a1b45a2 | 132 | extern bool _bfd_add_bfd_to_archive_cache |
8722de9c | 133 | (bfd *, file_ptr, bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 134 | extern bool _bfd_generic_mkarchive |
8722de9c AM |
135 | (bfd *) ATTRIBUTE_HIDDEN; |
136 | extern char *_bfd_append_relative_path | |
137 | (bfd *, char *) ATTRIBUTE_HIDDEN; | |
cb001c0d | 138 | extern bfd_cleanup bfd_generic_archive_p |
8722de9c | 139 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 140 | extern bool bfd_slurp_armap |
8722de9c | 141 | (bfd *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
142 | #define bfd_slurp_bsd_armap bfd_slurp_armap |
143 | #define bfd_slurp_coff_armap bfd_slurp_armap | |
0a1b45a2 | 144 | extern bool _bfd_archive_64_bit_slurp_armap |
8722de9c | 145 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 146 | extern bool _bfd_archive_64_bit_write_armap |
8722de9c | 147 | (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN; |
e6cc316a L |
148 | #define _bfd_archive_64_bit_slurp_extended_name_table \ |
149 | _bfd_slurp_extended_name_table | |
150 | #define _bfd_archive_64_bit_construct_extended_name_table \ | |
151 | _bfd_archive_coff_construct_extended_name_table | |
152 | #define _bfd_archive_64_bit_truncate_arname \ | |
153 | bfd_dont_truncate_arname | |
154 | #define _bfd_archive_64_bit_read_ar_hdr \ | |
155 | _bfd_generic_read_ar_hdr | |
156 | #define _bfd_archive_64_bit_write_ar_hdr \ | |
157 | _bfd_generic_write_ar_hdr | |
158 | #define _bfd_archive_64_bit_openr_next_archived_file \ | |
159 | bfd_generic_openr_next_archived_file | |
160 | #define _bfd_archive_64_bit_get_elt_at_index \ | |
161 | _bfd_generic_get_elt_at_index | |
162 | #define _bfd_archive_64_bit_generic_stat_arch_elt \ | |
163 | bfd_generic_stat_arch_elt | |
d00dd7dc | 164 | #define _bfd_archive_64_bit_update_armap_timestamp _bfd_bool_bfd_true |
e6cc316a | 165 | |
0a1b45a2 | 166 | extern bool _bfd_slurp_extended_name_table |
8722de9c | 167 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 AM |
168 | extern bool _bfd_construct_extended_name_table |
169 | (bfd *, bool, char **, bfd_size_type *) ATTRIBUTE_HIDDEN; | |
170 | extern bool _bfd_write_archive_contents | |
8722de9c | 171 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 172 | extern bool _bfd_compute_and_write_armap |
8722de9c AM |
173 | (bfd *, unsigned int) ATTRIBUTE_HIDDEN; |
174 | extern bfd *_bfd_get_elt_at_filepos | |
6395a102 | 175 | (bfd *, file_ptr, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
b34976b6 | 176 | extern bfd *_bfd_generic_get_elt_at_index |
8722de9c AM |
177 | (bfd *, symindex) ATTRIBUTE_HIDDEN; |
178 | extern bfd * _bfd_new_bfd | |
179 | (void) ATTRIBUTE_HIDDEN; | |
0a1b45a2 | 180 | extern bool _bfd_free_cached_info |
8722de9c | 181 | (bfd *) ATTRIBUTE_HIDDEN; |
b34976b6 | 182 | |
0a1b45a2 | 183 | extern bool _bfd_bool_bfd_false |
8722de9c | 184 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 185 | extern bool _bfd_bool_bfd_asymbol_false |
8722de9c | 186 | (bfd *, asymbol *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 187 | extern bool _bfd_bool_bfd_false_error |
8722de9c | 188 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 189 | extern bool _bfd_bool_bfd_link_false_error |
8722de9c | 190 | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 191 | extern bool _bfd_bool_bfd_true |
8722de9c | 192 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 193 | extern bool _bfd_bool_bfd_link_true |
8722de9c | 194 | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 195 | extern bool _bfd_bool_bfd_bfd_true |
8722de9c | 196 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 197 | extern bool _bfd_bool_bfd_uint_true |
8722de9c | 198 | (bfd *, unsigned int) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 199 | extern bool _bfd_bool_bfd_asection_bfd_asection_true |
8722de9c | 200 | (bfd *, asection *, bfd *, asection *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 201 | extern bool _bfd_bool_bfd_asymbol_bfd_asymbol_true |
8722de9c | 202 | (bfd *, asymbol *, bfd *, asymbol *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 203 | extern bool _bfd_bool_bfd_ptr_true |
8722de9c | 204 | (bfd *, void *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 205 | extern void *_bfd_ptr_bfd_null_error |
8722de9c | 206 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 207 | extern int _bfd_int_bfd_0 |
8722de9c | 208 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 209 | extern unsigned int _bfd_uint_bfd_0 |
8722de9c | 210 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 211 | extern long _bfd_long_bfd_0 |
8722de9c | 212 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 213 | extern long _bfd_long_bfd_n1_error |
8722de9c | 214 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 215 | extern void _bfd_void_bfd |
8722de9c | 216 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 217 | extern void _bfd_void_bfd_link |
8722de9c | 218 | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 219 | extern void _bfd_void_bfd_asection |
8722de9c | 220 | (bfd *, asection *) ATTRIBUTE_HIDDEN; |
b34976b6 | 221 | |
8722de9c AM |
222 | extern bfd *_bfd_new_bfd_contained_in |
223 | (bfd *) ATTRIBUTE_HIDDEN; | |
cb001c0d | 224 | extern bfd_cleanup _bfd_dummy_target |
8722de9c | 225 | (bfd *) ATTRIBUTE_HIDDEN; |
cb001c0d | 226 | #define _bfd_no_cleanup _bfd_void_bfd |
b34976b6 | 227 | |
8722de9c AM |
228 | extern void bfd_dont_truncate_arname |
229 | (bfd *, const char *, char *) ATTRIBUTE_HIDDEN; | |
230 | extern void bfd_bsd_truncate_arname | |
231 | (bfd *, const char *, char *) ATTRIBUTE_HIDDEN; | |
232 | extern void bfd_gnu_truncate_arname | |
233 | (bfd *, const char *, char *) ATTRIBUTE_HIDDEN; | |
b34976b6 | 234 | |
0a1b45a2 | 235 | extern bool _bfd_bsd_write_armap |
8722de9c | 236 | (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN; |
b34976b6 | 237 | |
0a1b45a2 | 238 | extern bool _bfd_coff_write_armap |
8722de9c | 239 | (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN; |
b34976b6 | 240 | |
c58b9523 | 241 | extern void *_bfd_generic_read_ar_hdr |
8722de9c | 242 | (bfd *) ATTRIBUTE_HIDDEN; |
390c0e42 | 243 | extern void _bfd_ar_spacepad |
8722de9c | 244 | (char *, size_t, const char *, long) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 245 | extern bool _bfd_ar_sizepad |
8722de9c | 246 | (char *, size_t, bfd_size_type) ATTRIBUTE_HIDDEN; |
b34976b6 | 247 | |
c58b9523 | 248 | extern void *_bfd_generic_read_ar_hdr_mag |
8722de9c | 249 | (bfd *, const char *) ATTRIBUTE_HIDDEN; |
b34976b6 | 250 | |
0a1b45a2 | 251 | extern bool _bfd_generic_write_ar_hdr |
8722de9c | 252 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; |
8f95b6e4 | 253 | |
0a1b45a2 | 254 | extern bool _bfd_bsd44_write_ar_hdr |
8722de9c | 255 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; |
8f95b6e4 | 256 | |
8722de9c AM |
257 | extern bfd * bfd_generic_openr_next_archived_file |
258 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; | |
b34976b6 | 259 | |
8722de9c AM |
260 | extern int bfd_generic_stat_arch_elt |
261 | (bfd *, struct stat *) ATTRIBUTE_HIDDEN; | |
252b5132 RH |
262 | |
263 | #define _bfd_read_ar_hdr(abfd) \ | |
07d6d2b8 AM |
264 | BFD_SEND (abfd, _bfd_read_ar_hdr_fn, (abfd)) |
265 | #define _bfd_write_ar_hdr(archive, abfd) \ | |
266 | BFD_SEND (abfd, _bfd_write_ar_hdr_fn, (archive, abfd)) | |
252b5132 RH |
267 | \f |
268 | /* Generic routines to use for BFD_JUMP_TABLE_GENERIC. Use | |
269 | BFD_JUMP_TABLE_GENERIC (_bfd_generic). */ | |
270 | ||
eeb1f9ae | 271 | #define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup |
0a1b45a2 | 272 | extern bool _bfd_archive_close_and_cleanup |
8722de9c | 273 | (bfd *) ATTRIBUTE_HIDDEN; |
eac61af6 | 274 | extern void _bfd_unlink_from_archive_parent (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 275 | #define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true |
0a1b45a2 | 276 | extern bool _bfd_generic_new_section_hook |
8722de9c | 277 | (bfd *, asection *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 278 | extern bool _bfd_generic_get_section_contents |
8722de9c | 279 | (bfd *, asection *, void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 280 | extern bool _bfd_generic_get_section_contents_in_window |
8722de9c | 281 | (bfd *, asection *, bfd_window *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN; |
252b5132 RH |
282 | |
283 | /* Generic routines to use for BFD_JUMP_TABLE_COPY. Use | |
284 | BFD_JUMP_TABLE_COPY (_bfd_generic). */ | |
285 | ||
d00dd7dc | 286 | #define _bfd_generic_bfd_copy_private_bfd_data _bfd_bool_bfd_bfd_true |
252b5132 | 287 | #define _bfd_generic_bfd_merge_private_bfd_data \ |
d00dd7dc AM |
288 | _bfd_bool_bfd_link_true |
289 | #define _bfd_generic_bfd_set_private_flags _bfd_bool_bfd_uint_true | |
252b5132 | 290 | #define _bfd_generic_bfd_copy_private_section_data \ |
d00dd7dc | 291 | _bfd_bool_bfd_asection_bfd_asection_true |
252b5132 | 292 | #define _bfd_generic_bfd_copy_private_symbol_data \ |
d00dd7dc AM |
293 | _bfd_bool_bfd_asymbol_bfd_asymbol_true |
294 | #define _bfd_generic_bfd_copy_private_header_data _bfd_bool_bfd_bfd_true | |
295 | #define _bfd_generic_bfd_print_private_bfd_data _bfd_bool_bfd_ptr_true | |
252b5132 | 296 | |
0a1b45a2 | 297 | extern bool _bfd_generic_init_private_section_data |
8722de9c AM |
298 | (bfd *, asection *, bfd *, asection *, struct bfd_link_info *) |
299 | ATTRIBUTE_HIDDEN; | |
ccd2ec6a | 300 | |
252b5132 RH |
301 | /* Routines to use for BFD_JUMP_TABLE_CORE when there is no core file |
302 | support. Use BFD_JUMP_TABLE_CORE (_bfd_nocore). */ | |
303 | ||
b34976b6 | 304 | extern char *_bfd_nocore_core_file_failing_command |
8722de9c | 305 | (bfd *) ATTRIBUTE_HIDDEN; |
b34976b6 | 306 | extern int _bfd_nocore_core_file_failing_signal |
8722de9c | 307 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 308 | extern bool _bfd_nocore_core_file_matches_executable_p |
8722de9c | 309 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; |
261b8d08 | 310 | extern int _bfd_nocore_core_file_pid |
8722de9c | 311 | (bfd *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
312 | |
313 | /* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive | |
314 | file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */ | |
315 | ||
d00dd7dc AM |
316 | #define _bfd_noarchive_slurp_armap _bfd_bool_bfd_false_error |
317 | #define _bfd_noarchive_slurp_extended_name_table _bfd_bool_bfd_false_error | |
0a1b45a2 | 318 | extern bool _bfd_noarchive_construct_extended_name_table |
8722de9c | 319 | (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN; |
d00dd7dc | 320 | extern void _bfd_noarchive_truncate_arname |
8722de9c | 321 | (bfd *, const char *, char *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 322 | extern bool _bfd_noarchive_write_armap |
8722de9c | 323 | (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN; |
d00dd7dc | 324 | #define _bfd_noarchive_read_ar_hdr _bfd_ptr_bfd_null_error |
0a1b45a2 | 325 | extern bool _bfd_noarchive_write_ar_hdr |
8722de9c | 326 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc AM |
327 | extern bfd * |
328 | _bfd_noarchive_openr_next_archived_file | |
8722de9c | 329 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 330 | extern bfd * _bfd_noarchive_get_elt_at_index |
8722de9c | 331 | (bfd *, symindex) ATTRIBUTE_HIDDEN; |
252b5132 | 332 | #define _bfd_noarchive_generic_stat_arch_elt bfd_generic_stat_arch_elt |
d00dd7dc | 333 | #define _bfd_noarchive_update_armap_timestamp _bfd_bool_bfd_false_error |
252b5132 RH |
334 | |
335 | /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD style | |
336 | archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd). */ | |
337 | ||
338 | #define _bfd_archive_bsd_slurp_armap bfd_slurp_bsd_armap | |
339 | #define _bfd_archive_bsd_slurp_extended_name_table \ | |
340 | _bfd_slurp_extended_name_table | |
0a1b45a2 | 341 | extern bool _bfd_archive_bsd_construct_extended_name_table |
8722de9c | 342 | (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN; |
252b5132 | 343 | #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname |
7ec22e0f | 344 | #define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap |
252b5132 | 345 | #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr |
8f95b6e4 | 346 | #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr |
252b5132 RH |
347 | #define _bfd_archive_bsd_openr_next_archived_file \ |
348 | bfd_generic_openr_next_archived_file | |
349 | #define _bfd_archive_bsd_get_elt_at_index _bfd_generic_get_elt_at_index | |
350 | #define _bfd_archive_bsd_generic_stat_arch_elt \ | |
351 | bfd_generic_stat_arch_elt | |
0a1b45a2 | 352 | extern bool _bfd_archive_bsd_update_armap_timestamp |
8722de9c | 353 | (bfd *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
354 | |
355 | /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get COFF style | |
356 | archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff). */ | |
357 | ||
358 | #define _bfd_archive_coff_slurp_armap bfd_slurp_coff_armap | |
359 | #define _bfd_archive_coff_slurp_extended_name_table \ | |
360 | _bfd_slurp_extended_name_table | |
0a1b45a2 | 361 | extern bool _bfd_archive_coff_construct_extended_name_table |
8722de9c | 362 | (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN; |
252b5132 | 363 | #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname |
7ec22e0f | 364 | #define _bfd_archive_coff_write_armap _bfd_coff_write_armap |
252b5132 | 365 | #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr |
8f95b6e4 | 366 | #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr |
252b5132 RH |
367 | #define _bfd_archive_coff_openr_next_archived_file \ |
368 | bfd_generic_openr_next_archived_file | |
369 | #define _bfd_archive_coff_get_elt_at_index _bfd_generic_get_elt_at_index | |
370 | #define _bfd_archive_coff_generic_stat_arch_elt \ | |
371 | bfd_generic_stat_arch_elt | |
d00dd7dc | 372 | #define _bfd_archive_coff_update_armap_timestamp _bfd_bool_bfd_true |
252b5132 | 373 | |
8f95b6e4 TG |
374 | /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get BSD4.4 style |
375 | archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_bsd44). */ | |
376 | ||
377 | #define _bfd_archive_bsd44_slurp_armap bfd_slurp_bsd_armap | |
378 | #define _bfd_archive_bsd44_slurp_extended_name_table \ | |
379 | _bfd_slurp_extended_name_table | |
0a1b45a2 | 380 | extern bool _bfd_archive_bsd44_construct_extended_name_table |
8722de9c | 381 | (bfd *, char **, bfd_size_type *, const char **) ATTRIBUTE_HIDDEN; |
8f95b6e4 | 382 | #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname |
7ec22e0f | 383 | #define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap |
8f95b6e4 TG |
384 | #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr |
385 | #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr | |
386 | #define _bfd_archive_bsd44_openr_next_archived_file \ | |
387 | bfd_generic_openr_next_archived_file | |
388 | #define _bfd_archive_bsd44_get_elt_at_index _bfd_generic_get_elt_at_index | |
389 | #define _bfd_archive_bsd44_generic_stat_arch_elt \ | |
390 | bfd_generic_stat_arch_elt | |
391 | #define _bfd_archive_bsd44_update_armap_timestamp \ | |
392 | _bfd_archive_bsd_update_armap_timestamp | |
393 | ||
4b544b64 TG |
394 | /* Routines to use for BFD_JUMP_TABLE_ARCHIVE to get VMS style |
395 | archives. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_vms_lib). Some of them | |
f0d19df9 | 396 | are irrelevant. */ |
4b544b64 | 397 | |
0a1b45a2 | 398 | extern bool _bfd_vms_lib_write_archive_contents |
8722de9c | 399 | (bfd *) ATTRIBUTE_HIDDEN; |
f0d19df9 AM |
400 | #define _bfd_vms_lib_slurp_armap _bfd_noarchive_slurp_armap |
401 | #define _bfd_vms_lib_slurp_extended_name_table \ | |
402 | _bfd_noarchive_slurp_extended_name_table | |
403 | #define _bfd_vms_lib_construct_extended_name_table \ | |
404 | _bfd_noarchive_construct_extended_name_table | |
405 | #define _bfd_vms_lib_truncate_arname _bfd_noarchive_truncate_arname | |
406 | #define _bfd_vms_lib_write_armap _bfd_noarchive_write_armap | |
407 | #define _bfd_vms_lib_read_ar_hdr _bfd_noarchive_read_ar_hdr | |
408 | #define _bfd_vms_lib_write_ar_hdr _bfd_noarchive_write_ar_hdr | |
8722de9c AM |
409 | extern bfd *_bfd_vms_lib_openr_next_archived_file |
410 | (bfd *, bfd *) ATTRIBUTE_HIDDEN; | |
411 | extern bfd *_bfd_vms_lib_get_elt_at_index | |
412 | (bfd *, symindex) ATTRIBUTE_HIDDEN; | |
413 | extern int _bfd_vms_lib_generic_stat_arch_elt | |
414 | (bfd *, struct stat *) ATTRIBUTE_HIDDEN; | |
d00dd7dc | 415 | #define _bfd_vms_lib_update_armap_timestamp _bfd_bool_bfd_true |
4b544b64 TG |
416 | |
417 | /* Extra routines for VMS style archives. */ | |
418 | ||
8722de9c AM |
419 | extern symindex _bfd_vms_lib_find_symbol |
420 | (bfd *, const char *) ATTRIBUTE_HIDDEN; | |
421 | extern bfd *_bfd_vms_lib_get_imagelib_file | |
422 | (bfd *) ATTRIBUTE_HIDDEN; | |
cb001c0d | 423 | extern bfd_cleanup _bfd_vms_lib_alpha_archive_p |
8722de9c | 424 | (bfd *) ATTRIBUTE_HIDDEN; |
cb001c0d | 425 | extern bfd_cleanup _bfd_vms_lib_ia64_archive_p |
8722de9c | 426 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 427 | extern bool _bfd_vms_lib_alpha_mkarchive |
8722de9c | 428 | (bfd *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 429 | extern bool _bfd_vms_lib_ia64_mkarchive |
8722de9c | 430 | (bfd *) ATTRIBUTE_HIDDEN; |
4b544b64 | 431 | |
252b5132 RH |
432 | /* Routines to use for BFD_JUMP_TABLE_SYMBOLS where there is no symbol |
433 | support. Use BFD_JUMP_TABLE_SYMBOLS (_bfd_nosymbols). */ | |
434 | ||
d00dd7dc AM |
435 | #define _bfd_nosymbols_get_symtab_upper_bound _bfd_long_bfd_n1_error |
436 | extern long _bfd_nosymbols_canonicalize_symtab | |
8722de9c | 437 | (bfd *, asymbol **) ATTRIBUTE_HIDDEN; |
3f3c5c34 | 438 | #define _bfd_nosymbols_make_empty_symbol _bfd_generic_make_empty_symbol |
d00dd7dc | 439 | extern void _bfd_nosymbols_print_symbol |
8722de9c | 440 | (bfd *, void *, asymbol *, bfd_print_symbol_type) ATTRIBUTE_HIDDEN; |
d00dd7dc | 441 | extern void _bfd_nosymbols_get_symbol_info |
8722de9c | 442 | (bfd *, asymbol *, symbol_info *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 443 | extern const char * _bfd_nosymbols_get_symbol_version_string |
0a1b45a2 AM |
444 | (bfd *, asymbol *, bool, bool *) ATTRIBUTE_HIDDEN; |
445 | extern bool _bfd_nosymbols_bfd_is_local_label_name | |
8722de9c | 446 | (bfd *, const char *) ATTRIBUTE_HIDDEN; |
d00dd7dc AM |
447 | #define _bfd_nosymbols_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false |
448 | extern alent *_bfd_nosymbols_get_lineno | |
8722de9c | 449 | (bfd *, asymbol *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 450 | extern bool _bfd_nosymbols_find_nearest_line |
d00dd7dc | 451 | (bfd *, asymbol **, asection *, bfd_vma, |
8722de9c AM |
452 | const char **, const char **, unsigned int *, unsigned int *) |
453 | ATTRIBUTE_HIDDEN; | |
6e7a29c7 AM |
454 | extern bool _bfd_nosymbols_find_nearest_line_with_alt |
455 | (bfd *, const char *, asymbol **, asection *, bfd_vma, | |
456 | const char **, const char **, unsigned int *, unsigned int *) | |
457 | ATTRIBUTE_HIDDEN; | |
0a1b45a2 | 458 | extern bool _bfd_nosymbols_find_line |
8722de9c AM |
459 | (bfd *, asymbol **, asymbol *, const char **, unsigned int *) |
460 | ATTRIBUTE_HIDDEN; | |
0a1b45a2 | 461 | extern bool _bfd_nosymbols_find_inliner_info |
8722de9c | 462 | (bfd *, const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 463 | extern asymbol *_bfd_nosymbols_bfd_make_debug_symbol |
8722de9c | 464 | (bfd *, void *, unsigned long) ATTRIBUTE_HIDDEN; |
d00dd7dc | 465 | extern long _bfd_nosymbols_read_minisymbols |
0a1b45a2 | 466 | (bfd *, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 467 | extern asymbol *_bfd_nosymbols_minisymbol_to_symbol |
0a1b45a2 | 468 | (bfd *, bool, const void *, asymbol *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
469 | |
470 | /* Routines to use for BFD_JUMP_TABLE_RELOCS when there is no reloc | |
471 | support. Use BFD_JUMP_TABLE_RELOCS (_bfd_norelocs). */ | |
472 | ||
8722de9c AM |
473 | extern long _bfd_norelocs_get_reloc_upper_bound |
474 | (bfd *, asection *) ATTRIBUTE_HIDDEN; | |
475 | extern long _bfd_norelocs_canonicalize_reloc | |
476 | (bfd *, asection *, arelent **, asymbol **) ATTRIBUTE_HIDDEN; | |
477 | extern void _bfd_norelocs_set_reloc | |
478 | (bfd *, asection *, arelent **, unsigned int) ATTRIBUTE_HIDDEN; | |
d00dd7dc | 479 | extern reloc_howto_type *_bfd_norelocs_bfd_reloc_type_lookup |
8722de9c | 480 | (bfd *, bfd_reloc_code_real_type) ATTRIBUTE_HIDDEN; |
d00dd7dc | 481 | extern reloc_howto_type *_bfd_norelocs_bfd_reloc_name_lookup |
8722de9c | 482 | (bfd *, const char *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
483 | |
484 | /* Routines to use for BFD_JUMP_TABLE_WRITE for targets which may not | |
485 | be written. Use BFD_JUMP_TABLE_WRITE (_bfd_nowrite). */ | |
486 | ||
0a1b45a2 | 487 | extern bool _bfd_nowrite_set_arch_mach |
8722de9c | 488 | (bfd *, enum bfd_architecture, unsigned long) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 489 | extern bool _bfd_nowrite_set_section_contents |
8722de9c | 490 | (bfd *, asection *, const void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN; |
252b5132 RH |
491 | |
492 | /* Generic routines to use for BFD_JUMP_TABLE_WRITE. Use | |
493 | BFD_JUMP_TABLE_WRITE (_bfd_generic). */ | |
494 | ||
495 | #define _bfd_generic_set_arch_mach bfd_default_set_arch_mach | |
0a1b45a2 | 496 | extern bool _bfd_generic_set_section_contents |
8722de9c | 497 | (bfd *, asection *, const void *, file_ptr, bfd_size_type) ATTRIBUTE_HIDDEN; |
252b5132 RH |
498 | |
499 | /* Routines to use for BFD_JUMP_TABLE_LINK for targets which do not | |
500 | support linking. Use BFD_JUMP_TABLE_LINK (_bfd_nolink). */ | |
501 | ||
d00dd7dc | 502 | extern int _bfd_nolink_sizeof_headers |
8722de9c | 503 | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
d00dd7dc AM |
504 | extern bfd_byte *_bfd_nolink_bfd_get_relocated_section_contents |
505 | (bfd *, struct bfd_link_info *, struct bfd_link_order *, | |
0a1b45a2 AM |
506 | bfd_byte *, bool, asymbol **) ATTRIBUTE_HIDDEN; |
507 | extern bool _bfd_nolink_bfd_relax_section | |
508 | (bfd *, asection *, struct bfd_link_info *, bool *) ATTRIBUTE_HIDDEN; | |
d00dd7dc | 509 | #define _bfd_nolink_bfd_gc_sections _bfd_bool_bfd_link_false_error |
0a1b45a2 | 510 | extern bool _bfd_nolink_bfd_lookup_section_flags |
8722de9c | 511 | (struct bfd_link_info *, struct flag_info *, asection *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 512 | #define _bfd_nolink_bfd_merge_sections _bfd_bool_bfd_link_false_error |
0a1b45a2 | 513 | extern bool _bfd_nolink_bfd_is_group_section |
8722de9c | 514 | (bfd *, const asection *) ATTRIBUTE_HIDDEN; |
cb7f4b29 AM |
515 | extern const char *_bfd_nolink_bfd_group_name |
516 | (bfd *, const asection *) ATTRIBUTE_HIDDEN; | |
0a1b45a2 | 517 | extern bool _bfd_nolink_bfd_discard_group |
8722de9c | 518 | (bfd *, asection *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 519 | extern struct bfd_link_hash_table *_bfd_nolink_bfd_link_hash_table_create |
8722de9c | 520 | (bfd *) ATTRIBUTE_HIDDEN; |
d00dd7dc AM |
521 | #define _bfd_nolink_bfd_link_add_symbols _bfd_bool_bfd_link_false_error |
522 | extern void _bfd_nolink_bfd_link_just_syms | |
8722de9c | 523 | (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
d00dd7dc | 524 | extern void _bfd_nolink_bfd_copy_link_hash_symbol_type |
8722de9c AM |
525 | (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *) |
526 | ATTRIBUTE_HIDDEN; | |
d00dd7dc | 527 | #define _bfd_nolink_bfd_final_link _bfd_bool_bfd_link_false_error |
0a1b45a2 | 528 | extern bool _bfd_nolink_bfd_link_split_section |
8722de9c | 529 | (bfd *, struct bfd_section *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 530 | extern bool _bfd_nolink_section_already_linked |
8722de9c | 531 | (bfd *, asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 532 | extern bool _bfd_nolink_bfd_define_common_symbol |
8722de9c AM |
533 | (bfd *, struct bfd_link_info *, struct bfd_link_hash_entry *) |
534 | ATTRIBUTE_HIDDEN; | |
34a87bb0 L |
535 | #define _bfd_nolink_bfd_link_hide_symbol \ |
536 | _bfd_generic_link_hide_symbol | |
d00dd7dc | 537 | extern struct bfd_link_hash_entry *_bfd_nolink_bfd_define_start_stop |
8722de9c | 538 | (struct bfd_link_info *, const char *, asection *) ATTRIBUTE_HIDDEN; |
4f3b23b3 NC |
539 | #define _bfd_nolink_bfd_link_check_relocs \ |
540 | _bfd_generic_link_check_relocs | |
252b5132 RH |
541 | |
542 | /* Routines to use for BFD_JUMP_TABLE_DYNAMIC for targets which do not | |
543 | have dynamic symbols or relocs. Use BFD_JUMP_TABLE_DYNAMIC | |
544 | (_bfd_nodynamic). */ | |
545 | ||
d00dd7dc | 546 | #define _bfd_nodynamic_get_dynamic_symtab_upper_bound _bfd_long_bfd_n1_error |
252b5132 | 547 | #define _bfd_nodynamic_canonicalize_dynamic_symtab \ |
d00dd7dc AM |
548 | _bfd_nosymbols_canonicalize_symtab |
549 | extern long _bfd_nodynamic_get_synthetic_symtab | |
8722de9c | 550 | (bfd *, long, asymbol **, long, asymbol **, asymbol **) ATTRIBUTE_HIDDEN; |
d00dd7dc AM |
551 | #define _bfd_nodynamic_get_dynamic_reloc_upper_bound _bfd_long_bfd_n1_error |
552 | extern long _bfd_nodynamic_canonicalize_dynamic_reloc | |
8722de9c | 553 | (bfd *, arelent **, asymbol **) ATTRIBUTE_HIDDEN; |
252b5132 RH |
554 | \f |
555 | /* Generic routine to determine of the given symbol is a local | |
556 | label. */ | |
0a1b45a2 | 557 | extern bool bfd_generic_is_local_label_name |
8722de9c | 558 | (bfd *, const char *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
559 | |
560 | /* Generic minisymbol routines. */ | |
561 | extern long _bfd_generic_read_minisymbols | |
0a1b45a2 | 562 | (bfd *, bool, void **, unsigned int *) ATTRIBUTE_HIDDEN; |
252b5132 | 563 | extern asymbol *_bfd_generic_minisymbol_to_symbol |
0a1b45a2 | 564 | (bfd *, bool, const void *, asymbol *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
565 | |
566 | /* Find the nearest line using .stab/.stabstr sections. */ | |
0a1b45a2 AM |
567 | extern bool _bfd_stab_section_find_nearest_line |
568 | (bfd *, asymbol **, asection *, bfd_vma, bool *, | |
8722de9c | 569 | const char **, const char **, unsigned int *, void **) ATTRIBUTE_HIDDEN; |
252b5132 | 570 | |
2db3311b | 571 | /* Find the nearest line using DWARF 1 debugging information. */ |
0a1b45a2 | 572 | extern bool _bfd_dwarf1_find_nearest_line |
fb167eb2 | 573 | (bfd *, asymbol **, asection *, bfd_vma, |
8722de9c | 574 | const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN; |
252b5132 | 575 | |
fc28f9aa TG |
576 | struct dwarf_debug_section |
577 | { | |
68d20676 NC |
578 | const char * uncompressed_name; |
579 | const char * compressed_name; | |
fc28f9aa TG |
580 | }; |
581 | ||
582 | /* Map of uncompressed DWARF debug section name to compressed one. It | |
583 | is terminated by NULL uncompressed_name. */ | |
584 | ||
8722de9c | 585 | extern const struct dwarf_debug_section dwarf_debug_sections[] ATTRIBUTE_HIDDEN; |
fc28f9aa | 586 | |
252b5132 | 587 | /* Find the nearest line using DWARF 2 debugging information. */ |
7f3bf384 | 588 | extern int _bfd_dwarf2_find_nearest_line |
fb167eb2 AM |
589 | (bfd *, asymbol **, asymbol *, asection *, bfd_vma, |
590 | const char **, const char **, unsigned int *, unsigned int *, | |
9defd221 | 591 | const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN; |
6e7a29c7 AM |
592 | |
593 | /* Find the nearest line using DWARF 2 debugging information, with | |
594 | the option of specifying a .gnu_debugaltlink file. */ | |
595 | extern int _bfd_dwarf2_find_nearest_line_with_alt | |
596 | (bfd *, const char *, asymbol **, asymbol *, asection *, bfd_vma, | |
597 | const char **, const char **, unsigned int *, unsigned int *, | |
598 | const struct dwarf_debug_section *, void **) ATTRIBUTE_HIDDEN; | |
9b8d1a36 | 599 | |
425bd9e1 NC |
600 | /* Find the bias between DWARF addresses and real addresses. */ |
601 | extern bfd_signed_vma _bfd_dwarf2_find_symbol_bias | |
8722de9c | 602 | (asymbol **, void **) ATTRIBUTE_HIDDEN; |
1b786873 | 603 | |
4ab527b0 | 604 | /* Find inliner info after calling bfd_find_nearest_line. */ |
0a1b45a2 | 605 | extern bool _bfd_dwarf2_find_inliner_info |
8722de9c AM |
606 | (bfd *, const char **, const char **, unsigned int *, void **) |
607 | ATTRIBUTE_HIDDEN; | |
d9071b0c | 608 | |
2ca7691a | 609 | /* Read DWARF 2 debugging information. */ |
0a1b45a2 | 610 | extern bool _bfd_dwarf2_slurp_debug_info |
93ee1e36 | 611 | (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **, |
0a1b45a2 | 612 | bool) ATTRIBUTE_HIDDEN; |
2ca7691a | 613 | |
d9071b0c TG |
614 | /* Clean up the data used to handle DWARF 2 debugging information. */ |
615 | extern void _bfd_dwarf2_cleanup_debug_info | |
8722de9c | 616 | (bfd *, void **) ATTRIBUTE_HIDDEN; |
d9071b0c | 617 | |
f3bc6035 AM |
618 | extern void _bfd_stab_cleanup |
619 | (bfd *, void **) ATTRIBUTE_HIDDEN; | |
620 | ||
73e87d70 AM |
621 | /* Create a new section entry. */ |
622 | extern struct bfd_hash_entry *bfd_section_hash_newfunc | |
8722de9c AM |
623 | (struct bfd_hash_entry *, struct bfd_hash_table *, const char *) |
624 | ATTRIBUTE_HIDDEN; | |
73e87d70 | 625 | |
252b5132 RH |
626 | /* A routine to create entries for a bfd_link_hash_table. */ |
627 | extern struct bfd_hash_entry *_bfd_link_hash_newfunc | |
c58b9523 | 628 | (struct bfd_hash_entry *entry, struct bfd_hash_table *table, |
8722de9c | 629 | const char *string) ATTRIBUTE_HIDDEN; |
252b5132 RH |
630 | |
631 | /* Initialize a bfd_link_hash_table. */ | |
0a1b45a2 | 632 | extern bool _bfd_link_hash_table_init |
c58b9523 AM |
633 | (struct bfd_link_hash_table *, bfd *, |
634 | struct bfd_hash_entry *(*) (struct bfd_hash_entry *, | |
635 | struct bfd_hash_table *, | |
66eb6687 | 636 | const char *), |
8722de9c | 637 | unsigned int) ATTRIBUTE_HIDDEN; |
252b5132 RH |
638 | |
639 | /* Generic link hash table creation routine. */ | |
640 | extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create | |
8722de9c | 641 | (bfd *) ATTRIBUTE_HIDDEN; |
252b5132 | 642 | |
e2d34d7d DJ |
643 | /* Generic link hash table destruction routine. */ |
644 | extern void _bfd_generic_link_hash_table_free | |
8722de9c | 645 | (bfd *) ATTRIBUTE_HIDDEN; |
e2d34d7d | 646 | |
252b5132 | 647 | /* Generic add symbol routine. */ |
0a1b45a2 | 648 | extern bool _bfd_generic_link_add_symbols |
8722de9c | 649 | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
252b5132 | 650 | |
252b5132 | 651 | /* Generic archive add symbol routine. */ |
0a1b45a2 | 652 | extern bool _bfd_generic_link_add_archive_symbols |
c58b9523 | 653 | (bfd *, struct bfd_link_info *, |
0a1b45a2 | 654 | bool (*) (bfd *, struct bfd_link_info *, |
13e570f8 | 655 | struct bfd_link_hash_entry *, const char *, |
0a1b45a2 | 656 | bool *)) ATTRIBUTE_HIDDEN; |
252b5132 | 657 | |
252b5132 RH |
658 | /* Forward declaration to avoid prototype errors. */ |
659 | typedef struct bfd_link_hash_entry _bfd_link_hash_entry; | |
660 | ||
661 | /* Generic routine to add a single symbol. */ | |
0a1b45a2 | 662 | extern bool _bfd_generic_link_add_one_symbol |
c58b9523 | 663 | (struct bfd_link_info *, bfd *, const char *name, flagword, |
0a1b45a2 AM |
664 | asection *, bfd_vma, const char *, bool copy, |
665 | bool constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN; | |
252b5132 | 666 | |
2d653fc7 AM |
667 | /* Generic routine to mark section as supplying symbols only. */ |
668 | extern void _bfd_generic_link_just_syms | |
8722de9c | 669 | (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
2d653fc7 | 670 | |
1338dd10 PB |
671 | /* Generic routine that does nothing. */ |
672 | extern void _bfd_generic_copy_link_hash_symbol_type | |
8722de9c AM |
673 | (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *) |
674 | ATTRIBUTE_HIDDEN; | |
1338dd10 | 675 | |
252b5132 | 676 | /* Generic link routine. */ |
0a1b45a2 | 677 | extern bool _bfd_generic_final_link |
8722de9c | 678 | (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
252b5132 | 679 | |
0a1b45a2 | 680 | extern bool _bfd_generic_link_split_section |
8722de9c | 681 | (bfd *, struct bfd_section *) ATTRIBUTE_HIDDEN; |
252b5132 | 682 | |
0a1b45a2 | 683 | extern bool _bfd_generic_section_already_linked |
8722de9c | 684 | (bfd *, asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; |
082b7297 | 685 | |
252b5132 | 686 | /* Generic reloc_link_order processing routine. */ |
0a1b45a2 | 687 | extern bool _bfd_generic_reloc_link_order |
8722de9c AM |
688 | (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *) |
689 | ATTRIBUTE_HIDDEN; | |
252b5132 RH |
690 | |
691 | /* Default link order processing routine. */ | |
0a1b45a2 | 692 | extern bool _bfd_default_link_order |
8722de9c AM |
693 | (bfd *, struct bfd_link_info *, asection *, struct bfd_link_order *) |
694 | ATTRIBUTE_HIDDEN; | |
252b5132 RH |
695 | |
696 | /* Count the number of reloc entries in a link order list. */ | |
697 | extern unsigned int _bfd_count_link_order_relocs | |
8722de9c | 698 | (struct bfd_link_order *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
699 | |
700 | /* Final link relocation routine. */ | |
701 | extern bfd_reloc_status_type _bfd_final_link_relocate | |
c58b9523 | 702 | (reloc_howto_type *, bfd *, asection *, bfd_byte *, |
8722de9c | 703 | bfd_vma, bfd_vma, bfd_vma) ATTRIBUTE_HIDDEN; |
252b5132 RH |
704 | |
705 | /* Relocate a particular location by a howto and a value. */ | |
706 | extern bfd_reloc_status_type _bfd_relocate_contents | |
8722de9c | 707 | (reloc_howto_type *, bfd *, bfd_vma, bfd_byte *) ATTRIBUTE_HIDDEN; |
252b5132 | 708 | |
b1e24c02 | 709 | /* Clear a given location using a given howto. */ |
0930cb30 AM |
710 | extern bfd_reloc_status_type _bfd_clear_contents |
711 | (reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN; | |
b1e24c02 | 712 | |
252b5132 RH |
713 | /* Link stabs in sections in the first pass. */ |
714 | ||
0a1b45a2 | 715 | extern bool _bfd_link_section_stabs |
3722b82f | 716 | (bfd *, struct stab_info *, asection *, asection *, void **, |
8722de9c | 717 | bfd_size_type *) ATTRIBUTE_HIDDEN; |
252b5132 | 718 | |
73d074b4 | 719 | /* Eliminate stabs for discarded functions and symbols. */ |
0a1b45a2 AM |
720 | extern bool _bfd_discard_section_stabs |
721 | (bfd *, asection *, void *, bool (*) (bfd_vma, void *), void *) | |
8722de9c | 722 | ATTRIBUTE_HIDDEN; |
73d074b4 | 723 | |
252b5132 RH |
724 | /* Write out the .stab section when linking stabs in sections. */ |
725 | ||
0a1b45a2 | 726 | extern bool _bfd_write_section_stabs |
8722de9c AM |
727 | (bfd *, struct stab_info *, asection *, void **, bfd_byte *) |
728 | ATTRIBUTE_HIDDEN; | |
252b5132 RH |
729 | |
730 | /* Write out the .stabstr string table when linking stabs in sections. */ | |
731 | ||
0a1b45a2 | 732 | extern bool _bfd_write_stab_strings |
8722de9c | 733 | (bfd *, struct stab_info *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
734 | |
735 | /* Find an offset within a .stab section when linking stabs in | |
736 | sections. */ | |
737 | ||
738 | extern bfd_vma _bfd_stab_section_offset | |
8722de9c | 739 | (asection *, void *, bfd_vma) ATTRIBUTE_HIDDEN; |
252b5132 | 740 | |
57ceae94 | 741 | /* Register a SEC_MERGE section as a candidate for merging. */ |
f5fa8ca2 | 742 | |
0a1b45a2 | 743 | extern bool _bfd_add_merge_section |
8722de9c | 744 | (bfd *, void **, asection *, void **) ATTRIBUTE_HIDDEN; |
f5fa8ca2 | 745 | |
8550eb6e JJ |
746 | /* Attempt to merge SEC_MERGE sections. */ |
747 | ||
0a1b45a2 | 748 | extern bool _bfd_merge_sections |
8722de9c AM |
749 | (bfd *, struct bfd_link_info *, void *, void (*) (bfd *, asection *)) |
750 | ATTRIBUTE_HIDDEN; | |
8550eb6e | 751 | |
f5fa8ca2 JJ |
752 | /* Write out a merged section. */ |
753 | ||
0a1b45a2 | 754 | extern bool _bfd_write_merged_section |
8722de9c | 755 | (bfd *, asection *, void *) ATTRIBUTE_HIDDEN; |
f5fa8ca2 JJ |
756 | |
757 | /* Find an offset within a modified SEC_MERGE section. */ | |
758 | ||
759 | extern bfd_vma _bfd_merged_section_offset | |
8722de9c | 760 | (bfd *, asection **, void *, bfd_vma) ATTRIBUTE_HIDDEN; |
f5fa8ca2 | 761 | |
9f7c3e5e AM |
762 | /* Tidy up when done. */ |
763 | ||
8722de9c | 764 | extern void _bfd_merge_sections_free (void *) ATTRIBUTE_HIDDEN; |
9f7c3e5e | 765 | |
252b5132 | 766 | /* Create a string table. */ |
b34976b6 | 767 | extern struct bfd_strtab_hash *_bfd_stringtab_init |
8722de9c | 768 | (void) ATTRIBUTE_HIDDEN; |
252b5132 RH |
769 | |
770 | /* Create an XCOFF .debug section style string table. */ | |
b34976b6 | 771 | extern struct bfd_strtab_hash *_bfd_xcoff_stringtab_init |
bdd2aaf6 | 772 | (bool isxcoff64) ATTRIBUTE_HIDDEN; |
252b5132 RH |
773 | |
774 | /* Free a string table. */ | |
b34976b6 | 775 | extern void _bfd_stringtab_free |
8722de9c | 776 | (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
777 | |
778 | /* Get the size of a string table. */ | |
b34976b6 | 779 | extern bfd_size_type _bfd_stringtab_size |
8722de9c | 780 | (struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
781 | |
782 | /* Add a string to a string table. */ | |
783 | extern bfd_size_type _bfd_stringtab_add | |
0a1b45a2 | 784 | (struct bfd_strtab_hash *, const char *, bool hash, bool copy) |
8722de9c | 785 | ATTRIBUTE_HIDDEN; |
252b5132 RH |
786 | |
787 | /* Write out a string table. */ | |
0a1b45a2 | 788 | extern bool _bfd_stringtab_emit |
8722de9c | 789 | (bfd *, struct bfd_strtab_hash *) ATTRIBUTE_HIDDEN; |
252b5132 RH |
790 | \f |
791 | /* Macros to tell if bfds are read or write enabled. | |
792 | ||
793 | Note that bfds open for read may be scribbled into if the fd passed | |
794 | to bfd_fdopenr is actually open both for read and write | |
795 | simultaneously. However an output bfd will never be open for | |
796 | read. Therefore sometimes you want to check bfd_read_p or | |
797 | !bfd_read_p, and only sometimes bfd_write_p. | |
798 | */ | |
799 | ||
c58b9523 AM |
800 | #define bfd_read_p(abfd) \ |
801 | ((abfd)->direction == read_direction || (abfd)->direction == both_direction) | |
802 | #define bfd_write_p(abfd) \ | |
803 | ((abfd)->direction == write_direction || (abfd)->direction == both_direction) | |
252b5132 | 804 | |
8722de9c AM |
805 | extern void bfd_assert |
806 | (const char*,int) ATTRIBUTE_HIDDEN; | |
252b5132 RH |
807 | |
808 | #define BFD_ASSERT(x) \ | |
f12123c0 | 809 | do { if (!(x)) bfd_assert(__FILE__,__LINE__); } while (0) |
252b5132 RH |
810 | |
811 | #define BFD_FAIL() \ | |
f12123c0 | 812 | do { bfd_assert(__FILE__,__LINE__); } while (0) |
252b5132 | 813 | |
b34976b6 | 814 | extern void _bfd_abort |
8722de9c | 815 | (const char *, int, const char *) ATTRIBUTE_NORETURN ATTRIBUTE_HIDDEN; |
c0bed66d | 816 | |
a1934524 AM |
817 | /* if gcc >= 2.6, we can give a function name, too */ |
818 | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) | |
c0bed66d ILT |
819 | #define __PRETTY_FUNCTION__ ((char *) NULL) |
820 | #endif | |
821 | ||
822 | #undef abort | |
823 | #define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__) | |
824 | ||
7c192733 AC |
825 | /* Manipulate a system FILE but using BFD's "file_ptr", rather than |
826 | the system "off_t" or "off64_t", as the offset. */ | |
8722de9c AM |
827 | extern file_ptr _bfd_real_ftell |
828 | (FILE *) ATTRIBUTE_HIDDEN; | |
829 | extern int _bfd_real_fseek | |
830 | (FILE *, file_ptr, int) ATTRIBUTE_HIDDEN; | |
831 | extern FILE *_bfd_real_fopen | |
832 | (const char *, const char *) ATTRIBUTE_HIDDEN; | |
7c192733 | 833 | |
252b5132 RH |
834 | /* List of supported target vectors, and the default vector (if |
835 | bfd_default_vector[0] is NULL, there is no default). */ | |
bd38246a | 836 | extern const bfd_target *const *const bfd_target_vector ATTRIBUTE_HIDDEN; |
8722de9c | 837 | extern const bfd_target *bfd_default_vector[] ATTRIBUTE_HIDDEN; |
252b5132 | 838 | |
08f74004 | 839 | /* List of associated target vectors. */ |
bd38246a | 840 | extern const bfd_target *const *const bfd_associated_vector ATTRIBUTE_HIDDEN; |
08f74004 | 841 | |
252b5132 RH |
842 | /* Functions shared by the ECOFF and MIPS ELF backends, which have no |
843 | other common header files. */ | |
844 | ||
845 | #if defined(__STDC__) || defined(ALMOST_STDC) | |
846 | struct ecoff_find_line; | |
847 | #endif | |
848 | ||
0a1b45a2 | 849 | extern bool _bfd_ecoff_locate_line |
c58b9523 AM |
850 | (bfd *, asection *, bfd_vma, struct ecoff_debug_info * const, |
851 | const struct ecoff_debug_swap * const, struct ecoff_find_line *, | |
8722de9c | 852 | const char **, const char **, unsigned int *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 853 | extern bool _bfd_ecoff_get_accumulated_pdr |
8722de9c | 854 | (void *, bfd_byte *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 855 | extern bool _bfd_ecoff_get_accumulated_sym |
8722de9c | 856 | (void *, bfd_byte *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 857 | extern bool _bfd_ecoff_get_accumulated_ss |
8722de9c | 858 | (void *, bfd_byte *) ATTRIBUTE_HIDDEN; |
b34976b6 AM |
859 | |
860 | extern bfd_vma _bfd_get_gp_value | |
8722de9c | 861 | (bfd *) ATTRIBUTE_HIDDEN; |
b34976b6 | 862 | extern void _bfd_set_gp_value |
8722de9c | 863 | (bfd *, bfd_vma) ATTRIBUTE_HIDDEN; |
252b5132 RH |
864 | |
865 | /* Function shared by the COFF and ELF SH backends, which have no | |
866 | other common header files. */ | |
867 | ||
c58b9523 | 868 | #ifndef _bfd_sh_align_load_span |
0a1b45a2 | 869 | extern bool _bfd_sh_align_load_span |
c58b9523 | 870 | (bfd *, asection *, bfd_byte *, |
0a1b45a2 AM |
871 | bool (*) (bfd *, asection *, void *, bfd_byte *, bfd_vma), |
872 | void *, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bool *) ATTRIBUTE_HIDDEN; | |
c58b9523 | 873 | #endif |
082b7297 L |
874 | |
875 | /* This is the shape of the elements inside the already_linked hash | |
876 | table. It maps a name onto a list of already_linked elements with | |
877 | the same name. */ | |
878 | ||
879 | struct bfd_section_already_linked_hash_entry | |
880 | { | |
881 | struct bfd_hash_entry root; | |
882 | struct bfd_section_already_linked *entry; | |
883 | }; | |
884 | ||
885 | struct bfd_section_already_linked | |
886 | { | |
887 | struct bfd_section_already_linked *next; | |
c77ec726 | 888 | asection *sec; |
082b7297 L |
889 | }; |
890 | ||
891 | extern struct bfd_section_already_linked_hash_entry * | |
8722de9c | 892 | bfd_section_already_linked_table_lookup (const char *) ATTRIBUTE_HIDDEN; |
0a1b45a2 | 893 | extern bool bfd_section_already_linked_table_insert |
8722de9c AM |
894 | (struct bfd_section_already_linked_hash_entry *, asection *) |
895 | ATTRIBUTE_HIDDEN; | |
3d7f7666 | 896 | extern void bfd_section_already_linked_table_traverse |
0a1b45a2 | 897 | (bool (*) (struct bfd_section_already_linked_hash_entry *, |
8722de9c AM |
898 | void *), void *) ATTRIBUTE_HIDDEN; |
899 | ||
900 | extern bfd_vma _bfd_read_unsigned_leb128 | |
901 | (bfd *, bfd_byte *, unsigned int *) ATTRIBUTE_HIDDEN; | |
902 | extern bfd_signed_vma _bfd_read_signed_leb128 | |
903 | (bfd *, bfd_byte *, unsigned int *) ATTRIBUTE_HIDDEN; | |
904 | extern bfd_vma _bfd_safe_read_leb128 | |
574ec108 | 905 | (bfd *, bfd_byte **, bool, const bfd_byte * const) ATTRIBUTE_HIDDEN; |
47485a31 AM |
906 | extern bfd_byte * _bfd_write_unsigned_leb128 |
907 | (bfd_byte *, bfd_byte *, bfd_vma) ATTRIBUTE_HIDDEN; | |
1f4361a7 | 908 | |
8c0546e9 L |
909 | extern struct bfd_link_info *_bfd_get_link_info (bfd *); |
910 | ||
a8dde0a2 L |
911 | extern bool _bfd_link_keep_memory (struct bfd_link_info *) |
912 | ATTRIBUTE_HIDDEN; | |
913 | ||
1f4361a7 AM |
914 | #if GCC_VERSION >= 7000 |
915 | #define _bfd_mul_overflow(a, b, res) __builtin_mul_overflow (a, b, res) | |
916 | #else | |
917 | /* Assumes unsigned values. Careful! Args evaluated multiple times. */ | |
918 | #define _bfd_mul_overflow(a, b, res) \ | |
919 | ((*res) = (a), (*res) *= (b), (b) != 0 && (*res) / (b) != (a)) | |
920 | #endif | |
2bb3687b | 921 | |
2c7c5554 AM |
922 | #ifdef __GNUC__ |
923 | #define _bfd_constant_p(v) __builtin_constant_p (v) | |
924 | #else | |
925 | #define _bfd_constant_p(v) 0 | |
926 | #endif | |
927 | ||
2bb3687b AM |
928 | static inline bfd_byte * |
929 | _bfd_alloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize) | |
930 | { | |
2c7c5554 AM |
931 | bfd_byte *mem; |
932 | if (!_bfd_constant_p (rsize)) | |
933 | { | |
934 | ufile_ptr filesize = bfd_get_file_size (abfd); | |
935 | if (filesize != 0 && rsize > filesize) | |
936 | { | |
937 | bfd_set_error (bfd_error_file_truncated); | |
938 | return NULL; | |
939 | } | |
940 | } | |
941 | mem = bfd_alloc (abfd, asize); | |
2bb3687b AM |
942 | if (mem != NULL) |
943 | { | |
944 | if (bfd_bread (mem, rsize, abfd) == rsize) | |
945 | return mem; | |
946 | bfd_release (abfd, mem); | |
947 | } | |
948 | return NULL; | |
949 | } | |
950 | ||
951 | static inline bfd_byte * | |
952 | _bfd_malloc_and_read (bfd *abfd, bfd_size_type asize, bfd_size_type rsize) | |
953 | { | |
2c7c5554 AM |
954 | bfd_byte *mem; |
955 | if (!_bfd_constant_p (rsize)) | |
956 | { | |
957 | ufile_ptr filesize = bfd_get_file_size (abfd); | |
958 | if (filesize != 0 && rsize > filesize) | |
959 | { | |
960 | bfd_set_error (bfd_error_file_truncated); | |
961 | return NULL; | |
962 | } | |
963 | } | |
964 | mem = bfd_malloc (asize); | |
2bb3687b AM |
965 | if (mem != NULL) |
966 | { | |
967 | if (bfd_bread (mem, rsize, abfd) == rsize) | |
968 | return mem; | |
969 | free (mem); | |
970 | } | |
971 | return NULL; | |
972 | } |