1 1.1 skrll /* BFD ECOFF object file private structure. 2 1.1.1.11 christos Copyright (C) 1993-2026 Free Software Foundation, Inc. 3 1.1 skrll Written by Ian Lance Taylor, Cygnus Support. 4 1.1 skrll 5 1.1 skrll This file is part of BFD, the Binary File Descriptor library. 6 1.1 skrll 7 1.1 skrll This program is free software; you can redistribute it and/or modify 8 1.1 skrll it under the terms of the GNU General Public License as published by 9 1.1 skrll the Free Software Foundation; either version 3 of the License, or 10 1.1 skrll (at your option) any later version. 11 1.1 skrll 12 1.1 skrll This program is distributed in the hope that it will be useful, 13 1.1 skrll but WITHOUT ANY WARRANTY; without even the implied warranty of 14 1.1 skrll MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 1.1 skrll GNU General Public License for more details. 16 1.1 skrll 17 1.1 skrll You should have received a copy of the GNU General Public License 18 1.1 skrll along with this program; if not, write to the Free Software 19 1.1 skrll Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 20 1.1 skrll MA 02110-1301, USA. */ 21 1.1 skrll 22 1.1 skrll #include "bfdlink.h" 23 1.1 skrll 24 1.1 skrll #ifndef ECOFF_H 25 1.1 skrll #include "coff/ecoff.h" 26 1.1 skrll #endif 27 1.1 skrll 28 1.1.1.11 christos #include "hidden.h" 29 1.1.1.11 christos 30 1.1 skrll /* This is the backend information kept for ECOFF files. This 31 1.1 skrll structure is constant for a particular backend. The first element 32 1.1 skrll is the COFF backend data structure, so that ECOFF targets can use 33 1.1 skrll the generic COFF code. */ 34 1.1 skrll 35 1.1 skrll #define ecoff_backend(abfd) \ 36 1.1 skrll ((struct ecoff_backend_data *) (abfd)->xvec->backend_data) 37 1.1 skrll 38 1.1 skrll struct ecoff_backend_data 39 1.1 skrll { 40 1.1 skrll /* COFF backend information. This must be the first field. */ 41 1.1 skrll bfd_coff_backend_data coff; 42 1.1 skrll /* Supported architecture. */ 43 1.1 skrll enum bfd_architecture arch; 44 1.1 skrll /* Initial portion of armap string. */ 45 1.1 skrll const char *armap_start; 46 1.1 skrll /* The page boundary used to align sections in a demand-paged 47 1.1 skrll executable file. E.g., 0x1000. */ 48 1.1 skrll bfd_vma round; 49 1.1 skrll /* TRUE if the .rdata section is part of the text segment, as on the 50 1.1 skrll Alpha. FALSE if .rdata is part of the data segment, as on the 51 1.1 skrll MIPS. */ 52 1.1.1.8 christos bool rdata_in_text; 53 1.1 skrll /* Bitsize of constructor entries. */ 54 1.1 skrll unsigned int constructor_bitsize; 55 1.1 skrll /* Reloc to use for constructor entries. */ 56 1.1 skrll reloc_howto_type *constructor_reloc; 57 1.1 skrll /* How to swap debugging information. */ 58 1.1 skrll struct ecoff_debug_swap debug_swap; 59 1.1 skrll /* External reloc size. */ 60 1.1 skrll bfd_size_type external_reloc_size; 61 1.1 skrll /* Reloc swapping functions. */ 62 1.1 skrll void (*swap_reloc_in) (bfd *, void *, struct internal_reloc *); 63 1.1 skrll void (*swap_reloc_out) (bfd *, const struct internal_reloc *, void *); 64 1.1 skrll /* Backend reloc tweaking. */ 65 1.1 skrll void (*adjust_reloc_in) 66 1.1 skrll (bfd *, const struct internal_reloc *, arelent *); 67 1.1 skrll void (*adjust_reloc_out) 68 1.1 skrll (bfd *, const arelent *, struct internal_reloc *); 69 1.1 skrll /* Relocate section contents while linking. */ 70 1.1.1.8 christos bool (*relocate_section) 71 1.1 skrll (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, void *); 72 1.1 skrll /* Do final adjustments to filehdr and aouthdr. */ 73 1.1.1.8 christos bool (*adjust_headers) 74 1.1 skrll (bfd *, struct internal_filehdr *, struct internal_aouthdr *); 75 1.1 skrll /* Read an element from an archive at a given file position. This 76 1.1 skrll is needed because OSF/1 3.2 uses a weird archive format. */ 77 1.1.1.8 christos bfd *(*get_elt_at_filepos) (bfd *, file_ptr, struct bfd_link_info *); 78 1.1 skrll }; 79 1.1 skrll 80 1.1.1.2 christos /* ECOFF targets don't support COFF long section names, so this 81 1.1.1.2 christos macro is provided to use as an initialiser for the related 82 1.1.1.2 christos members of the embedded bfd_coff_backend_data struct. */ 83 1.1.1.8 christos #define ECOFF_NO_LONG_SECTION_NAMES (false), _bfd_ecoff_no_long_sections 84 1.1.1.2 christos 85 1.1.1.9 christos struct mips_hi 86 1.1.1.9 christos { 87 1.1.1.9 christos struct mips_hi *next; 88 1.1.1.9 christos bfd_byte *addr; 89 1.1.1.9 christos bfd_vma addend; 90 1.1.1.9 christos }; 91 1.1.1.9 christos 92 1.1 skrll /* This is the target specific information kept for ECOFF files. */ 93 1.1 skrll 94 1.1 skrll #define ecoff_data(abfd) ((abfd)->tdata.ecoff_obj_data) 95 1.1 skrll 96 1.1 skrll typedef struct ecoff_tdata 97 1.1 skrll { 98 1.1 skrll /* The reloc file position, set by 99 1.1 skrll ecoff_compute_section_file_positions. */ 100 1.1 skrll file_ptr reloc_filepos; 101 1.1 skrll 102 1.1 skrll /* The symbol table file position, set by _bfd_ecoff_mkobject_hook. */ 103 1.1 skrll file_ptr sym_filepos; 104 1.1 skrll 105 1.1 skrll /* The start and end of the text segment. Only valid for an 106 1.1 skrll existing file, not for one we are creating. */ 107 1.1 skrll unsigned long text_start; 108 1.1 skrll unsigned long text_end; 109 1.1 skrll 110 1.1 skrll /* The cached gp value. This is used when relocating. */ 111 1.1 skrll bfd_vma gp; 112 1.1 skrll 113 1.1 skrll /* The maximum size of objects to optimize using gp. This is 114 1.1 skrll typically set by the -G option to the compiler, assembler or 115 1.1 skrll linker. */ 116 1.1 skrll unsigned int gp_size; 117 1.1 skrll 118 1.1 skrll /* The register masks. When linking, all the masks found in the 119 1.1 skrll input files are combined into the masks of the output file. 120 1.1 skrll These are not all used for all targets, but that's OK, because 121 1.1 skrll the relevant ones are the only ones swapped in and out. */ 122 1.1 skrll unsigned long gprmask; 123 1.1 skrll unsigned long fprmask; 124 1.1 skrll unsigned long cprmask[4]; 125 1.1 skrll 126 1.1 skrll /* The ECOFF symbolic debugging information. */ 127 1.1 skrll struct ecoff_debug_info debug_info; 128 1.1 skrll 129 1.1 skrll /* The canonical BFD symbols. */ 130 1.1 skrll struct ecoff_symbol_struct *canonical_symbols; 131 1.1 skrll 132 1.1 skrll /* A mapping from external symbol numbers to entries in the linker 133 1.1 skrll hash table, used when linking. */ 134 1.1 skrll struct ecoff_link_hash_entry **sym_hashes; 135 1.1 skrll 136 1.1 skrll /* A mapping from reloc symbol indices to sections, used when 137 1.1 skrll linking. */ 138 1.1 skrll asection **symndx_to_section; 139 1.1 skrll 140 1.1 skrll /* TRUE if this BFD was written by the backend linker. */ 141 1.1.1.8 christos bool linker; 142 1.1 skrll 143 1.1 skrll /* TRUE if a warning that multiple global pointer values are 144 1.1 skrll needed in the output binary was issued already. */ 145 1.1.1.8 christos bool issued_multiple_gp_warning; 146 1.1 skrll 147 1.1 skrll /* Used by find_nearest_line entry point. The structure could be 148 1.1 skrll included directly in this one, but there's no point to wasting 149 1.1 skrll the memory just for the infrequently called find_nearest_line. */ 150 1.1 skrll struct ecoff_find_line *find_line_info; 151 1.1 skrll 152 1.1 skrll /* Whether the .rdata section is in the text segment for this 153 1.1 skrll particular ECOFF file. This is not valid until 154 1.1 skrll ecoff_compute_section_file_positions is called. */ 155 1.1.1.8 christos bool rdata_in_text; 156 1.1 skrll 157 1.1.1.9 christos /* Used by coff-mips.c to track REFHI relocs for pairing with REFLO. */ 158 1.1.1.9 christos struct mips_hi *mips_refhi_list; 159 1.1 skrll } ecoff_data_type; 160 1.1 skrll 161 1.1 skrll /* Each canonical asymbol really looks like this. */ 162 1.1 skrll 163 1.1 skrll typedef struct ecoff_symbol_struct 164 1.1 skrll { 165 1.1 skrll /* The actual symbol which the rest of BFD works with */ 166 1.1 skrll asymbol symbol; 167 1.1 skrll 168 1.1 skrll /* The fdr for this symbol. */ 169 1.1 skrll FDR *fdr; 170 1.1 skrll 171 1.1 skrll /* TRUE if this is a local symbol rather than an external one. */ 172 1.1.1.8 christos bool local; 173 1.1 skrll 174 1.1 skrll /* A pointer to the unswapped hidden information for this symbol. 175 1.1 skrll This is either a struct sym_ext or a struct ext_ext, depending on 176 1.1 skrll the value of the local field above. */ 177 1.1 skrll void * native; 178 1.1 skrll } ecoff_symbol_type; 179 1.1 skrll 180 1.1 skrll /* We take the address of the first element of an asymbol to ensure that the 181 1.1 skrll macro is only ever applied to an asymbol. */ 182 1.1 skrll #define ecoffsymbol(asymbol) ((ecoff_symbol_type *) (&((asymbol)->the_bfd))) 183 1.1 skrll 184 1.1 skrll /* We need to save the index of an external symbol when we write it 185 1.1 skrll out so that can set the symbol index correctly when we write out 186 1.1 skrll the relocs. */ 187 1.1 skrll #define ecoff_get_sym_index(symbol) ((symbol)->udata.i) 188 1.1 skrll #define ecoff_set_sym_index(symbol, idx) ((symbol)->udata.i = (idx)) 189 1.1 skrll 190 1.1 skrll /* A pointer to this structure is put in the used_by_bfd pointer of 191 1.1 skrll a section to keep track of any per-section data. 192 1.1 skrll The user_by_bfd pointer will be NULL if the information was not 193 1.1 skrll needed. */ 194 1.1 skrll 195 1.1 skrll struct ecoff_section_tdata 196 1.1 skrll { 197 1.1 skrll /* When producing an executable (i.e., final, non-relocatable link) 198 1.1 skrll on the Alpha, we may need to use multiple global pointer values 199 1.1 skrll to span the entire .lita section. In essence, we allow each 200 1.1 skrll input .lita section to have its own gp value. To support this, 201 1.1 skrll we need to keep track of the gp values that we picked for each 202 1.1 skrll input .lita section . */ 203 1.1 skrll bfd_vma gp; 204 1.1 skrll }; 205 1.1 skrll 206 1.1 skrll /* An accessor macro for the ecoff_section_tdata structure. */ 207 1.1 skrll #define ecoff_section_data(abfd, sec) \ 208 1.1 skrll ((struct ecoff_section_tdata *) (sec)->used_by_bfd) 209 1.1 skrll 210 1.1 skrll /* ECOFF linker hash table entries. */ 211 1.1 skrll 212 1.1 skrll struct ecoff_link_hash_entry 213 1.1 skrll { 214 1.1 skrll struct bfd_link_hash_entry root; 215 1.1 skrll /* Symbol index in output file. */ 216 1.1 skrll long indx; 217 1.1 skrll /* BFD that ext field value came from. */ 218 1.1 skrll bfd *abfd; 219 1.1 skrll /* ECOFF external symbol information. */ 220 1.1 skrll EXTR esym; 221 1.1 skrll /* Nonzero if this symbol has been written out. */ 222 1.1 skrll char written; 223 1.1 skrll /* Nonzero if this symbol was referred to as small undefined. */ 224 1.1 skrll char small; 225 1.1 skrll }; 226 1.1 skrll 227 1.1 skrll /* ECOFF linker hash table. */ 228 1.1 skrll 229 1.1 skrll struct ecoff_link_hash_table 230 1.1 skrll { 231 1.1 skrll struct bfd_link_hash_table root; 232 1.1 skrll }; 233 1.1 skrll 234 1.1 skrll /* Make an ECOFF object. */ 235 1.1.1.11 christos extern bool _bfd_ecoff_mkobject (bfd *) ATTRIBUTE_HIDDEN; 236 1.1 skrll 237 1.1 skrll /* Read in the ECOFF symbolic debugging information. */ 238 1.1.1.8 christos extern bool _bfd_ecoff_slurp_symbolic_info 239 1.1.1.11 christos (bfd *, asection *, struct ecoff_debug_info *) ATTRIBUTE_HIDDEN; 240 1.1 skrll 241 1.1 skrll /* Generic ECOFF BFD backend vectors. */ 242 1.1 skrll 243 1.1.1.11 christos extern bool _bfd_ecoff_write_object_contents (bfd *) ATTRIBUTE_HIDDEN; 244 1.1 skrll 245 1.1.1.9 christos #define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup 246 1.1.1.11 christos extern bool _bfd_ecoff_bfd_free_cached_info (bfd *) ATTRIBUTE_HIDDEN; 247 1.1.1.8 christos extern bool _bfd_ecoff_new_section_hook 248 1.1.1.11 christos (bfd *, asection *) ATTRIBUTE_HIDDEN; 249 1.1.1.8 christos extern bool _bfd_ecoff_get_section_contents 250 1.1.1.11 christos (bfd *, asection *, void * location, file_ptr, bfd_size_type) 251 1.1.1.11 christos ATTRIBUTE_HIDDEN; 252 1.1 skrll 253 1.1 skrll #define _bfd_ecoff_bfd_link_split_section _bfd_generic_link_split_section 254 1.1.1.4 christos #define _bfd_ecoff_bfd_link_check_relocs _bfd_generic_link_check_relocs 255 1.1 skrll 256 1.1.1.8 christos extern bool _bfd_ecoff_bfd_copy_private_bfd_data 257 1.1.1.11 christos (bfd *, bfd *) ATTRIBUTE_HIDDEN; 258 1.1 skrll #define _bfd_ecoff_bfd_copy_private_section_data \ 259 1.1 skrll _bfd_generic_bfd_copy_private_section_data 260 1.1 skrll 261 1.1 skrll #define _bfd_ecoff_bfd_copy_private_symbol_data \ 262 1.1 skrll _bfd_generic_bfd_copy_private_symbol_data 263 1.1 skrll 264 1.1 skrll #define _bfd_ecoff_bfd_copy_private_header_data \ 265 1.1 skrll _bfd_generic_bfd_copy_private_header_data 266 1.1 skrll 267 1.1 skrll #define _bfd_ecoff_bfd_print_private_bfd_data \ 268 1.1 skrll _bfd_generic_bfd_print_private_bfd_data 269 1.1 skrll 270 1.1 skrll #define _bfd_ecoff_bfd_merge_private_bfd_data \ 271 1.1 skrll _bfd_generic_bfd_merge_private_bfd_data 272 1.1 skrll 273 1.1 skrll #define _bfd_ecoff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags 274 1.1.1.11 christos extern bool _bfd_ecoff_slurp_armap (bfd *) ATTRIBUTE_HIDDEN; 275 1.1 skrll #define _bfd_ecoff_slurp_extended_name_table _bfd_slurp_extended_name_table 276 1.1 skrll #define _bfd_ecoff_construct_extended_name_table \ 277 1.1 skrll _bfd_archive_bsd_construct_extended_name_table 278 1.1 skrll #define _bfd_ecoff_truncate_arname bfd_dont_truncate_arname 279 1.1.1.8 christos extern bool _bfd_ecoff_write_armap 280 1.1.1.11 christos (bfd *, unsigned int, struct orl *, unsigned int, int) ATTRIBUTE_HIDDEN; 281 1.1 skrll #define _bfd_ecoff_read_ar_hdr _bfd_generic_read_ar_hdr 282 1.1.1.2 christos #define _bfd_ecoff_write_ar_hdr _bfd_generic_write_ar_hdr 283 1.1 skrll #define _bfd_ecoff_openr_next_archived_file \ 284 1.1 skrll bfd_generic_openr_next_archived_file 285 1.1 skrll #define _bfd_ecoff_get_elt_at_index _bfd_generic_get_elt_at_index 286 1.1 skrll #define _bfd_ecoff_generic_stat_arch_elt bfd_generic_stat_arch_elt 287 1.1.1.6 christos #define _bfd_ecoff_update_armap_timestamp _bfd_bool_bfd_true 288 1.1.1.6 christos #define _bfd_ecoff_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false 289 1.1 skrll 290 1.1.1.11 christos extern long _bfd_ecoff_get_symtab_upper_bound (bfd *) ATTRIBUTE_HIDDEN; 291 1.1.1.11 christos extern long _bfd_ecoff_canonicalize_symtab (bfd *, asymbol **) ATTRIBUTE_HIDDEN; 292 1.1.1.11 christos extern asymbol *_bfd_ecoff_make_empty_symbol (bfd *) ATTRIBUTE_HIDDEN; 293 1.1 skrll extern void _bfd_ecoff_print_symbol 294 1.1.1.11 christos (bfd *, void *, asymbol *, bfd_print_symbol_type) ATTRIBUTE_HIDDEN; 295 1.1 skrll extern void _bfd_ecoff_get_symbol_info 296 1.1.1.11 christos (bfd *, asymbol *, symbol_info *) ATTRIBUTE_HIDDEN; 297 1.1.1.3 christos #define _bfd_ecoff_get_symbol_version_string \ 298 1.1.1.3 christos _bfd_nosymbols_get_symbol_version_string 299 1.1.1.8 christos extern bool _bfd_ecoff_bfd_is_local_label_name 300 1.1.1.11 christos (bfd *, const char *) ATTRIBUTE_HIDDEN; 301 1.1 skrll #define _bfd_ecoff_get_lineno _bfd_nosymbols_get_lineno 302 1.1.1.8 christos extern bool _bfd_ecoff_find_nearest_line 303 1.1.1.3 christos (bfd *, asymbol **, asection *, bfd_vma, 304 1.1.1.11 christos const char **, const char **, unsigned int *, unsigned int *) 305 1.1.1.11 christos ATTRIBUTE_HIDDEN; 306 1.1.1.9 christos #define _bfd_ecoff_find_nearest_line_with_alt \ 307 1.1.1.9 christos _bfd_nosymbols_find_nearest_line_with_alt 308 1.1.1.3 christos #define _bfd_ecoff_find_line _bfd_nosymbols_find_line 309 1.1 skrll #define _bfd_ecoff_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol 310 1.1 skrll #define _bfd_ecoff_read_minisymbols _bfd_generic_read_minisymbols 311 1.1 skrll #define _bfd_ecoff_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol 312 1.1 skrll #define _bfd_ecoff_find_inliner_info _bfd_nosymbols_find_inliner_info 313 1.1 skrll 314 1.1 skrll #define _bfd_ecoff_get_reloc_upper_bound coff_get_reloc_upper_bound 315 1.1 skrll extern long _bfd_ecoff_canonicalize_reloc 316 1.1.1.11 christos (bfd *, asection *, arelent **, asymbol **) ATTRIBUTE_HIDDEN; 317 1.1 skrll /* ecoff_bfd_reloc_type_lookup defined by backend. */ 318 1.1 skrll 319 1.1.1.8 christos extern bool _bfd_ecoff_set_arch_mach 320 1.1.1.11 christos (bfd *, enum bfd_architecture, unsigned long) ATTRIBUTE_HIDDEN; 321 1.1.1.8 christos extern bool _bfd_ecoff_set_section_contents 322 1.1.1.11 christos (bfd *, asection *, const void * location, file_ptr, bfd_size_type) 323 1.1.1.11 christos ATTRIBUTE_HIDDEN; 324 1.1 skrll 325 1.1.1.11 christos extern int _bfd_ecoff_sizeof_headers (bfd *, struct bfd_link_info *) 326 1.1.1.11 christos ATTRIBUTE_HIDDEN; 327 1.1 skrll /* ecoff_bfd_get_relocated_section_contents defined by backend. */ 328 1.1 skrll /* ecoff_bfd_relax_section defined by backend. */ 329 1.1 skrll extern struct bfd_link_hash_table *_bfd_ecoff_bfd_link_hash_table_create 330 1.1.1.11 christos (bfd *) ATTRIBUTE_HIDDEN; 331 1.1.1.8 christos extern bool _bfd_ecoff_bfd_link_add_symbols 332 1.1.1.11 christos (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; 333 1.1 skrll #define _bfd_ecoff_bfd_link_just_syms _bfd_generic_link_just_syms 334 1.1.1.2 christos #define _bfd_ecoff_bfd_copy_link_hash_symbol_type \ 335 1.1.1.2 christos _bfd_generic_copy_link_hash_symbol_type 336 1.1.1.8 christos extern bool _bfd_ecoff_bfd_final_link 337 1.1.1.11 christos (bfd *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; 338 1.1 skrll 339 1.1 skrll /* Hook functions for the generic COFF section reading code. */ 340 1.1 skrll 341 1.1.1.11 christos extern void *_bfd_ecoff_mkobject_hook 342 1.1.1.11 christos (bfd *, void *, void *) ATTRIBUTE_HIDDEN; 343 1.1.1.6 christos extern void _bfd_ecoff_set_alignment_hook 344 1.1.1.11 christos (bfd *, asection *, void *) ATTRIBUTE_HIDDEN; 345 1.1.1.8 christos extern bool _bfd_ecoff_set_arch_mach_hook 346 1.1.1.11 christos (bfd *, void *) ATTRIBUTE_HIDDEN; 347 1.1.1.8 christos extern bool _bfd_ecoff_no_long_sections 348 1.1.1.11 christos (bfd *abfd, int enable) ATTRIBUTE_HIDDEN; 349 1.1.1.8 christos extern bool _bfd_ecoff_styp_to_sec_flags 350 1.1.1.11 christos (bfd *, void *, const char *, asection *, flagword *) ATTRIBUTE_HIDDEN; 351 1.1.1.11 christos extern bool _bfd_ecoff_slurp_symbol_table 352 1.1.1.11 christos (bfd *) ATTRIBUTE_HIDDEN; 353 1.1 skrll 354 1.1 skrll /* ECOFF auxiliary information swapping routines. These are the same 355 1.1 skrll for all ECOFF targets, so they are defined in ecofflink.c. */ 356 1.1 skrll 357 1.1 skrll extern void _bfd_ecoff_swap_tir_in 358 1.1.1.11 christos (int, const struct tir_ext *, TIR *) ATTRIBUTE_HIDDEN; 359 1.1 skrll extern void _bfd_ecoff_swap_tir_out 360 1.1.1.11 christos (int, const TIR *, struct tir_ext *) ATTRIBUTE_HIDDEN; 361 1.1 skrll extern void _bfd_ecoff_swap_rndx_in 362 1.1.1.11 christos (int, const struct rndx_ext *, RNDXR *) ATTRIBUTE_HIDDEN; 363 1.1 skrll extern void _bfd_ecoff_swap_rndx_out 364 1.1.1.11 christos (int, const RNDXR *, struct rndx_ext *) ATTRIBUTE_HIDDEN; 365