* configure.in (*-*-netware, i[34]86-*-netware): New configs.
[binutils-gdb.git] / bfd / libelf.h
1 /* BFD back-end data structures for ELF files.
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
3 Written by Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #ifndef _LIBELF_H_
22 #define _LIBELF_H_ 1
23
24 #include "elf/common.h"
25 #include "elf/internal.h"
26 #include "elf/external.h"
27
28 /* If size isn't specified as 64 or 32, NAME macro should fail. */
29 #ifndef NAME
30 #if ARCH_SIZE==64
31 #define NAME(x,y) CAT4(x,64,_,y)
32 #endif
33 #if ARCH_SIZE==32
34 #define NAME(x,y) CAT4(x,32,_,y)
35 #endif
36 #endif
37
38 #define ElfNAME(X) NAME(Elf,X)
39 #define elfNAME(X) NAME(elf,X)
40
41 typedef struct
42 {
43 asymbol symbol;
44 Elf_Internal_Sym internal_elf_sym;
45 /* these are used for the generation of .stabX symbols (?) */
46 short desc;
47 unsigned char type;
48 char other;
49 union
50 {
51 unsigned int hppa_arg_reloc;
52 PTR any;
53 }
54 tc_data;
55 Elf32_External_Sym native_elf_sym;
56 } elf32_symbol_type;
57
58 typedef struct
59 {
60 asymbol symbol;
61 Elf_Internal_Sym internal_elf_sym;
62 /* these are used for the generation of .stabX symbols (?) */
63 short desc;
64 unsigned char type;
65 char other;
66 union
67 {
68 unsigned int hppa_arg_reloc;
69 PTR any;
70 }
71 tc_data;
72 Elf64_External_Sym native_elf_sym;
73 } elf64_symbol_type;
74
75 struct elf_backend_data
76 {
77 int use_rela_p;
78 int elf_64_p;
79 enum bfd_architecture arch;
80 void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
81 Elf_Internal_Rela *));
82 void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
83 Elf_Internal_Rel *));
84 void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
85
86 /* @@ I really don't think this should be here. I don't know what
87 global_sym is supposed to be used for, but I doubt it's something
88 that would be considered global, e.g., if you've got a program
89 reading and writing many BFDs. My hunch is that it's specific to
90 the output BFD. If not, put a comment here explaining why. */
91 /* @@ Was pointer to elfNAME(symbol_type). This makes it size-
92 independent. */
93 PTR global_sym;
94 };
95
96 struct bfd_elf_arch_map {
97 enum bfd_architecture bfd_arch;
98 int elf_arch;
99 };
100
101 extern const struct bfd_elf_arch_map bfd_elf_arch_map[];
102 extern const int bfd_elf_arch_map_size;
103
104 struct bfd_elf_section_data {
105 Elf_Internal_Shdr this_hdr;
106 Elf_Internal_Shdr rel_hdr;
107 int this_idx, rel_idx;
108 #if 0
109 Elf_Internal_Shdr str_hdr;
110 int str_idx;
111 #endif
112 };
113 #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
114 #define shdr_name(abfd,shdr) (elf_shstrtab (abfd)->tab + (shdr)->sh_name)
115
116 #define get_elf_backend_data(abfd) \
117 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
118
119 struct strtab
120 {
121 char *tab;
122 int nentries;
123 int length;
124 };
125
126 /* Some private data is stashed away for future use using the tdata pointer
127 in the bfd structure. */
128
129 struct elf_obj_tdata
130 {
131 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
132 Elf_Internal_Shdr **elf_sect_ptr;
133 struct strtab *strtab_ptr;
134 int num_locals;
135 int num_globals;
136 int *symtab_map;
137 PTR raw_syms; /* Elf_External_Sym* */
138 Elf_Internal_Sym *internal_syms;
139 PTR symbols; /* elf_symbol_type */
140 /* struct strtab *shstrtab;*/
141 Elf_Internal_Shdr symtab_hdr;
142 Elf_Internal_Shdr shstrtab_hdr;
143 Elf_Internal_Shdr strtab_hdr;
144 int symtab_section, shstrtab_section, strtab_section;
145 file_ptr next_file_pos;
146 void *prstatus; /* The raw /proc prstatus structure */
147 void *prpsinfo; /* The raw /proc prpsinfo structure */
148 };
149
150 #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
151 #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
152 #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
153 #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
154 #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
155 #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
156 #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
157 #define elf_symtab_map(bfd) (elf_tdata(bfd) -> symtab_map)
158 #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
159 #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
160 #define obj_symbols(bfd) ((elf_symbol_type*)(elf_tdata(bfd) -> symbols))
161 #define obj_raw_syms(bfd) ((Elf_External_Sym*)(elf_tdata(bfd) -> raw_syms))
162 #define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
163
164 extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
165 extern char * elf_get_str_section PARAMS ((bfd *, unsigned));
166
167 #define bfd_elf32_mkobject bfd_elf_mkobject
168 #define bfd_elf64_mkobject bfd_elf_mkobject
169 #define elf_mkobject bfd_elf_mkobject
170
171 extern unsigned long elf_hash PARAMS ((CONST unsigned char *));
172
173 extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
174 arelent *,
175 asymbol *,
176 PTR,
177 asection *,
178 bfd *));
179 extern boolean bfd_elf_mkobject PARAMS ((bfd *));
180 extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
181 extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
182
183 extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
184 extern bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
185 extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
186 extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
187 extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
188 bfd *));
189 extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
190 file_ptr,
191 bfd_size_type));
192
193 extern unsigned int bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *));
194 extern unsigned int bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **));
195 extern unsigned int bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
196 extern unsigned int bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
197 arelent **,
198 asymbol **));
199 extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *));
200 extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *,
201 bfd_print_symbol_type));
202 extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *,
203 symbol_info *));
204 extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *));
205 extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
206 unsigned long));
207 extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *,
208 asymbol **,
209 bfd_vma, CONST char **,
210 CONST char **,
211 unsigned int *));
212 extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean));
213 extern void bfd_elf32__write_relocs PARAMS ((bfd *, asection *, PTR));
214 extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *));
215
216 /* If the target doesn't have reloc handling written yet: */
217 extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
218 Elf32_Internal_Rela *));
219
220 extern bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
221 extern bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
222 extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
223 extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
224 extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
225 bfd *));
226 extern boolean bfd_elf64_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
227 file_ptr,
228 bfd_size_type));
229
230 extern unsigned int bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *));
231 extern unsigned int bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **));
232 extern unsigned int bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
233 extern unsigned int bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
234 arelent **,
235 asymbol **));
236 extern asymbol *bfd_elf64_make_empty_symbol PARAMS ((bfd *));
237 extern void bfd_elf64_print_symbol PARAMS ((bfd *, PTR, asymbol *,
238 bfd_print_symbol_type));
239 extern void bfd_elf64_get_symbol_info PARAMS ((bfd *, asymbol *,
240 symbol_info *));
241 extern alent *bfd_elf64_get_lineno PARAMS ((bfd *, asymbol *));
242 extern boolean bfd_elf64_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
243 unsigned long));
244 extern boolean bfd_elf64_find_nearest_line PARAMS ((bfd *, asection *,
245 asymbol **,
246 bfd_vma, CONST char **,
247 CONST char **,
248 unsigned int *));
249 extern int bfd_elf64_sizeof_headers PARAMS ((bfd *, boolean));
250 extern void bfd_elf64__write_relocs PARAMS ((bfd *, asection *, PTR));
251 extern boolean bfd_elf64_new_section_hook PARAMS ((bfd *, asection *));
252
253 /* If the target doesn't have reloc handling written yet: */
254 extern void bfd_elf64_no_info_to_howto PARAMS ((bfd *, arelent *,
255 Elf64_Internal_Rela *));
256
257 #endif /* _LIBELF_H_ */