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