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 /* This CAT4 hack is to avoid a problem with some strict ANSI C preprocessors.
29 The problem is, "32_" is not a valid preprocessing token, and we don't
30 want extra underscores (e.g., "elf_32_"). The XCAT2 macro will cause the
31 inner CAT macros to be evaluated first, producing still-valid pp-tokens.
32 Then the final concatenation can be done. (Sigh.) */
34 #define CAT4(a,b,c,d) a##b##c##d
37 #define XCAT2(a,b) CAT(a,b)
38 #define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d))
40 #define CAT4(a,b,c,d) a/**/b/**/c/**/d
44 /* If size isn't specified as 64 or 32, NAME macro should fail. */
47 #define NAME(x,y) CAT4(x,64,_,y)
50 #define NAME(x,y) CAT4(x,32,_,y)
54 #define ElfNAME(X) NAME(Elf,X)
55 #define elfNAME(X) NAME(elf,X)
60 Elf_Internal_Sym internal_elf_sym
;
61 /* these are used for the generation of .stabX symbols (?) */
67 unsigned int hppa_arg_reloc
;
71 Elf32_External_Sym native_elf_sym
;
77 Elf_Internal_Sym internal_elf_sym
;
78 /* these are used for the generation of .stabX symbols (?) */
84 unsigned int hppa_arg_reloc
;
88 Elf64_External_Sym native_elf_sym
;
91 /* Lacking nested functions and nested types, set up for mapping over
92 BFD sections to produce ELF sections. */
95 Elf_Internal_Ehdr
* i_ehdr
;
96 Elf_Internal_Shdr
* i_shdrp
;
97 struct strtab
*shstrtab
;
102 struct elf_backend_data
106 enum bfd_architecture arch
;
107 void (*elf_info_to_howto
) PARAMS ((bfd
*, arelent
*,
108 Elf_Internal_Rela
*));
109 void (*elf_info_to_howto_rel
) PARAMS ((bfd
*, arelent
*,
110 Elf_Internal_Rel
*));
112 /* @@ I really don't think this should be here. I don't know what
113 global_sym is supposed to be used for, but I doubt it's something
114 that would be considered global, e.g., if you've got a program
115 reading and writing many BFDs. My hunch is that it's specific to
116 the output BFD. If not, put a comment here explaining why. */
117 /* @@ Was pointer to elfNAME(symbol_type). This makes it size-
122 extern bfd_target
*bfd_elf32_object_p
PARAMS ((bfd
*));
123 extern bfd_target
*bfd_elf32_core_file_p
PARAMS ((bfd
*));
124 extern boolean bfd_elf_mkobject
PARAMS ((bfd
*));
125 extern boolean bfd_elf32_write_object_contents
PARAMS ((bfd
*));
126 extern char *bfd_elf32_core_file_failing_command
PARAMS ((bfd
*));
127 extern int bfd_elf32_core_file_failing_signal
PARAMS ((bfd
*));
128 extern boolean bfd_elf32_core_file_matches_executable_p
PARAMS ((bfd
*,
130 extern boolean bfd_elf32_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
134 extern boolean elf_get_sect_thunk
PARAMS ((bfd
*, elf_sect_thunk
*));
135 extern unsigned int bfd_elf32_get_symtab_upper_bound
PARAMS ((bfd
*));
136 extern unsigned int bfd_elf32_get_symtab
PARAMS ((bfd
*, asymbol
**));
137 extern unsigned int bfd_elf32_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
138 extern unsigned int bfd_elf32_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
141 extern asymbol
*bfd_elf32_make_empty_symbol
PARAMS ((bfd
*));
142 extern void bfd_elf32_print_symbol
PARAMS ((bfd
*, PTR
, asymbol
*,
143 bfd_print_symbol_type
));
144 extern void bfd_elf32_get_symbol_info
PARAMS ((bfd
*, asymbol
*,
146 extern alent
*bfd_elf32_get_lineno
PARAMS ((bfd
*, asymbol
*));
147 extern boolean bfd_elf32_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
149 extern boolean bfd_elf32_find_nearest_line
PARAMS ((bfd
*, asection
*,
151 bfd_vma
, CONST
char **,
154 extern int bfd_elf32_sizeof_headers
PARAMS ((bfd
*, boolean
));
155 extern unsigned long elf_hash
PARAMS ((CONST
unsigned char *));
156 extern boolean bfd_elf32_new_section_hook
PARAMS ((bfd
*, asection
*));
158 /* If the target doesn't have reloc handling written yet: */
159 extern void bfd_elf32_no_info_to_howto
PARAMS ((bfd
*, arelent
*,
160 Elf32_Internal_Rela
*));
162 extern bfd_target
*bfd_elf64_object_p
PARAMS ((bfd
*));
163 extern bfd_target
*bfd_elf64_core_file_p
PARAMS ((bfd
*));
164 extern boolean bfd_elf64_write_object_contents
PARAMS ((bfd
*));
165 extern char *bfd_elf64_core_file_failing_command
PARAMS ((bfd
*));
166 extern int bfd_elf64_core_file_failing_signal
PARAMS ((bfd
*));
167 extern boolean bfd_elf64_core_file_matches_executable_p
PARAMS ((bfd
*,
169 extern boolean bfd_elf64_set_section_contents
PARAMS ((bfd
*, sec_ptr
, PTR
,
173 extern unsigned int bfd_elf64_get_symtab_upper_bound
PARAMS ((bfd
*));
174 extern unsigned int bfd_elf64_get_symtab
PARAMS ((bfd
*, asymbol
**));
175 extern unsigned int bfd_elf64_get_reloc_upper_bound
PARAMS ((bfd
*, sec_ptr
));
176 extern unsigned int bfd_elf64_canonicalize_reloc
PARAMS ((bfd
*, sec_ptr
,
179 extern asymbol
*bfd_elf64_make_empty_symbol
PARAMS ((bfd
*));
180 extern void bfd_elf64_print_symbol
PARAMS ((bfd
*, PTR
, asymbol
*,
181 bfd_print_symbol_type
));
182 extern void bfd_elf64_get_symbol_info
PARAMS ((bfd
*, asymbol
*,
184 extern alent
*bfd_elf64_get_lineno
PARAMS ((bfd
*, asymbol
*));
185 extern boolean bfd_elf64_set_arch_mach
PARAMS ((bfd
*, enum bfd_architecture
,
187 extern boolean bfd_elf64_find_nearest_line
PARAMS ((bfd
*, asection
*,
189 bfd_vma
, CONST
char **,
192 extern int bfd_elf64_sizeof_headers
PARAMS ((bfd
*, boolean
));
193 extern boolean bfd_elf64_new_section_hook
PARAMS ((bfd
*, asection
*));
195 /* If the target doesn't have reloc handling written yet: */
196 extern void bfd_elf64_no_info_to_howto
PARAMS ((bfd
*, arelent
*,
197 Elf64_Internal_Rela
*));
199 #define get_elf_backend_data(abfd) \
200 ((struct elf_backend_data *) (abfd)->xvec->backend_data)
209 extern struct elf32_internal_shdr
*
210 bfd_elf_locate_sh
PARAMS ((bfd
*, struct strtab
*,
211 struct elf32_internal_shdr
*, CONST
char *));
213 /* Some private data is stashed away for future use using the tdata pointer
214 in the bfd structure. */
218 Elf_Internal_Ehdr elf_header
[1]; /* Actual data, but ref like ptr */
219 Elf_Internal_Shdr
*elf_sect_ptr
;
220 struct strtab
*strtab_ptr
;
225 void *prstatus
; /* The raw /proc prstatus structure */
226 void *prpsinfo
; /* The raw /proc prpsinfo structure */
227 PTR raw_syms
; /* Elf_External_Sym* */
228 Elf_Internal_Sym
*internal_syms
;
229 PTR symbols
; /* elf_symbol_type */
232 #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
233 #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
234 #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
235 #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
236 #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
237 #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
238 #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
239 #define elf_symtab_map(bfd) (elf_tdata(bfd) -> symtab_map)
240 #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
241 #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
242 #define obj_symbols(bfd) ((elf_symbol_type*)(elf_tdata(bfd) -> symbols))
243 #define obj_raw_syms(bfd) ((Elf_External_Sym*)(elf_tdata(bfd) -> raw_syms))
244 #define obj_internal_syms(bfd) (elf_tdata(bfd) -> internal_syms)
246 extern char * elf_string_from_elf_section ();
247 extern char * elf_get_str_section ();
249 #define bfd_elf32_mkobject bfd_elf_mkobject
250 #define bfd_elf64_mkobject bfd_elf_mkobject
251 #define elf_mkobject bfd_elf_mkobject
253 #endif /* _LIBELF_H_ */