]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | ||
81187b54 KR |
24 | #include "elf/common.h" |
25 | #include "elf/internal.h" | |
26 | #include "elf/external.h" | |
27 | ||
638616ca KR |
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.) */ | |
33 | #ifdef __STDC__ | |
34 | #define XCAT2(a,b) CAT(a,b) | |
35 | #define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d)) | |
36 | #else | |
37 | #define CAT4(a,b,c,d) a/**/b/**/c/**/d | |
38 | #endif | |
39 | ||
9942e684 | 40 | #ifndef NAME |
7050286d | 41 | #if ARCH_SIZE==64 |
638616ca | 42 | #define NAME(x,y) CAT4(x,64,_,y) |
9942e684 | 43 | #else /* ARCH_SIZE==32 */ |
638616ca | 44 | #define NAME(x,y) CAT4(x,32,_,y) |
9942e684 KR |
45 | #endif |
46 | #endif | |
47 | ||
638616ca KR |
48 | #define ElfNAME(X) NAME(Elf,X) |
49 | #define elfNAME(X) NAME(elf,X) | |
50 | ||
db232882 KR |
51 | typedef struct |
52 | { | |
53 | asymbol symbol; | |
7050286d KR |
54 | ElfNAME (Internal_Sym) internal_elf_sym; |
55 | ElfNAME (External_Sym) native_elf_sym; | |
db232882 KR |
56 | /* these are used for the generation of .stabX symbols (?) */ |
57 | short desc; | |
58 | unsigned char type; | |
59 | char other; | |
7050286d KR |
60 | union |
61 | { | |
62 | unsigned int hppa_arg_reloc; | |
63 | PTR any; | |
64 | } | |
65 | tc_data; | |
66 | } | |
db232882 | 67 | |
7050286d KR |
68 | elfNAME (symbol_type); |
69 | ||
70 | /* Lacking nested functions and nested types, set up for mapping over | |
71 | BFD sections to produce ELF sections. */ | |
72 | typedef struct | |
73 | { | |
74 | ElfNAME (Internal_Ehdr) * i_ehdr; | |
75 | ElfNAME (Internal_Shdr) * i_shdrp; | |
76 | struct strtab *shstrtab; | |
77 | int symtab_section; | |
78 | } | |
79 | ||
80 | elf_sect_thunk; | |
81 | ||
82 | struct elfNAME(backend_data) | |
83 | { | |
84 | int use_rela_p; | |
85 | int elf_64_p; | |
81187b54 | 86 | enum bfd_architecture arch; |
7050286d KR |
87 | void (*elf_info_to_howto) PARAMS ((bfd *, arelent *, |
88 | ElfNAME (Internal_Rela) *)); | |
89 | void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *, | |
90 | ElfNAME (Internal_Rel) *)); | |
db232882 | 91 | |
8e40bcd8 KR |
92 | /* @@ I really don't think this should be here. I don't know what |
93 | global_sym is supposed to be used for, but I doubt it's something | |
94 | that would be considered global, e.g., if you've got a program | |
95 | reading and writing many BFDs. My hunch is that it's specific to | |
96 | the output BFD. If not, put a comment here explaining why. */ | |
7050286d | 97 | elfNAME (symbol_type) * global_sym; |
81187b54 KR |
98 | }; |
99 | ||
9942e684 KR |
100 | extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *)); |
101 | extern bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *)); | |
102 | extern boolean bfd_elf32_mkobject PARAMS ((bfd *)); | |
103 | extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *)); | |
104 | extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *)); | |
105 | extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *)); | |
106 | extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *, | |
107 | bfd *)); | |
108 | extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, | |
109 | file_ptr, | |
110 | bfd_size_type)); | |
7050286d KR |
111 | |
112 | extern boolean elf_get_sect_thunk PARAMS ((bfd *, elf_sect_thunk *)); | |
9942e684 KR |
113 | extern unsigned int bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *)); |
114 | extern unsigned int bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **)); | |
115 | extern unsigned int bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); | |
116 | extern unsigned int bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr, | |
117 | arelent **, | |
118 | asymbol **)); | |
119 | extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *)); | |
120 | extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *, | |
121 | bfd_print_symbol_type)); | |
122 | extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *, | |
7050286d | 123 | symbol_info *)); |
9942e684 KR |
124 | extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *)); |
125 | extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, | |
126 | unsigned long)); | |
127 | extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *, | |
128 | asymbol **, | |
129 | bfd_vma, CONST char **, | |
130 | CONST char **, | |
131 | unsigned int *)); | |
132 | extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean)); | |
7050286d | 133 | extern unsigned long elf_hash PARAMS ((CONST unsigned char *)); |
e6858d1b | 134 | extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *)); |
81187b54 KR |
135 | |
136 | /* If the target doesn't have reloc handling written yet: */ | |
9942e684 KR |
137 | extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *, |
138 | Elf32_Internal_Rela *)); | |
db232882 | 139 | |
7050286d KR |
140 | #define get_elf_backend_data(abfd) \ |
141 | ((struct elfNAME (backend_data) *) (abfd)->xvec->backend_data) | |
142 | ||
143 | struct strtab | |
144 | { | |
145 | char *tab; | |
146 | int nentries; | |
147 | int length; | |
148 | }; | |
149 | ||
150 | extern struct elf32_internal_shdr * | |
151 | bfd_elf_locate_sh PARAMS ((bfd *, struct strtab *, | |
152 | struct elf32_internal_shdr *, CONST char *)); | |
153 | ||
db232882 | 154 | #endif /* _LIBELF_H_ */ |