| 1 | /* ELF object file format. |
| 2 | Copyright (C) 1992-2020 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GAS, the GNU Assembler. |
| 5 | |
| 6 | GAS is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 3, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | GAS is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GAS; see the file COPYING. If not, write to the Free |
| 18 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
| 19 | 02110-1301, USA. */ |
| 20 | |
| 21 | /* HP PA-RISC support was contributed by the Center for Software Science |
| 22 | at the University of Utah. */ |
| 23 | |
| 24 | #ifndef _OBJ_ELF_H |
| 25 | #define _OBJ_ELF_H |
| 26 | |
| 27 | #define OBJ_ELF 1 |
| 28 | |
| 29 | /* Note that all macros in this file should be wrapped in #ifndef, for |
| 30 | sake of obj-multi.h which includes this file. */ |
| 31 | |
| 32 | #ifndef OUTPUT_FLAVOR |
| 33 | #define OUTPUT_FLAVOR bfd_target_elf_flavour |
| 34 | #endif |
| 35 | |
| 36 | #define BYTES_IN_WORD 4 /* for now */ |
| 37 | #include "bfd/elf-bfd.h" |
| 38 | |
| 39 | #include "targ-cpu.h" |
| 40 | |
| 41 | #ifdef TC_ALPHA |
| 42 | #define ECOFF_DEBUGGING (alpha_flag_mdebug > 0) |
| 43 | extern int alpha_flag_mdebug; |
| 44 | #endif |
| 45 | |
| 46 | /* For now, always set ECOFF_DEBUGGING for a MIPS target. */ |
| 47 | #ifdef TC_MIPS |
| 48 | #define ECOFF_DEBUGGING mips_flag_mdebug |
| 49 | extern int mips_flag_mdebug; |
| 50 | #endif /* TC_MIPS */ |
| 51 | |
| 52 | #ifdef OBJ_MAYBE_ECOFF |
| 53 | #ifndef ECOFF_DEBUGGING |
| 54 | #define ECOFF_DEBUGGING 1 |
| 55 | #endif |
| 56 | #endif |
| 57 | |
| 58 | enum elf_visibility |
| 59 | { |
| 60 | visibility_unchanged = 0, |
| 61 | visibility_local, |
| 62 | visibility_hidden, |
| 63 | visibility_remove |
| 64 | }; |
| 65 | |
| 66 | struct elf_versioned_name_list |
| 67 | { |
| 68 | char *name; |
| 69 | struct elf_versioned_name_list *next; |
| 70 | }; |
| 71 | |
| 72 | /* Additional information we keep for each symbol. */ |
| 73 | struct elf_obj_sy |
| 74 | { |
| 75 | /* Whether the symbol has been marked as local. */ |
| 76 | unsigned int local : 1; |
| 77 | |
| 78 | /* Whether the symbol has been marked for rename with @@@. */ |
| 79 | unsigned int rename : 1; |
| 80 | |
| 81 | /* Whether the symbol has a bad version name. */ |
| 82 | unsigned int bad_version : 1; |
| 83 | |
| 84 | /* Whether visibility of the symbol should be changed. */ |
| 85 | ENUM_BITFIELD (elf_visibility) visibility : 2; |
| 86 | |
| 87 | /* Use this to keep track of .size expressions that involve |
| 88 | differences that we can't compute yet. */ |
| 89 | expressionS *size; |
| 90 | |
| 91 | /* The list of names specified by the .symver directive. */ |
| 92 | struct elf_versioned_name_list *versioned_name; |
| 93 | |
| 94 | #ifdef ECOFF_DEBUGGING |
| 95 | /* If we are generating ECOFF debugging information, we need some |
| 96 | additional fields for each symbol. */ |
| 97 | struct efdr *ecoff_file; |
| 98 | struct localsym *ecoff_symbol; |
| 99 | valueT ecoff_extern_size; |
| 100 | #endif |
| 101 | }; |
| 102 | |
| 103 | /* Match section group name, the sh_info field and the section_id |
| 104 | field. */ |
| 105 | struct elf_section_match |
| 106 | { |
| 107 | const char *group_name; |
| 108 | const char *linked_to_symbol_name; |
| 109 | unsigned int info; |
| 110 | unsigned int section_id; |
| 111 | flagword flags; |
| 112 | }; |
| 113 | |
| 114 | #define OBJ_SYMFIELD_TYPE struct elf_obj_sy |
| 115 | |
| 116 | #ifndef FALSE |
| 117 | #define FALSE 0 |
| 118 | #define TRUE !FALSE |
| 119 | #endif |
| 120 | |
| 121 | #ifndef obj_begin |
| 122 | #define obj_begin() elf_begin () |
| 123 | #endif |
| 124 | extern void elf_begin (void); |
| 125 | |
| 126 | #ifndef LOCAL_LABEL_PREFIX |
| 127 | #define LOCAL_LABEL_PREFIX '.' |
| 128 | #endif |
| 129 | |
| 130 | /* should be conditional on address size! */ |
| 131 | #define elf_symbol(asymbol) ((elf_symbol_type *) (&(asymbol)->the_bfd)) |
| 132 | |
| 133 | #ifndef S_GET_SIZE |
| 134 | #define S_GET_SIZE(S) \ |
| 135 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size) |
| 136 | #endif |
| 137 | #ifndef S_SET_SIZE |
| 138 | #define S_SET_SIZE(S,V) \ |
| 139 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V)) |
| 140 | #endif |
| 141 | |
| 142 | #ifndef S_GET_ALIGN |
| 143 | #define S_GET_ALIGN(S) \ |
| 144 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value) |
| 145 | #endif |
| 146 | #ifndef S_SET_ALIGN |
| 147 | #define S_SET_ALIGN(S,V) \ |
| 148 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V)) |
| 149 | #endif |
| 150 | |
| 151 | int elf_s_get_other (symbolS *); |
| 152 | #ifndef S_GET_OTHER |
| 153 | #define S_GET_OTHER(S) (elf_s_get_other (S)) |
| 154 | #endif |
| 155 | #ifndef S_SET_OTHER |
| 156 | #define S_SET_OTHER(S,V) \ |
| 157 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V)) |
| 158 | #endif |
| 159 | |
| 160 | extern asection *gdb_section; |
| 161 | |
| 162 | #ifndef obj_frob_file |
| 163 | #define obj_frob_file elf_frob_file |
| 164 | #endif |
| 165 | extern void elf_frob_file (void); |
| 166 | |
| 167 | #ifndef obj_frob_file_before_adjust |
| 168 | #define obj_frob_file_before_adjust elf_frob_file_before_adjust |
| 169 | #endif |
| 170 | extern void elf_frob_file_before_adjust (void); |
| 171 | |
| 172 | #ifndef obj_frob_file_after_relocs |
| 173 | #define obj_frob_file_after_relocs elf_frob_file_after_relocs |
| 174 | #endif |
| 175 | extern void elf_frob_file_after_relocs (void); |
| 176 | |
| 177 | /* If the target doesn't have special processing for labels, take care of |
| 178 | dwarf2 output at the object file level. */ |
| 179 | #ifndef tc_frob_label |
| 180 | #include "dwarf2dbg.h" |
| 181 | #define obj_frob_label dwarf2_emit_label |
| 182 | #endif |
| 183 | |
| 184 | #ifndef obj_app_file |
| 185 | #define obj_app_file elf_file_symbol |
| 186 | #endif |
| 187 | extern void elf_file_symbol (const char *, int); |
| 188 | |
| 189 | extern void obj_elf_section_change_hook (void); |
| 190 | |
| 191 | extern void obj_elf_section (int); |
| 192 | extern const char * obj_elf_section_name (void); |
| 193 | extern void obj_elf_previous (int); |
| 194 | extern void obj_elf_version (int); |
| 195 | extern void obj_elf_common (int); |
| 196 | extern void obj_elf_data (int); |
| 197 | extern void obj_elf_text (int); |
| 198 | extern void obj_elf_change_section |
| 199 | (const char *, unsigned int, bfd_vma, int, struct elf_section_match *, |
| 200 | int, int); |
| 201 | extern void obj_elf_vtable_inherit (int); |
| 202 | extern void obj_elf_vtable_entry (int); |
| 203 | extern struct fix * obj_elf_get_vtable_inherit (void); |
| 204 | extern struct fix * obj_elf_get_vtable_entry (void); |
| 205 | extern bfd_boolean obj_elf_seen_attribute |
| 206 | (int, unsigned int); |
| 207 | extern int obj_elf_vendor_attribute (int); |
| 208 | |
| 209 | /* BFD wants to write the udata field, which is a no-no for the |
| 210 | predefined section symbols in bfd/section.c. They are read-only. */ |
| 211 | #ifndef obj_sec_sym_ok_for_reloc |
| 212 | #define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0) |
| 213 | #endif |
| 214 | |
| 215 | void elf_obj_read_begin_hook (void); |
| 216 | #ifndef obj_read_begin_hook |
| 217 | #define obj_read_begin_hook elf_obj_read_begin_hook |
| 218 | #endif |
| 219 | |
| 220 | void elf_obj_symbol_new_hook (symbolS *); |
| 221 | #ifndef obj_symbol_new_hook |
| 222 | #define obj_symbol_new_hook elf_obj_symbol_new_hook |
| 223 | #endif |
| 224 | |
| 225 | void elf_copy_symbol_attributes (symbolS *, symbolS *); |
| 226 | #ifndef OBJ_COPY_SYMBOL_ATTRIBUTES |
| 227 | #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \ |
| 228 | (elf_copy_symbol_attributes (DEST, SRC)) |
| 229 | #endif |
| 230 | |
| 231 | void elf_adjust_symtab (void); |
| 232 | #ifndef obj_adjust_symtab |
| 233 | #define obj_adjust_symtab elf_adjust_symtab |
| 234 | #endif |
| 235 | |
| 236 | #ifndef SEPARATE_STAB_SECTIONS |
| 237 | /* Avoid ifndef each separate macro setting by wrapping the whole of the |
| 238 | stab group on the assumption that whoever sets SEPARATE_STAB_SECTIONS |
| 239 | caters to ECOFF_DEBUGGING and the right setting of INIT_STAB_SECTIONS |
| 240 | and OBJ_PROCESS_STAB too, without needing the tweaks below. */ |
| 241 | |
| 242 | /* Stabs go in a separate section. */ |
| 243 | #define SEPARATE_STAB_SECTIONS 1 |
| 244 | |
| 245 | /* We need 12 bytes at the start of the section to hold some initial |
| 246 | information. */ |
| 247 | extern void obj_elf_init_stab_section (segT); |
| 248 | #define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg) |
| 249 | |
| 250 | #ifdef ECOFF_DEBUGGING |
| 251 | /* We smuggle stabs in ECOFF rather than using a separate section. |
| 252 | The Irix linker can not handle a separate stabs section. */ |
| 253 | |
| 254 | #undef SEPARATE_STAB_SECTIONS |
| 255 | #define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING) |
| 256 | |
| 257 | #undef INIT_STAB_SECTION |
| 258 | #define INIT_STAB_SECTION(seg) \ |
| 259 | ((void) (ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0))) |
| 260 | |
| 261 | #undef OBJ_PROCESS_STAB |
| 262 | #define OBJ_PROCESS_STAB(seg, what, string, type, other, desc) \ |
| 263 | if (ECOFF_DEBUGGING) \ |
| 264 | ecoff_stab ((seg), (what), (string), (type), (other), (desc)) |
| 265 | #endif /* ECOFF_DEBUGGING */ |
| 266 | |
| 267 | #endif /* SEPARATE_STAB_SECTIONS not defined. */ |
| 268 | |
| 269 | extern void elf_frob_symbol (symbolS *, int *); |
| 270 | #ifndef obj_frob_symbol |
| 271 | #define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt) |
| 272 | #endif |
| 273 | |
| 274 | extern void elf_pop_insert (void); |
| 275 | #ifndef obj_pop_insert |
| 276 | #define obj_pop_insert() elf_pop_insert() |
| 277 | #endif |
| 278 | |
| 279 | #ifndef OBJ_MAYBE_ELF |
| 280 | /* If OBJ_MAYBE_ELF then obj-multi.h will define obj_ecoff_set_ext. */ |
| 281 | #define obj_ecoff_set_ext elf_ecoff_set_ext |
| 282 | struct ecoff_extr; |
| 283 | extern void elf_ecoff_set_ext (symbolS *, struct ecoff_extr *); |
| 284 | #endif |
| 285 | extern asection *elf_com_section_ptr; |
| 286 | extern symbolS * elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP, |
| 287 | addressT size); |
| 288 | |
| 289 | #endif /* _OBJ_ELF_H */ |