1 /* BFD back-end data structures for ELF files.
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
3 Written by Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
24 #include "elf/common.h"
25 #include "elf/internal.h"
26 #include "elf/external.h"
28 /* If size isn't specified as 64 or 32, NAME macro should fail. */
31 #define NAME(x,y) CAT4(x,64,_,y)
34 #define NAME(x,y) CAT4(x,32,_,y)
39 #define NAME(x,y) CAT4(x,NOSIZE,_,y)
42 #define ElfNAME(X) NAME(Elf,X)
43 #define elfNAME(X) NAME(elf,X)
48 Elf_Internal_Sym internal_elf_sym
;
49 /* these are used for the generation of .stabX symbols (?) */
55 unsigned int hppa_arg_reloc
;
59 Elf32_External_Sym native_elf_sym
;
65 Elf_Internal_Sym internal_elf_sym
;
66 /* these are used for the generation of .stabX symbols (?) */
72 unsigned int hppa_arg_reloc
;
76 Elf64_External_Sym native_elf_sym
;
79 struct elf_backend_data
83 enum bfd_architecture arch
;
84 void (*elf_info_to_howto
) PARAMS ((bfd
*, arelent
*,
85 Elf_Internal_Rela
*));
86 void (*elf_info_to_howto_rel
) PARAMS ((bfd
*, arelent
*,
89 void (*write_relocs
) PARAMS ((bfd
*, asection
*, PTR
));
91 /* @@ I really don't think this should be here. I don't know what
92 global_sym is supposed to be used for, but I doubt it's something
93 that would be considered global, e.g., if you've got a program
94 reading and writing many BFDs. My hunch is that it's specific to
95 the output BFD. If not, put a comment here explaining why. */
96 /* @@ Was pointer to elfNAME(symbol_type). This makes it size-
101 struct bfd_elf_arch_map
{
102 enum bfd_architecture bfd_arch
;
106 extern const struct bfd_elf_arch_map bfd_elf_arch_map
[];
107 extern const int bfd_elf_arch_map_size
;
109 struct bfd_elf_section_data
{
110 Elf_Internal_Shdr this_hdr
;
111 Elf_Internal_Shdr rel_hdr
;
112 int this_idx
, rel_idx
;
114 Elf_Internal_Shdr str_hdr
;
118 #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
119 #define shdr_name(abfd,shdr) (elf_shstrtab (abfd)->tab + (shdr)->sh_name)
121 #define get_elf_backend_data(abfd) \
122 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
131 /* Some private data is stashed away for future use using the tdata pointer
132 in the bfd structure. */
136 Elf_Internal_Ehdr elf_header
[1]; /* Actual data, but ref like ptr */
137 Elf_Internal_Shdr
**elf_sect_ptr
;
138 Elf_Internal_Phdr
*phdr
;
139 struct strtab
*strtab_ptr
;
143 PTR raw_syms
; /* Elf_External_Sym* */
144 Elf_Internal_Sym
*internal_syms
;
145 PTR symbols
; /* elf_symbol_type */
146 /* struct strtab *shstrtab;*/
147 Elf_Internal_Shdr symtab_hdr
;
148 Elf_Internal_Shdr shstrtab_hdr
;
149 Elf_Internal_Shdr strtab_hdr
;
150 int symtab_section
, shstrtab_section
, strtab_section
;
151 file_ptr next_file_pos
;
152 void *prstatus
; /* The raw /proc prstatus structure */
153 void *prpsinfo
; /* The raw /proc prpsinfo structure */
156 #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
157 #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
158 #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
159 #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
160 #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
161 #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
162 #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
163 #define elf_symtab_map(bfd) (elf_tdata(bfd) -> symtab_map)
164 #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
165 #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
166 #define obj_symbols(bfd) ((elf_symbol_type*)(elf_tdata(bfd) -> symbols))
167 #define obj_raw_syms(bfd) ((Elf_External_Sym*)(elf_tdata(bfd) -> raw_syms))
168 #define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
170 extern char * elf_string_from_elf_section
PARAMS ((bfd
*, unsigned, unsigned));
171 extern char * elf_get_str_section
PARAMS ((bfd
*, unsigned));
173 #define bfd_elf32_mkobject bfd_elf_mkobject
174 #define bfd_elf64_mkobject bfd_elf_mkobject
175 #define elf_mkobject bfd_elf_mkobject
177 extern unsigned long bfd_elf_hash
PARAMS ((CONST
unsigned char *));
179 extern bfd_reloc_status_type bfd_elf_generic_reloc
PARAMS ((bfd
*,
185 extern boolean bfd_elf_mkobject
PARAMS ((bfd
*));
186 extern boolean bfd_elf32_write_object_contents
PARAMS ((bfd
*));
187 extern boolean bfd_elf64_write_object_contents
PARAMS ((bfd
*));
189 extern bfd_target
*bfd_elf32_object_p
PARAMS ((bfd
*));
190 extern bfd_target
*bfd_elf32_core_file_p
PARAMS ((bfd
*));
191 extern char *bfd_elf32_core_file_failing_command
PARAMS ((bfd
*));
192 extern int bfd_elf32_core_file_failing_signal
PARAMS ((bfd
*));
193 extern boolean bfd_elf32_core_file_matches_executable_p
PARAMS ((bfd
*,
195 extern boolean bfd_elf32_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
199 extern unsigned int bfd_elf32_get_symtab_upper_bound
PARAMS ((bfd
*));
200 extern unsigned int bfd_elf32_get_symtab
PARAMS ((bfd
*, asymbol
**));
201 extern unsigned int bfd_elf32_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
202 extern unsigned int bfd_elf32_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
205 extern asymbol
*bfd_elf32_make_empty_symbol
PARAMS ((bfd
*));
206 extern void bfd_elf32_print_symbol
PARAMS ((bfd
*, PTR
, asymbol
*,
207 bfd_print_symbol_type
));
208 extern void bfd_elf32_get_symbol_info
PARAMS ((bfd
*, asymbol
*,
210 extern alent
*bfd_elf32_get_lineno
PARAMS ((bfd
*, asymbol
*));
211 extern boolean bfd_elf32_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
213 extern boolean bfd_elf32_find_nearest_line
PARAMS ((bfd
*, asection
*,
215 bfd_vma
, CONST
char **,
218 extern int bfd_elf32_sizeof_headers
PARAMS ((bfd
*, boolean
));
219 extern void bfd_elf32__write_relocs
PARAMS ((bfd
*, asection
*, PTR
));
220 extern boolean bfd_elf32_new_section_hook
PARAMS ((bfd
*, asection
*));
222 /* If the target doesn't have reloc handling written yet: */
223 extern void bfd_elf32_no_info_to_howto
PARAMS ((bfd
*, arelent
*,
224 Elf32_Internal_Rela
*));
226 extern bfd_target
*bfd_elf64_object_p
PARAMS ((bfd
*));
227 extern bfd_target
*bfd_elf64_core_file_p
PARAMS ((bfd
*));
228 extern char *bfd_elf64_core_file_failing_command
PARAMS ((bfd
*));
229 extern int bfd_elf64_core_file_failing_signal
PARAMS ((bfd
*));
230 extern boolean bfd_elf64_core_file_matches_executable_p
PARAMS ((bfd
*,
232 extern boolean bfd_elf64_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
236 extern unsigned int bfd_elf64_get_symtab_upper_bound
PARAMS ((bfd
*));
237 extern unsigned int bfd_elf64_get_symtab
PARAMS ((bfd
*, asymbol
**));
238 extern unsigned int bfd_elf64_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
239 extern unsigned int bfd_elf64_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
242 extern asymbol
*bfd_elf64_make_empty_symbol
PARAMS ((bfd
*));
243 extern void bfd_elf64_print_symbol
PARAMS ((bfd
*, PTR
, asymbol
*,
244 bfd_print_symbol_type
));
245 extern void bfd_elf64_get_symbol_info
PARAMS ((bfd
*, asymbol
*,
247 extern alent
*bfd_elf64_get_lineno
PARAMS ((bfd
*, asymbol
*));
248 extern boolean bfd_elf64_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
250 extern boolean bfd_elf64_find_nearest_line
PARAMS ((bfd
*, asection
*,
252 bfd_vma
, CONST
char **,
255 extern int bfd_elf64_sizeof_headers
PARAMS ((bfd
*, boolean
));
256 extern void bfd_elf64__write_relocs
PARAMS ((bfd
*, asection
*, PTR
));
257 extern boolean bfd_elf64_new_section_hook
PARAMS ((bfd
*, asection
*));
259 /* If the target doesn't have reloc handling written yet: */
260 extern void bfd_elf64_no_info_to_howto
PARAMS ((bfd
*, arelent
*,
261 Elf64_Internal_Rela
*));
263 #endif /* _LIBELF_H_ */