* config/ho-hpux.h: Do not include ho-sysv.h. Instead include
[deliverable/binutils-gdb.git] / bfd / libelf.h
CommitLineData
db232882
KR
1/* BFD back-end data structures for ELF files.
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
3 Written by Cygnus Support.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21#ifndef _LIBELF_H_
22#define _LIBELF_H_ 1
23
81187b54
KR
24#include "elf/common.h"
25#include "elf/internal.h"
26#include "elf/external.h"
27
998ce1e0 28/* If size isn't specified as 64 or 32, NAME macro should fail. */
9942e684 29#ifndef NAME
7050286d 30#if ARCH_SIZE==64
638616ca 31#define NAME(x,y) CAT4(x,64,_,y)
998ce1e0
KR
32#endif
33#if ARCH_SIZE==32
638616ca 34#define NAME(x,y) CAT4(x,32,_,y)
9942e684
KR
35#endif
36#endif
37
153cb9ad
KR
38#ifndef NAME
39#define NAME(x,y) CAT4(x,NOSIZE,_,y)
40#endif
41
638616ca
KR
42#define ElfNAME(X) NAME(Elf,X)
43#define elfNAME(X) NAME(elf,X)
44
db232882
KR
45typedef struct
46{
47 asymbol symbol;
268f94ac 48 Elf_Internal_Sym internal_elf_sym;
7050286d
KR
49 union
50 {
51 unsigned int hppa_arg_reloc;
52 PTR any;
53 }
54 tc_data;
ee8cb548 55} elf_symbol_type;
7050286d 56
268f94ac 57struct elf_backend_data
7050286d
KR
58{
59 int use_rela_p;
60 int elf_64_p;
81187b54 61 enum bfd_architecture arch;
7050286d 62 void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
268f94ac 63 Elf_Internal_Rela *));
7050286d 64 void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
268f94ac 65 Elf_Internal_Rel *));
d79ab07c 66 bfd_vma maxpagesize;
32090b8e 67 void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
db232882 68
e2a422b8 69 void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
ee8cb548 70 boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *, elf_symbol_type *, int));
e2a422b8
KR
71 boolean (*elf_backend_section_processing) PARAMS ((bfd *, Elf32_Internal_Shdr *));
72 boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *, Elf32_Internal_Shdr *, char *));
73 boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
d5a30a08 74 boolean (*elf_backend_section_from_bfd_section) PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
81187b54
KR
75};
76
d24928c0
KR
77struct elf_sym_extra
78{
79 int elf_sym_num; /* sym# after locals/globals are reordered */
80};
81
82typedef struct elf_sym_extra Elf_Sym_Extra;
83
32090b8e
KR
84struct bfd_elf_arch_map {
85 enum bfd_architecture bfd_arch;
86 int elf_arch;
87};
88
89extern const struct bfd_elf_arch_map bfd_elf_arch_map[];
90extern const int bfd_elf_arch_map_size;
91
92struct bfd_elf_section_data {
93 Elf_Internal_Shdr this_hdr;
94 Elf_Internal_Shdr rel_hdr;
95 int this_idx, rel_idx;
32090b8e
KR
96};
97#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
98#define shdr_name(abfd,shdr) (elf_shstrtab (abfd)->tab + (shdr)->sh_name)
99
100#define get_elf_backend_data(abfd) \
101 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
102
103struct strtab
104{
105 char *tab;
106 int nentries;
107 int length;
108};
109
110/* Some private data is stashed away for future use using the tdata pointer
111 in the bfd structure. */
112
113struct elf_obj_tdata
114{
115 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
116 Elf_Internal_Shdr **elf_sect_ptr;
d79ab07c 117 Elf_Internal_Phdr *phdr;
32090b8e
KR
118 struct strtab *strtab_ptr;
119 int num_locals;
120 int num_globals;
32090b8e 121 Elf_Internal_Sym *internal_syms;
ee8cb548 122 elf_symbol_type *symbols; /* elf_symbol_type */
d24928c0
KR
123 Elf_Sym_Extra *sym_extra;
124 asymbol **section_syms; /* STT_SECTION symbols for each section */
125 int num_section_syms; /* number of section_syms allocated */
32090b8e
KR
126 Elf_Internal_Shdr symtab_hdr;
127 Elf_Internal_Shdr shstrtab_hdr;
128 Elf_Internal_Shdr strtab_hdr;
129 int symtab_section, shstrtab_section, strtab_section;
130 file_ptr next_file_pos;
131 void *prstatus; /* The raw /proc prstatus structure */
132 void *prpsinfo; /* The raw /proc prpsinfo structure */
d5a30a08
ILT
133 bfd_vma gp; /* The gp value (MIPS only, for now) */
134 int gp_size; /* The gp size (MIPS only, for now) */
32090b8e
KR
135};
136
137#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
138#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
139#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
140#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
141#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
142#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
143#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
d24928c0
KR
144#define elf_sym_extra(bfd) (elf_tdata(bfd) -> sym_extra)
145#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
146#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
32090b8e
KR
147#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
148#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
ee8cb548 149#define obj_symbols(bfd) (elf_tdata(bfd) -> symbols)
32090b8e 150#define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
d5a30a08
ILT
151#define elf_gp(bfd) (elf_tdata(bfd) -> gp)
152#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
32090b8e
KR
153
154extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
155extern char * elf_get_str_section PARAMS ((bfd *, unsigned));
156
157#define bfd_elf32_mkobject bfd_elf_mkobject
158#define bfd_elf64_mkobject bfd_elf_mkobject
159#define elf_mkobject bfd_elf_mkobject
160
153cb9ad 161extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *));
7e37f9ff 162
32090b8e
KR
163extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
164 arelent *,
165 asymbol *,
166 PTR,
167 asection *,
168 bfd *));
998ce1e0 169extern boolean bfd_elf_mkobject PARAMS ((bfd *));
e2a422b8
KR
170extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
171
9942e684 172extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
32090b8e
KR
173extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
174
175extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
176extern bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
9942e684
KR
177extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
178extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
179extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
180 bfd *));
181extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
182 file_ptr,
183 bfd_size_type));
7050286d 184
9942e684
KR
185extern unsigned int bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *));
186extern unsigned int bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **));
187extern unsigned int bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
188extern unsigned int bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
189 arelent **,
190 asymbol **));
191extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *));
192extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *,
193 bfd_print_symbol_type));
194extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *,
7050286d 195 symbol_info *));
9942e684
KR
196extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *));
197extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
198 unsigned long));
199extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *,
200 asymbol **,
201 bfd_vma, CONST char **,
202 CONST char **,
203 unsigned int *));
204extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean));
32090b8e 205extern void bfd_elf32__write_relocs PARAMS ((bfd *, asection *, PTR));
e6858d1b 206extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *));
81187b54
KR
207
208/* If the target doesn't have reloc handling written yet: */
9942e684
KR
209extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
210 Elf32_Internal_Rela *));
db232882 211
7d9bb6da
KR
212extern bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
213extern bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
7d9bb6da
KR
214extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
215extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
216extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
217 bfd *));
218extern boolean bfd_elf64_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
219 file_ptr,
220 bfd_size_type));
221
222extern unsigned int bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *));
223extern unsigned int bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **));
224extern unsigned int bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
225extern unsigned int bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
226 arelent **,
227 asymbol **));
228extern asymbol *bfd_elf64_make_empty_symbol PARAMS ((bfd *));
229extern void bfd_elf64_print_symbol PARAMS ((bfd *, PTR, asymbol *,
230 bfd_print_symbol_type));
231extern void bfd_elf64_get_symbol_info PARAMS ((bfd *, asymbol *,
232 symbol_info *));
233extern alent *bfd_elf64_get_lineno PARAMS ((bfd *, asymbol *));
234extern boolean bfd_elf64_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
235 unsigned long));
236extern boolean bfd_elf64_find_nearest_line PARAMS ((bfd *, asection *,
237 asymbol **,
238 bfd_vma, CONST char **,
239 CONST char **,
240 unsigned int *));
241extern int bfd_elf64_sizeof_headers PARAMS ((bfd *, boolean));
32090b8e 242extern void bfd_elf64__write_relocs PARAMS ((bfd *, asection *, PTR));
7d9bb6da
KR
243extern boolean bfd_elf64_new_section_hook PARAMS ((bfd *, asection *));
244
245/* If the target doesn't have reloc handling written yet: */
246extern void bfd_elf64_no_info_to_howto PARAMS ((bfd *, arelent *,
247 Elf64_Internal_Rela *));
248
db232882 249#endif /* _LIBELF_H_ */
This page took 0.062043 seconds and 4 git commands to generate.