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