]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/config/obj-elf.h
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / config / obj-elf.h
CommitLineData
252b5132 1/* ELF object file format.
250d07de 2 Copyright (C) 1992-2021 Free Software Foundation, Inc.
252b5132
RH
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
ec2655a6 8 the Free Software Foundation; either version 3, or (at your option)
252b5132
RH
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
4b4da160
NC
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
19 02110-1301, USA. */
252b5132 20
252b5132
RH
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
5110c57e
HPN
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
4ca72d38 32#ifndef OUTPUT_FLAVOR
252b5132 33#define OUTPUT_FLAVOR bfd_target_elf_flavour
4ca72d38 34#endif
252b5132 35
252b5132
RH
36#define BYTES_IN_WORD 4 /* for now */
37#include "bfd/elf-bfd.h"
38
49309057
ILT
39#include "targ-cpu.h"
40
41#ifdef TC_ALPHA
a8316fe2 42#define ECOFF_DEBUGGING (alpha_flag_mdebug > 0)
49309057
ILT
43extern int alpha_flag_mdebug;
44#endif
45
46/* For now, always set ECOFF_DEBUGGING for a MIPS target. */
47#ifdef TC_MIPS
ecb4347a
DJ
48#define ECOFF_DEBUGGING mips_flag_mdebug
49extern int mips_flag_mdebug;
49309057
ILT
50#endif /* TC_MIPS */
51
4c63da97
AM
52#ifdef OBJ_MAYBE_ECOFF
53#ifndef ECOFF_DEBUGGING
54#define ECOFF_DEBUGGING 1
55#endif
56#endif
57
6914be53
L
58enum elf_visibility
59{
60 visibility_unchanged = 0,
61 visibility_local,
62 visibility_hidden,
63 visibility_remove
64};
65
66struct elf_versioned_name_list
67{
68 char *name;
69 struct elf_versioned_name_list *next;
70};
71
252b5132 72/* Additional information we keep for each symbol. */
252b5132
RH
73struct elf_obj_sy
74{
49309057 75 /* Whether the symbol has been marked as local. */
6914be53
L
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;
49309057 86
252b5132
RH
87 /* Use this to keep track of .size expressions that involve
88 differences that we can't compute yet. */
89 expressionS *size;
90
6914be53
L
91 /* The list of names specified by the .symver directive. */
92 struct elf_versioned_name_list *versioned_name;
49309057
ILT
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
252b5132 101};
252b5132 102
a8c4d40b
L
103/* Match section group name, the sh_info field and the section_id
104 field. */
105struct elf_section_match
106{
b71702f1
NC
107 const char * group_name;
108 const char * linked_to_symbol_name;
b71702f1 109 unsigned int section_id;
037311d1
L
110 unsigned int sh_info; /* ELF section information. */
111 bfd_vma sh_flags; /* ELF section flags. */
b71702f1 112 flagword flags;
a8c4d40b
L
113};
114
252b5132
RH
115#define OBJ_SYMFIELD_TYPE struct elf_obj_sy
116
252b5132
RH
117#ifndef FALSE
118#define FALSE 0
119#define TRUE !FALSE
120#endif
121
5110c57e 122#ifndef obj_begin
252b5132 123#define obj_begin() elf_begin ()
5110c57e 124#endif
dbe2df79 125extern void elf_begin (void);
252b5132 126
199114c2
AS
127#ifndef LOCAL_LABEL_PREFIX
128#define LOCAL_LABEL_PREFIX '.'
129#endif
130
252b5132 131/* should be conditional on address size! */
814f6641 132#define elf_symbol(asymbol) ((elf_symbol_type *) (&(asymbol)->the_bfd))
252b5132 133
4ca72d38 134#ifndef S_GET_SIZE
49309057
ILT
135#define S_GET_SIZE(S) \
136 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size)
4ca72d38
AM
137#endif
138#ifndef S_SET_SIZE
252b5132 139#define S_SET_SIZE(S,V) \
49309057 140 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V))
4ca72d38 141#endif
252b5132 142
4ca72d38 143#ifndef S_GET_ALIGN
49309057
ILT
144#define S_GET_ALIGN(S) \
145 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value)
4ca72d38
AM
146#endif
147#ifndef S_SET_ALIGN
252b5132 148#define S_SET_ALIGN(S,V) \
49309057 149 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V))
4ca72d38 150#endif
252b5132 151
dbe2df79 152int elf_s_get_other (symbolS *);
4c63da97
AM
153#ifndef S_GET_OTHER
154#define S_GET_OTHER(S) (elf_s_get_other (S))
155#endif
156#ifndef S_SET_OTHER
252b5132 157#define S_SET_OTHER(S,V) \
49309057 158 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V))
4c63da97 159#endif
252b5132
RH
160
161extern asection *gdb_section;
162
4ca72d38 163#ifndef obj_frob_file
252b5132 164#define obj_frob_file elf_frob_file
4ca72d38 165#endif
dbe2df79 166extern void elf_frob_file (void);
252b5132 167
339681c0
L
168#ifndef obj_frob_file_before_adjust
169#define obj_frob_file_before_adjust elf_frob_file_before_adjust
170#endif
dbe2df79 171extern void elf_frob_file_before_adjust (void);
339681c0 172
4ca72d38 173#ifndef obj_frob_file_after_relocs
252b5132 174#define obj_frob_file_after_relocs elf_frob_file_after_relocs
4ca72d38 175#endif
dbe2df79 176extern void elf_frob_file_after_relocs (void);
252b5132 177
07a53e5c
RH
178/* If the target doesn't have special processing for labels, take care of
179 dwarf2 output at the object file level. */
180#ifndef tc_frob_label
181#include "dwarf2dbg.h"
182#define obj_frob_label dwarf2_emit_label
183#endif
184
5110c57e 185#ifndef obj_app_file
252b5132 186#define obj_app_file elf_file_symbol
5110c57e 187#endif
c04f5787 188extern void elf_file_symbol (const char *, int);
252b5132 189
dbe2df79 190extern void obj_elf_section_change_hook (void);
252b5132 191
dbe2df79 192extern void obj_elf_section (int);
82b8a785 193extern const char * obj_elf_section_name (void);
dbe2df79
AM
194extern void obj_elf_previous (int);
195extern void obj_elf_version (int);
196extern void obj_elf_common (int);
197extern void obj_elf_data (int);
198extern void obj_elf_text (int);
e8cf2216 199extern void obj_elf_change_section
a8c4d40b 200 (const char *, unsigned int, bfd_vma, int, struct elf_section_match *,
a91e1603 201 int, int);
68d20676
NC
202extern void obj_elf_vtable_inherit (int);
203extern void obj_elf_vtable_entry (int);
204extern struct fix * obj_elf_get_vtable_inherit (void);
205extern struct fix * obj_elf_get_vtable_entry (void);
9440a904
RS
206extern bfd_boolean obj_elf_seen_attribute
207 (int, unsigned int);
0420f52b 208extern int obj_elf_vendor_attribute (int);
252b5132
RH
209
210/* BFD wants to write the udata field, which is a no-no for the
a161fe53 211 predefined section symbols in bfd/section.c. They are read-only. */
4ca72d38 212#ifndef obj_sec_sym_ok_for_reloc
252b5132 213#define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0)
4ca72d38 214#endif
252b5132 215
dbe2df79 216void elf_obj_read_begin_hook (void);
4c63da97
AM
217#ifndef obj_read_begin_hook
218#define obj_read_begin_hook elf_obj_read_begin_hook
219#endif
220
dbe2df79 221void elf_obj_symbol_new_hook (symbolS *);
4c63da97
AM
222#ifndef obj_symbol_new_hook
223#define obj_symbol_new_hook elf_obj_symbol_new_hook
224#endif
225
7bed8466
AM
226void elf_obj_symbol_clone_hook (symbolS *, symbolS *);
227#ifndef obj_symbol_clone_hook
228#define obj_symbol_clone_hook elf_obj_symbol_clone_hook
229#endif
230
dbe2df79 231void elf_copy_symbol_attributes (symbolS *, symbolS *);
4ca72d38 232#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
8fd3e36b
AM
233#define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
234 (elf_copy_symbol_attributes (DEST, SRC))
4ca72d38 235#endif
252b5132 236
709001e9
MM
237void elf_adjust_symtab (void);
238#ifndef obj_adjust_symtab
239#define obj_adjust_symtab elf_adjust_symtab
240#endif
241
5110c57e
HPN
242#ifndef SEPARATE_STAB_SECTIONS
243/* Avoid ifndef each separate macro setting by wrapping the whole of the
244 stab group on the assumption that whoever sets SEPARATE_STAB_SECTIONS
245 caters to ECOFF_DEBUGGING and the right setting of INIT_STAB_SECTIONS
246 and OBJ_PROCESS_STAB too, without needing the tweaks below. */
247
252b5132
RH
248/* Stabs go in a separate section. */
249#define SEPARATE_STAB_SECTIONS 1
250
251/* We need 12 bytes at the start of the section to hold some initial
252 information. */
dbe2df79 253extern void obj_elf_init_stab_section (segT);
252b5132
RH
254#define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg)
255
252b5132 256#ifdef ECOFF_DEBUGGING
252b5132
RH
257/* We smuggle stabs in ECOFF rather than using a separate section.
258 The Irix linker can not handle a separate stabs section. */
259
260#undef SEPARATE_STAB_SECTIONS
261#define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING)
262
263#undef INIT_STAB_SECTION
264#define INIT_STAB_SECTION(seg) \
814f6641 265 ((void) (ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0)))
252b5132 266
4ca72d38 267#undef OBJ_PROCESS_STAB
252b5132
RH
268#define OBJ_PROCESS_STAB(seg, what, string, type, other, desc) \
269 if (ECOFF_DEBUGGING) \
270 ecoff_stab ((seg), (what), (string), (type), (other), (desc))
271#endif /* ECOFF_DEBUGGING */
272
bf514e21 273#endif /* SEPARATE_STAB_SECTIONS not defined. */
5110c57e 274
dbe2df79 275extern void elf_frob_symbol (symbolS *, int *);
252b5132
RH
276#ifndef obj_frob_symbol
277#define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
278#endif
279
dbe2df79 280extern void elf_pop_insert (void);
4ca72d38 281#ifndef obj_pop_insert
252b5132 282#define obj_pop_insert() elf_pop_insert()
4ca72d38 283#endif
252b5132
RH
284
285#ifndef OBJ_MAYBE_ELF
ae4a729b 286/* If OBJ_MAYBE_ELF then obj-multi.h will define obj_ecoff_set_ext. */
252b5132 287#define obj_ecoff_set_ext elf_ecoff_set_ext
252b5132 288struct ecoff_extr;
dbe2df79 289extern void elf_ecoff_set_ext (symbolS *, struct ecoff_extr *);
252b5132 290#endif
3b22753a
L
291extern asection *elf_com_section_ptr;
292extern symbolS * elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP,
293 addressT size);
252b5132
RH
294
295#endif /* _OBJ_ELF_H */