obj-elf.h 8.5 KB

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