Sun Aug 1 22:54:08 1993 Stu Grossman (grossman at cygnus.com)
[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
638616ca
KR
38#define ElfNAME(X) NAME(Elf,X)
39#define elfNAME(X) NAME(elf,X)
40
db232882
KR
41typedef struct
42{
43 asymbol symbol;
268f94ac 44 Elf_Internal_Sym internal_elf_sym;
db232882
KR
45 /* these are used for the generation of .stabX symbols (?) */
46 short desc;
47 unsigned char type;
48 char other;
7050286d
KR
49 union
50 {
51 unsigned int hppa_arg_reloc;
52 PTR any;
53 }
54 tc_data;
998ce1e0
KR
55 Elf32_External_Sym native_elf_sym;
56} elf32_symbol_type;
db232882 57
998ce1e0
KR
58typedef 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;
7050286d 74
268f94ac 75struct elf_backend_data
7050286d
KR
76{
77 int use_rela_p;
78 int elf_64_p;
81187b54 79 enum bfd_architecture arch;
7050286d 80 void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
268f94ac 81 Elf_Internal_Rela *));
7050286d 82 void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
268f94ac 83 Elf_Internal_Rel *));
d79ab07c 84 bfd_vma maxpagesize;
32090b8e 85 void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
db232882 86
8e40bcd8
KR
87 /* @@ I really don't think this should be here. I don't know what
88 global_sym is supposed to be used for, but I doubt it's something
89 that would be considered global, e.g., if you've got a program
90 reading and writing many BFDs. My hunch is that it's specific to
91 the output BFD. If not, put a comment here explaining why. */
998ce1e0
KR
92 /* @@ Was pointer to elfNAME(symbol_type). This makes it size-
93 independent. */
94 PTR global_sym;
81187b54
KR
95};
96
32090b8e
KR
97struct bfd_elf_arch_map {
98 enum bfd_architecture bfd_arch;
99 int elf_arch;
100};
101
102extern const struct bfd_elf_arch_map bfd_elf_arch_map[];
103extern const int bfd_elf_arch_map_size;
104
105struct bfd_elf_section_data {
106 Elf_Internal_Shdr this_hdr;
107 Elf_Internal_Shdr rel_hdr;
108 int this_idx, rel_idx;
109#if 0
110 Elf_Internal_Shdr str_hdr;
111 int str_idx;
112#endif
113};
114#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
115#define shdr_name(abfd,shdr) (elf_shstrtab (abfd)->tab + (shdr)->sh_name)
116
117#define get_elf_backend_data(abfd) \
118 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
119
120struct strtab
121{
122 char *tab;
123 int nentries;
124 int length;
125};
126
127/* Some private data is stashed away for future use using the tdata pointer
128 in the bfd structure. */
129
130struct elf_obj_tdata
131{
132 Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
133 Elf_Internal_Shdr **elf_sect_ptr;
d79ab07c 134 Elf_Internal_Phdr *phdr;
32090b8e
KR
135 struct strtab *strtab_ptr;
136 int num_locals;
137 int num_globals;
138 int *symtab_map;
139 PTR raw_syms; /* Elf_External_Sym* */
140 Elf_Internal_Sym *internal_syms;
141 PTR symbols; /* elf_symbol_type */
142/* struct strtab *shstrtab;*/
143 Elf_Internal_Shdr symtab_hdr;
144 Elf_Internal_Shdr shstrtab_hdr;
145 Elf_Internal_Shdr strtab_hdr;
146 int symtab_section, shstrtab_section, strtab_section;
147 file_ptr next_file_pos;
148 void *prstatus; /* The raw /proc prstatus structure */
149 void *prpsinfo; /* The raw /proc prpsinfo structure */
150};
151
152#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
153#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
154#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
155#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
156#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
157#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
158#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
159#define elf_symtab_map(bfd) (elf_tdata(bfd) -> symtab_map)
160#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
161#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
162#define obj_symbols(bfd) ((elf_symbol_type*)(elf_tdata(bfd) -> symbols))
163#define obj_raw_syms(bfd) ((Elf_External_Sym*)(elf_tdata(bfd) -> raw_syms))
164#define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
165
166extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));
167extern char * elf_get_str_section PARAMS ((bfd *, unsigned));
168
169#define bfd_elf32_mkobject bfd_elf_mkobject
170#define bfd_elf64_mkobject bfd_elf_mkobject
171#define elf_mkobject bfd_elf_mkobject
172
7e37f9ff
KR
173extern unsigned long elf_hash PARAMS ((CONST unsigned char *));
174
32090b8e
KR
175extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
176 arelent *,
177 asymbol *,
178 PTR,
179 asection *,
180 bfd *));
998ce1e0 181extern boolean bfd_elf_mkobject PARAMS ((bfd *));
9942e684 182extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *));
32090b8e
KR
183extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *));
184
185extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
186extern bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
9942e684
KR
187extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
188extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
189extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
190 bfd *));
191extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
192 file_ptr,
193 bfd_size_type));
7050286d 194
9942e684
KR
195extern unsigned int bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *));
196extern unsigned int bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **));
197extern unsigned int bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
198extern unsigned int bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
199 arelent **,
200 asymbol **));
201extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *));
202extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *,
203 bfd_print_symbol_type));
204extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *,
7050286d 205 symbol_info *));
9942e684
KR
206extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *));
207extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
208 unsigned long));
209extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *,
210 asymbol **,
211 bfd_vma, CONST char **,
212 CONST char **,
213 unsigned int *));
214extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean));
32090b8e 215extern void bfd_elf32__write_relocs PARAMS ((bfd *, asection *, PTR));
e6858d1b 216extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *));
81187b54
KR
217
218/* If the target doesn't have reloc handling written yet: */
9942e684
KR
219extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
220 Elf32_Internal_Rela *));
db232882 221
7d9bb6da
KR
222extern bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
223extern bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
7d9bb6da
KR
224extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
225extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
226extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
227 bfd *));
228extern boolean bfd_elf64_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
229 file_ptr,
230 bfd_size_type));
231
232extern unsigned int bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *));
233extern unsigned int bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **));
234extern unsigned int bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
235extern unsigned int bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
236 arelent **,
237 asymbol **));
238extern asymbol *bfd_elf64_make_empty_symbol PARAMS ((bfd *));
239extern void bfd_elf64_print_symbol PARAMS ((bfd *, PTR, asymbol *,
240 bfd_print_symbol_type));
241extern void bfd_elf64_get_symbol_info PARAMS ((bfd *, asymbol *,
242 symbol_info *));
243extern alent *bfd_elf64_get_lineno PARAMS ((bfd *, asymbol *));
244extern boolean bfd_elf64_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
245 unsigned long));
246extern boolean bfd_elf64_find_nearest_line PARAMS ((bfd *, asection *,
247 asymbol **,
248 bfd_vma, CONST char **,
249 CONST char **,
250 unsigned int *));
251extern int bfd_elf64_sizeof_headers PARAMS ((bfd *, boolean));
32090b8e 252extern void bfd_elf64__write_relocs PARAMS ((bfd *, asection *, PTR));
7d9bb6da
KR
253extern boolean bfd_elf64_new_section_hook PARAMS ((bfd *, asection *));
254
255/* If the target doesn't have reloc handling written yet: */
256extern void bfd_elf64_no_info_to_howto PARAMS ((bfd *, arelent *,
257 Elf64_Internal_Rela *));
258
db232882 259#endif /* _LIBELF_H_ */
This page took 0.053835 seconds and 4 git commands to generate.