* elfxx-target.h (bfd_elfNN_bfd_link_add_symbols): Define.
[deliverable/binutils-gdb.git] / bfd / elfcode.h
1 /* ELF executable support for BFD.
2 Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003 Free Software Foundation, Inc.
4
5 Written by Fred Fish @ Cygnus Support, from information published
6 in "UNIX System V Release 4, Programmers Guide: ANSI C and
7 Programming Support Tools". Sufficient support for gdb.
8
9 Rewritten by Mark Eichin @ Cygnus Support, from information
10 published in "System V Application Binary Interface", chapters 4
11 and 5, as well as the various "Processor Supplement" documents
12 derived from it. Added support for assembler and other object file
13 utilities. Further work done by Ken Raeburn (Cygnus Support), Michael
14 Meissner (Open Software Foundation), and Peter Hoogenboom (University
15 of Utah) to finish and extend this.
16
17 This file is part of BFD, the Binary File Descriptor library.
18
19 This program is free software; you can redistribute it and/or modify
20 it under the terms of the GNU General Public License as published by
21 the Free Software Foundation; either version 2 of the License, or
22 (at your option) any later version.
23
24 This program is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 GNU General Public License for more details.
28
29 You should have received a copy of the GNU General Public License
30 along with this program; if not, write to the Free Software
31 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
32
33 /* Problems and other issues to resolve.
34
35 (1) BFD expects there to be some fixed number of "sections" in
36 the object file. I.E. there is a "section_count" variable in the
37 bfd structure which contains the number of sections. However, ELF
38 supports multiple "views" of a file. In particular, with current
39 implementations, executable files typically have two tables, a
40 program header table and a section header table, both of which
41 partition the executable.
42
43 In ELF-speak, the "linking view" of the file uses the section header
44 table to access "sections" within the file, and the "execution view"
45 uses the program header table to access "segments" within the file.
46 "Segments" typically may contain all the data from one or more
47 "sections".
48
49 Note that the section header table is optional in ELF executables,
50 but it is this information that is most useful to gdb. If the
51 section header table is missing, then gdb should probably try
52 to make do with the program header table. (FIXME)
53
54 (2) The code in this file is compiled twice, once in 32-bit mode and
55 once in 64-bit mode. More of it should be made size-independent
56 and moved into elf.c.
57
58 (3) ELF section symbols are handled rather sloppily now. This should
59 be cleaned up, and ELF section symbols reconciled with BFD section
60 symbols.
61
62 (4) We need a published spec for 64-bit ELF. We've got some stuff here
63 that we're using for SPARC V9 64-bit chips, but don't assume that
64 it's cast in stone.
65 */
66
67 #include "bfd.h"
68 #include "sysdep.h"
69 #include "libiberty.h"
70 #include "bfdlink.h"
71 #include "libbfd.h"
72 #include "elf-bfd.h"
73
74 /* Renaming structures, typedefs, macros and functions to be size-specific. */
75 #define Elf_External_Ehdr NAME(Elf,External_Ehdr)
76 #define Elf_External_Sym NAME(Elf,External_Sym)
77 #define Elf_External_Shdr NAME(Elf,External_Shdr)
78 #define Elf_External_Phdr NAME(Elf,External_Phdr)
79 #define Elf_External_Rel NAME(Elf,External_Rel)
80 #define Elf_External_Rela NAME(Elf,External_Rela)
81 #define Elf_External_Dyn NAME(Elf,External_Dyn)
82
83 #define elf_core_file_failing_command NAME(bfd_elf,core_file_failing_command)
84 #define elf_core_file_failing_signal NAME(bfd_elf,core_file_failing_signal)
85 #define elf_core_file_matches_executable_p \
86 NAME(bfd_elf,core_file_matches_executable_p)
87 #define elf_object_p NAME(bfd_elf,object_p)
88 #define elf_core_file_p NAME(bfd_elf,core_file_p)
89 #define elf_get_symtab_upper_bound NAME(bfd_elf,get_symtab_upper_bound)
90 #define elf_get_dynamic_symtab_upper_bound \
91 NAME(bfd_elf,get_dynamic_symtab_upper_bound)
92 #define elf_swap_reloc_in NAME(bfd_elf,swap_reloc_in)
93 #define elf_swap_reloca_in NAME(bfd_elf,swap_reloca_in)
94 #define elf_swap_reloc_out NAME(bfd_elf,swap_reloc_out)
95 #define elf_swap_reloca_out NAME(bfd_elf,swap_reloca_out)
96 #define elf_swap_symbol_in NAME(bfd_elf,swap_symbol_in)
97 #define elf_swap_symbol_out NAME(bfd_elf,swap_symbol_out)
98 #define elf_swap_phdr_in NAME(bfd_elf,swap_phdr_in)
99 #define elf_swap_phdr_out NAME(bfd_elf,swap_phdr_out)
100 #define elf_swap_dyn_in NAME(bfd_elf,swap_dyn_in)
101 #define elf_swap_dyn_out NAME(bfd_elf,swap_dyn_out)
102 #define elf_get_reloc_upper_bound NAME(bfd_elf,get_reloc_upper_bound)
103 #define elf_canonicalize_reloc NAME(bfd_elf,canonicalize_reloc)
104 #define elf_slurp_symbol_table NAME(bfd_elf,slurp_symbol_table)
105 #define elf_canonicalize_symtab NAME(bfd_elf,canonicalize_symtab)
106 #define elf_canonicalize_dynamic_symtab \
107 NAME(bfd_elf,canonicalize_dynamic_symtab)
108 #define elf_make_empty_symbol NAME(bfd_elf,make_empty_symbol)
109 #define elf_get_symbol_info NAME(bfd_elf,get_symbol_info)
110 #define elf_get_lineno NAME(bfd_elf,get_lineno)
111 #define elf_set_arch_mach NAME(bfd_elf,set_arch_mach)
112 #define elf_find_nearest_line NAME(bfd_elf,find_nearest_line)
113 #define elf_sizeof_headers NAME(bfd_elf,sizeof_headers)
114 #define elf_set_section_contents NAME(bfd_elf,set_section_contents)
115 #define elf_no_info_to_howto NAME(bfd_elf,no_info_to_howto)
116 #define elf_no_info_to_howto_rel NAME(bfd_elf,no_info_to_howto_rel)
117 #define elf_find_section NAME(bfd_elf,find_section)
118 #define elf_write_shdrs_and_ehdr NAME(bfd_elf,write_shdrs_and_ehdr)
119 #define elf_write_out_phdrs NAME(bfd_elf,write_out_phdrs)
120 #define elf_write_relocs NAME(bfd_elf,write_relocs)
121 #define elf_slurp_reloc_table NAME(bfd_elf,slurp_reloc_table)
122 #define elf_bfd_discard_info NAME(bfd_elf,discard_info)
123 #define elf_reloc_symbol_deleted_p NAME(_bfd_elf,reloc_symbol_deleted_p)
124 #define elf_link_record_dynamic_symbol _bfd_elf_link_record_dynamic_symbol
125 #define elf_bfd_final_link NAME(bfd_elf,bfd_final_link)
126 #define elf_gc_sections NAME(_bfd_elf,gc_sections)
127 #define elf_gc_common_finalize_got_offsets \
128 NAME(_bfd_elf,gc_common_finalize_got_offsets)
129 #define elf_gc_common_final_link NAME(_bfd_elf,gc_common_final_link)
130 #define elf_gc_record_vtinherit NAME(_bfd_elf,gc_record_vtinherit)
131 #define elf_gc_record_vtentry NAME(_bfd_elf,gc_record_vtentry)
132 #define elf_link_record_local_dynamic_symbol \
133 NAME(_bfd_elf,link_record_local_dynamic_symbol)
134
135 #if ARCH_SIZE == 64
136 #define ELF_R_INFO(X,Y) ELF64_R_INFO(X,Y)
137 #define ELF_R_SYM(X) ELF64_R_SYM(X)
138 #define ELF_R_TYPE(X) ELF64_R_TYPE(X)
139 #define ELFCLASS ELFCLASS64
140 #define FILE_ALIGN 8
141 #define LOG_FILE_ALIGN 3
142 #endif
143 #if ARCH_SIZE == 32
144 #define ELF_R_INFO(X,Y) ELF32_R_INFO(X,Y)
145 #define ELF_R_SYM(X) ELF32_R_SYM(X)
146 #define ELF_R_TYPE(X) ELF32_R_TYPE(X)
147 #define ELFCLASS ELFCLASS32
148 #define FILE_ALIGN 4
149 #define LOG_FILE_ALIGN 2
150 #endif
151
152 #define elf_stringtab_init _bfd_elf_stringtab_init
153
154 #define section_from_elf_index bfd_section_from_elf_index
155
156 #ifdef DEBUG
157 static void elf_debug_section (int, Elf_Internal_Shdr *);
158 static void elf_debug_file (Elf_Internal_Ehdr *);
159 static char *elf_symbol_flags (flagword);
160 #endif
161 \f
162 /* Structure swapping routines */
163
164 /* Should perhaps use put_offset, put_word, etc. For now, the two versions
165 can be handled by explicitly specifying 32 bits or "the long type". */
166 #if ARCH_SIZE == 64
167 #define H_PUT_WORD H_PUT_64
168 #define H_PUT_SIGNED_WORD H_PUT_S64
169 #define H_GET_WORD H_GET_64
170 #define H_GET_SIGNED_WORD H_GET_S64
171 #endif
172 #if ARCH_SIZE == 32
173 #define H_PUT_WORD H_PUT_32
174 #define H_PUT_SIGNED_WORD H_PUT_S32
175 #define H_GET_WORD H_GET_32
176 #define H_GET_SIGNED_WORD H_GET_S32
177 #endif
178
179 /* Translate an ELF symbol in external format into an ELF symbol in internal
180 format. */
181
182 void
183 elf_swap_symbol_in (bfd *abfd,
184 const void *psrc,
185 const void *pshn,
186 Elf_Internal_Sym *dst)
187 {
188 const Elf_External_Sym *src = psrc;
189 const Elf_External_Sym_Shndx *shndx = pshn;
190 int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
191
192 dst->st_name = H_GET_32 (abfd, src->st_name);
193 if (signed_vma)
194 dst->st_value = H_GET_SIGNED_WORD (abfd, src->st_value);
195 else
196 dst->st_value = H_GET_WORD (abfd, src->st_value);
197 dst->st_size = H_GET_WORD (abfd, src->st_size);
198 dst->st_info = H_GET_8 (abfd, src->st_info);
199 dst->st_other = H_GET_8 (abfd, src->st_other);
200 dst->st_shndx = H_GET_16 (abfd, src->st_shndx);
201 if (dst->st_shndx == SHN_XINDEX)
202 {
203 if (shndx == NULL)
204 abort ();
205 dst->st_shndx = H_GET_32 (abfd, shndx->est_shndx);
206 }
207 }
208
209 /* Translate an ELF symbol in internal format into an ELF symbol in external
210 format. */
211
212 void
213 elf_swap_symbol_out (bfd *abfd,
214 const Elf_Internal_Sym *src,
215 void *cdst,
216 void *shndx)
217 {
218 unsigned int tmp;
219 Elf_External_Sym *dst = cdst;
220 H_PUT_32 (abfd, src->st_name, dst->st_name);
221 H_PUT_WORD (abfd, src->st_value, dst->st_value);
222 H_PUT_WORD (abfd, src->st_size, dst->st_size);
223 H_PUT_8 (abfd, src->st_info, dst->st_info);
224 H_PUT_8 (abfd, src->st_other, dst->st_other);
225 tmp = src->st_shndx;
226 if (tmp > SHN_HIRESERVE)
227 {
228 if (shndx == NULL)
229 abort ();
230 H_PUT_32 (abfd, tmp, shndx);
231 tmp = SHN_XINDEX;
232 }
233 H_PUT_16 (abfd, tmp, dst->st_shndx);
234 }
235
236 /* Translate an ELF file header in external format into an ELF file header in
237 internal format. */
238
239 static void
240 elf_swap_ehdr_in (bfd *abfd,
241 const Elf_External_Ehdr *src,
242 Elf_Internal_Ehdr *dst)
243 {
244 int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
245 memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
246 dst->e_type = H_GET_16 (abfd, src->e_type);
247 dst->e_machine = H_GET_16 (abfd, src->e_machine);
248 dst->e_version = H_GET_32 (abfd, src->e_version);
249 if (signed_vma)
250 dst->e_entry = H_GET_SIGNED_WORD (abfd, src->e_entry);
251 else
252 dst->e_entry = H_GET_WORD (abfd, src->e_entry);
253 dst->e_phoff = H_GET_WORD (abfd, src->e_phoff);
254 dst->e_shoff = H_GET_WORD (abfd, src->e_shoff);
255 dst->e_flags = H_GET_32 (abfd, src->e_flags);
256 dst->e_ehsize = H_GET_16 (abfd, src->e_ehsize);
257 dst->e_phentsize = H_GET_16 (abfd, src->e_phentsize);
258 dst->e_phnum = H_GET_16 (abfd, src->e_phnum);
259 dst->e_shentsize = H_GET_16 (abfd, src->e_shentsize);
260 dst->e_shnum = H_GET_16 (abfd, src->e_shnum);
261 dst->e_shstrndx = H_GET_16 (abfd, src->e_shstrndx);
262 }
263
264 /* Translate an ELF file header in internal format into an ELF file header in
265 external format. */
266
267 static void
268 elf_swap_ehdr_out (bfd *abfd,
269 const Elf_Internal_Ehdr *src,
270 Elf_External_Ehdr *dst)
271 {
272 unsigned int tmp;
273 int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
274 memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
275 /* note that all elements of dst are *arrays of unsigned char* already... */
276 H_PUT_16 (abfd, src->e_type, dst->e_type);
277 H_PUT_16 (abfd, src->e_machine, dst->e_machine);
278 H_PUT_32 (abfd, src->e_version, dst->e_version);
279 if (signed_vma)
280 H_PUT_SIGNED_WORD (abfd, src->e_entry, dst->e_entry);
281 else
282 H_PUT_WORD (abfd, src->e_entry, dst->e_entry);
283 H_PUT_WORD (abfd, src->e_phoff, dst->e_phoff);
284 H_PUT_WORD (abfd, src->e_shoff, dst->e_shoff);
285 H_PUT_32 (abfd, src->e_flags, dst->e_flags);
286 H_PUT_16 (abfd, src->e_ehsize, dst->e_ehsize);
287 H_PUT_16 (abfd, src->e_phentsize, dst->e_phentsize);
288 H_PUT_16 (abfd, src->e_phnum, dst->e_phnum);
289 H_PUT_16 (abfd, src->e_shentsize, dst->e_shentsize);
290 tmp = src->e_shnum;
291 if (tmp >= SHN_LORESERVE)
292 tmp = SHN_UNDEF;
293 H_PUT_16 (abfd, tmp, dst->e_shnum);
294 tmp = src->e_shstrndx;
295 if (tmp >= SHN_LORESERVE)
296 tmp = SHN_XINDEX;
297 H_PUT_16 (abfd, tmp, dst->e_shstrndx);
298 }
299
300 /* Translate an ELF section header table entry in external format into an
301 ELF section header table entry in internal format. */
302
303 static void
304 elf_swap_shdr_in (bfd *abfd,
305 const Elf_External_Shdr *src,
306 Elf_Internal_Shdr *dst)
307 {
308 int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
309
310 dst->sh_name = H_GET_32 (abfd, src->sh_name);
311 dst->sh_type = H_GET_32 (abfd, src->sh_type);
312 dst->sh_flags = H_GET_WORD (abfd, src->sh_flags);
313 if (signed_vma)
314 dst->sh_addr = H_GET_SIGNED_WORD (abfd, src->sh_addr);
315 else
316 dst->sh_addr = H_GET_WORD (abfd, src->sh_addr);
317 dst->sh_offset = H_GET_WORD (abfd, src->sh_offset);
318 dst->sh_size = H_GET_WORD (abfd, src->sh_size);
319 dst->sh_link = H_GET_32 (abfd, src->sh_link);
320 dst->sh_info = H_GET_32 (abfd, src->sh_info);
321 dst->sh_addralign = H_GET_WORD (abfd, src->sh_addralign);
322 dst->sh_entsize = H_GET_WORD (abfd, src->sh_entsize);
323 dst->bfd_section = NULL;
324 dst->contents = NULL;
325 }
326
327 /* Translate an ELF section header table entry in internal format into an
328 ELF section header table entry in external format. */
329
330 static void
331 elf_swap_shdr_out (bfd *abfd,
332 const Elf_Internal_Shdr *src,
333 Elf_External_Shdr *dst)
334 {
335 /* note that all elements of dst are *arrays of unsigned char* already... */
336 H_PUT_32 (abfd, src->sh_name, dst->sh_name);
337 H_PUT_32 (abfd, src->sh_type, dst->sh_type);
338 H_PUT_WORD (abfd, src->sh_flags, dst->sh_flags);
339 H_PUT_WORD (abfd, src->sh_addr, dst->sh_addr);
340 H_PUT_WORD (abfd, src->sh_offset, dst->sh_offset);
341 H_PUT_WORD (abfd, src->sh_size, dst->sh_size);
342 H_PUT_32 (abfd, src->sh_link, dst->sh_link);
343 H_PUT_32 (abfd, src->sh_info, dst->sh_info);
344 H_PUT_WORD (abfd, src->sh_addralign, dst->sh_addralign);
345 H_PUT_WORD (abfd, src->sh_entsize, dst->sh_entsize);
346 }
347
348 /* Translate an ELF program header table entry in external format into an
349 ELF program header table entry in internal format. */
350
351 void
352 elf_swap_phdr_in (bfd *abfd,
353 const Elf_External_Phdr *src,
354 Elf_Internal_Phdr *dst)
355 {
356 int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
357
358 dst->p_type = H_GET_32 (abfd, src->p_type);
359 dst->p_flags = H_GET_32 (abfd, src->p_flags);
360 dst->p_offset = H_GET_WORD (abfd, src->p_offset);
361 if (signed_vma)
362 {
363 dst->p_vaddr = H_GET_SIGNED_WORD (abfd, src->p_vaddr);
364 dst->p_paddr = H_GET_SIGNED_WORD (abfd, src->p_paddr);
365 }
366 else
367 {
368 dst->p_vaddr = H_GET_WORD (abfd, src->p_vaddr);
369 dst->p_paddr = H_GET_WORD (abfd, src->p_paddr);
370 }
371 dst->p_filesz = H_GET_WORD (abfd, src->p_filesz);
372 dst->p_memsz = H_GET_WORD (abfd, src->p_memsz);
373 dst->p_align = H_GET_WORD (abfd, src->p_align);
374 }
375
376 void
377 elf_swap_phdr_out (bfd *abfd,
378 const Elf_Internal_Phdr *src,
379 Elf_External_Phdr *dst)
380 {
381 /* note that all elements of dst are *arrays of unsigned char* already... */
382 H_PUT_32 (abfd, src->p_type, dst->p_type);
383 H_PUT_WORD (abfd, src->p_offset, dst->p_offset);
384 H_PUT_WORD (abfd, src->p_vaddr, dst->p_vaddr);
385 H_PUT_WORD (abfd, src->p_paddr, dst->p_paddr);
386 H_PUT_WORD (abfd, src->p_filesz, dst->p_filesz);
387 H_PUT_WORD (abfd, src->p_memsz, dst->p_memsz);
388 H_PUT_32 (abfd, src->p_flags, dst->p_flags);
389 H_PUT_WORD (abfd, src->p_align, dst->p_align);
390 }
391
392 /* Translate an ELF reloc from external format to internal format. */
393 void
394 elf_swap_reloc_in (bfd *abfd,
395 const bfd_byte *s,
396 Elf_Internal_Rela *dst)
397 {
398 const Elf_External_Rel *src = (const Elf_External_Rel *) s;
399 dst->r_offset = H_GET_WORD (abfd, src->r_offset);
400 dst->r_info = H_GET_WORD (abfd, src->r_info);
401 dst->r_addend = 0;
402 }
403
404 void
405 elf_swap_reloca_in (bfd *abfd,
406 const bfd_byte *s,
407 Elf_Internal_Rela *dst)
408 {
409 const Elf_External_Rela *src = (const Elf_External_Rela *) s;
410 dst->r_offset = H_GET_WORD (abfd, src->r_offset);
411 dst->r_info = H_GET_WORD (abfd, src->r_info);
412 dst->r_addend = H_GET_SIGNED_WORD (abfd, src->r_addend);
413 }
414
415 /* Translate an ELF reloc from internal format to external format. */
416 void
417 elf_swap_reloc_out (bfd *abfd,
418 const Elf_Internal_Rela *src,
419 bfd_byte *d)
420 {
421 Elf_External_Rel *dst = (Elf_External_Rel *) d;
422 H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
423 H_PUT_WORD (abfd, src->r_info, dst->r_info);
424 }
425
426 void
427 elf_swap_reloca_out (bfd *abfd,
428 const Elf_Internal_Rela *src,
429 bfd_byte *d)
430 {
431 Elf_External_Rela *dst = (Elf_External_Rela *) d;
432 H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
433 H_PUT_WORD (abfd, src->r_info, dst->r_info);
434 H_PUT_SIGNED_WORD (abfd, src->r_addend, dst->r_addend);
435 }
436
437 void
438 elf_swap_dyn_in (bfd *abfd,
439 const void *p,
440 Elf_Internal_Dyn *dst)
441 {
442 const Elf_External_Dyn *src = p;
443
444 dst->d_tag = H_GET_WORD (abfd, src->d_tag);
445 dst->d_un.d_val = H_GET_WORD (abfd, src->d_un.d_val);
446 }
447
448 void
449 elf_swap_dyn_out (bfd *abfd,
450 const Elf_Internal_Dyn *src,
451 void *p)
452 {
453 Elf_External_Dyn *dst = p;
454
455 H_PUT_WORD (abfd, src->d_tag, dst->d_tag);
456 H_PUT_WORD (abfd, src->d_un.d_val, dst->d_un.d_val);
457 }
458 \f
459 /* ELF .o/exec file reading */
460
461 /* Begin processing a given object.
462
463 First we validate the file by reading in the ELF header and checking
464 the magic number. */
465
466 static inline bfd_boolean
467 elf_file_p (Elf_External_Ehdr *x_ehdrp)
468 {
469 return ((x_ehdrp->e_ident[EI_MAG0] == ELFMAG0)
470 && (x_ehdrp->e_ident[EI_MAG1] == ELFMAG1)
471 && (x_ehdrp->e_ident[EI_MAG2] == ELFMAG2)
472 && (x_ehdrp->e_ident[EI_MAG3] == ELFMAG3));
473 }
474
475 /* Check to see if the file associated with ABFD matches the target vector
476 that ABFD points to.
477
478 Note that we may be called several times with the same ABFD, but different
479 target vectors, most of which will not match. We have to avoid leaving
480 any side effects in ABFD, or any data it points to (like tdata), if the
481 file does not match the target vector. */
482
483 const bfd_target *
484 elf_object_p (bfd *abfd)
485 {
486 Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
487 Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
488 Elf_External_Shdr x_shdr; /* Section header table entry, external form */
489 Elf_Internal_Shdr i_shdr;
490 Elf_Internal_Shdr *i_shdrp; /* Section header table, internal form */
491 unsigned int shindex;
492 char *shstrtab; /* Internal copy of section header stringtab */
493 const struct elf_backend_data *ebd;
494 struct bfd_preserve preserve;
495 asection *s;
496 bfd_size_type amt;
497
498 preserve.marker = NULL;
499
500 /* Read in the ELF header in external format. */
501
502 if (bfd_bread (&x_ehdr, sizeof (x_ehdr), abfd) != sizeof (x_ehdr))
503 {
504 if (bfd_get_error () != bfd_error_system_call)
505 goto got_wrong_format_error;
506 else
507 goto got_no_match;
508 }
509
510 /* Now check to see if we have a valid ELF file, and one that BFD can
511 make use of. The magic number must match, the address size ('class')
512 and byte-swapping must match our XVEC entry, and it must have a
513 section header table (FIXME: See comments re sections at top of this
514 file). */
515
516 if (! elf_file_p (&x_ehdr)
517 || x_ehdr.e_ident[EI_VERSION] != EV_CURRENT
518 || x_ehdr.e_ident[EI_CLASS] != ELFCLASS)
519 goto got_wrong_format_error;
520
521 /* Check that file's byte order matches xvec's */
522 switch (x_ehdr.e_ident[EI_DATA])
523 {
524 case ELFDATA2MSB: /* Big-endian */
525 if (! bfd_header_big_endian (abfd))
526 goto got_wrong_format_error;
527 break;
528 case ELFDATA2LSB: /* Little-endian */
529 if (! bfd_header_little_endian (abfd))
530 goto got_wrong_format_error;
531 break;
532 case ELFDATANONE: /* No data encoding specified */
533 default: /* Unknown data encoding specified */
534 goto got_wrong_format_error;
535 }
536
537 if (!bfd_preserve_save (abfd, &preserve))
538 goto got_no_match;
539
540 /* Allocate an instance of the elf_obj_tdata structure and hook it up to
541 the tdata pointer in the bfd. */
542
543 if (! (*abfd->xvec->_bfd_set_format[bfd_object]) (abfd))
544 goto got_no_match;
545 preserve.marker = elf_tdata (abfd);
546
547 /* Now that we know the byte order, swap in the rest of the header */
548 i_ehdrp = elf_elfheader (abfd);
549 elf_swap_ehdr_in (abfd, &x_ehdr, i_ehdrp);
550 #if DEBUG & 1
551 elf_debug_file (i_ehdrp);
552 #endif
553
554 /* Reject ET_CORE (header indicates core file, not object file) */
555 if (i_ehdrp->e_type == ET_CORE)
556 goto got_wrong_format_error;
557
558 /* If this is a relocatable file and there is no section header
559 table, then we're hosed. */
560 if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_type == ET_REL)
561 goto got_wrong_format_error;
562
563 /* As a simple sanity check, verify that the what BFD thinks is the
564 size of each section header table entry actually matches the size
565 recorded in the file, but only if there are any sections. */
566 if (i_ehdrp->e_shentsize != sizeof (x_shdr) && i_ehdrp->e_shnum != 0)
567 goto got_wrong_format_error;
568
569 /* Further sanity check. */
570 if (i_ehdrp->e_shoff == 0 && i_ehdrp->e_shnum != 0)
571 goto got_wrong_format_error;
572
573 ebd = get_elf_backend_data (abfd);
574
575 /* Check that the ELF e_machine field matches what this particular
576 BFD format expects. */
577 if (ebd->elf_machine_code != i_ehdrp->e_machine
578 && (ebd->elf_machine_alt1 == 0
579 || i_ehdrp->e_machine != ebd->elf_machine_alt1)
580 && (ebd->elf_machine_alt2 == 0
581 || i_ehdrp->e_machine != ebd->elf_machine_alt2))
582 {
583 const bfd_target * const *target_ptr;
584
585 if (ebd->elf_machine_code != EM_NONE)
586 goto got_wrong_format_error;
587
588 /* This is the generic ELF target. Let it match any ELF target
589 for which we do not have a specific backend. */
590 for (target_ptr = bfd_target_vector; *target_ptr != NULL; target_ptr++)
591 {
592 const struct elf_backend_data *back;
593
594 if ((*target_ptr)->flavour != bfd_target_elf_flavour)
595 continue;
596 back = (const struct elf_backend_data *) (*target_ptr)->backend_data;
597 if (back->elf_machine_code == i_ehdrp->e_machine
598 || (back->elf_machine_alt1 != 0
599 && back->elf_machine_alt1 == i_ehdrp->e_machine)
600 || (back->elf_machine_alt2 != 0
601 && back->elf_machine_alt2 == i_ehdrp->e_machine))
602 {
603 /* target_ptr is an ELF backend which matches this
604 object file, so reject the generic ELF target. */
605 goto got_wrong_format_error;
606 }
607 }
608 }
609
610 if (i_ehdrp->e_type == ET_EXEC)
611 abfd->flags |= EXEC_P;
612 else if (i_ehdrp->e_type == ET_DYN)
613 abfd->flags |= DYNAMIC;
614
615 if (i_ehdrp->e_phnum > 0)
616 abfd->flags |= D_PAGED;
617
618 if (! bfd_default_set_arch_mach (abfd, ebd->arch, 0))
619 {
620 /* It's OK if this fails for the generic target. */
621 if (ebd->elf_machine_code != EM_NONE)
622 goto got_no_match;
623 }
624
625 /* Remember the entry point specified in the ELF file header. */
626 bfd_set_start_address (abfd, i_ehdrp->e_entry);
627
628 if (i_ehdrp->e_shoff != 0)
629 {
630 /* Seek to the section header table in the file. */
631 if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0)
632 goto got_no_match;
633
634 /* Read the first section header at index 0, and convert to internal
635 form. */
636 if (bfd_bread (&x_shdr, sizeof x_shdr, abfd) != sizeof (x_shdr))
637 goto got_no_match;
638 elf_swap_shdr_in (abfd, &x_shdr, &i_shdr);
639
640 /* If the section count is zero, the actual count is in the first
641 section header. */
642 if (i_ehdrp->e_shnum == SHN_UNDEF)
643 i_ehdrp->e_shnum = i_shdr.sh_size;
644
645 /* And similarly for the string table index. */
646 if (i_ehdrp->e_shstrndx == SHN_XINDEX)
647 i_ehdrp->e_shstrndx = i_shdr.sh_link;
648 }
649
650 /* Allocate space for a copy of the section header table in
651 internal form. */
652 if (i_ehdrp->e_shnum != 0)
653 {
654 Elf_Internal_Shdr *shdrp;
655 unsigned int num_sec;
656
657 amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
658 i_shdrp = bfd_alloc (abfd, amt);
659 if (!i_shdrp)
660 goto got_no_match;
661 num_sec = i_ehdrp->e_shnum;
662 if (num_sec > SHN_LORESERVE)
663 num_sec += SHN_HIRESERVE + 1 - SHN_LORESERVE;
664 elf_numsections (abfd) = num_sec;
665 amt = sizeof (i_shdrp) * num_sec;
666 elf_elfsections (abfd) = bfd_alloc (abfd, amt);
667 if (!elf_elfsections (abfd))
668 goto got_no_match;
669
670 memcpy (i_shdrp, &i_shdr, sizeof (*i_shdrp));
671 shdrp = i_shdrp;
672 shindex = 0;
673 if (num_sec > SHN_LORESERVE)
674 {
675 for ( ; shindex < SHN_LORESERVE; shindex++)
676 elf_elfsections (abfd)[shindex] = shdrp++;
677 for ( ; shindex < SHN_HIRESERVE + 1; shindex++)
678 elf_elfsections (abfd)[shindex] = i_shdrp;
679 }
680 for ( ; shindex < num_sec; shindex++)
681 elf_elfsections (abfd)[shindex] = shdrp++;
682
683 /* Read in the rest of the section header table and convert it
684 to internal form. */
685 for (shindex = 1; shindex < i_ehdrp->e_shnum; shindex++)
686 {
687 if (bfd_bread (&x_shdr, sizeof x_shdr, abfd) != sizeof (x_shdr))
688 goto got_no_match;
689 elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
690
691 /* If the section is loaded, but not page aligned, clear
692 D_PAGED. */
693 if (i_shdrp[shindex].sh_size != 0
694 && (i_shdrp[shindex].sh_flags & SHF_ALLOC) != 0
695 && i_shdrp[shindex].sh_type != SHT_NOBITS
696 && (((i_shdrp[shindex].sh_addr - i_shdrp[shindex].sh_offset)
697 % ebd->maxpagesize)
698 != 0))
699 abfd->flags &= ~D_PAGED;
700 }
701 }
702
703 if (i_ehdrp->e_shstrndx && i_ehdrp->e_shoff)
704 {
705 if (! bfd_section_from_shdr (abfd, i_ehdrp->e_shstrndx))
706 goto got_no_match;
707 }
708
709 /* Read in the program headers. */
710 if (i_ehdrp->e_phnum == 0)
711 elf_tdata (abfd)->phdr = NULL;
712 else
713 {
714 Elf_Internal_Phdr *i_phdr;
715 unsigned int i;
716
717 amt = i_ehdrp->e_phnum * sizeof (Elf_Internal_Phdr);
718 elf_tdata (abfd)->phdr = bfd_alloc (abfd, amt);
719 if (elf_tdata (abfd)->phdr == NULL)
720 goto got_no_match;
721 if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0)
722 goto got_no_match;
723 i_phdr = elf_tdata (abfd)->phdr;
724 for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
725 {
726 Elf_External_Phdr x_phdr;
727
728 if (bfd_bread (&x_phdr, sizeof x_phdr, abfd) != sizeof x_phdr)
729 goto got_no_match;
730 elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
731 }
732 }
733
734 /* Read in the string table containing the names of the sections. We
735 will need the base pointer to this table later. */
736 /* We read this inline now, so that we don't have to go through
737 bfd_section_from_shdr with it (since this particular strtab is
738 used to find all of the ELF section names.) */
739
740 if (i_ehdrp->e_shstrndx != 0 && i_ehdrp->e_shoff)
741 {
742 unsigned int num_sec;
743
744 shstrtab = bfd_elf_get_str_section (abfd, i_ehdrp->e_shstrndx);
745 if (!shstrtab)
746 goto got_no_match;
747
748 /* Once all of the section headers have been read and converted, we
749 can start processing them. Note that the first section header is
750 a dummy placeholder entry, so we ignore it. */
751 num_sec = elf_numsections (abfd);
752 for (shindex = 1; shindex < num_sec; shindex++)
753 {
754 if (! bfd_section_from_shdr (abfd, shindex))
755 goto got_no_match;
756 if (shindex == SHN_LORESERVE - 1)
757 shindex += SHN_HIRESERVE + 1 - SHN_LORESERVE;
758 }
759 }
760
761 /* Let the backend double check the format and override global
762 information. */
763 if (ebd->elf_backend_object_p)
764 {
765 if (! (*ebd->elf_backend_object_p) (abfd))
766 goto got_wrong_format_error;
767 }
768
769 /* If we have created any reloc sections that are associated with
770 debugging sections, mark the reloc sections as debugging as well. */
771 for (s = abfd->sections; s != NULL; s = s->next)
772 {
773 if ((elf_section_data (s)->this_hdr.sh_type == SHT_REL
774 || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)
775 && elf_section_data (s)->this_hdr.sh_info > 0)
776 {
777 unsigned long targ_index;
778 asection *targ_sec;
779
780 targ_index = elf_section_data (s)->this_hdr.sh_info;
781 targ_sec = bfd_section_from_elf_index (abfd, targ_index);
782 if (targ_sec != NULL
783 && (targ_sec->flags & SEC_DEBUGGING) != 0)
784 s->flags |= SEC_DEBUGGING;
785 }
786 }
787
788 bfd_preserve_finish (abfd, &preserve);
789 return abfd->xvec;
790
791 got_wrong_format_error:
792 /* There is way too much undoing of half-known state here. The caller,
793 bfd_check_format_matches, really shouldn't iterate on live bfd's to
794 check match/no-match like it does. We have to rely on that a call to
795 bfd_default_set_arch_mach with the previously known mach, undoes what
796 was done by the first bfd_default_set_arch_mach (with mach 0) here.
797 For this to work, only elf-data and the mach may be changed by the
798 target-specific elf_backend_object_p function. Note that saving the
799 whole bfd here and restoring it would be even worse; the first thing
800 you notice is that the cached bfd file position gets out of sync. */
801 bfd_set_error (bfd_error_wrong_format);
802
803 got_no_match:
804 if (preserve.marker != NULL)
805 bfd_preserve_restore (abfd, &preserve);
806 return NULL;
807 }
808 \f
809 /* ELF .o/exec file writing */
810
811 /* Write out the relocs. */
812
813 void
814 elf_write_relocs (bfd *abfd, asection *sec, void *data)
815 {
816 bfd_boolean *failedp = data;
817 Elf_Internal_Shdr *rela_hdr;
818 bfd_vma addr_offset;
819 void (*swap_out) (bfd *, const Elf_Internal_Rela *, bfd_byte *);
820 size_t extsize;
821 bfd_byte *dst_rela;
822 unsigned int idx;
823 asymbol *last_sym;
824 int last_sym_idx;
825
826 /* If we have already failed, don't do anything. */
827 if (*failedp)
828 return;
829
830 if ((sec->flags & SEC_RELOC) == 0)
831 return;
832
833 /* The linker backend writes the relocs out itself, and sets the
834 reloc_count field to zero to inhibit writing them here. Also,
835 sometimes the SEC_RELOC flag gets set even when there aren't any
836 relocs. */
837 if (sec->reloc_count == 0)
838 return;
839
840 rela_hdr = &elf_section_data (sec)->rel_hdr;
841
842 rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count;
843 rela_hdr->contents = bfd_alloc (abfd, rela_hdr->sh_size);
844 if (rela_hdr->contents == NULL)
845 {
846 *failedp = TRUE;
847 return;
848 }
849
850 /* Figure out whether the relocations are RELA or REL relocations. */
851 if (rela_hdr->sh_type == SHT_RELA)
852 {
853 swap_out = elf_swap_reloca_out;
854 extsize = sizeof (Elf_External_Rela);
855 }
856 else if (rela_hdr->sh_type == SHT_REL)
857 {
858 swap_out = elf_swap_reloc_out;
859 extsize = sizeof (Elf_External_Rel);
860 }
861 else
862 /* Every relocation section should be either an SHT_RELA or an
863 SHT_REL section. */
864 abort ();
865
866 /* The address of an ELF reloc is section relative for an object
867 file, and absolute for an executable file or shared library.
868 The address of a BFD reloc is always section relative. */
869 addr_offset = 0;
870 if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
871 addr_offset = sec->vma;
872
873 /* orelocation has the data, reloc_count has the count... */
874 last_sym = 0;
875 last_sym_idx = 0;
876 dst_rela = rela_hdr->contents;
877
878 for (idx = 0; idx < sec->reloc_count; idx++, dst_rela += extsize)
879 {
880 Elf_Internal_Rela src_rela;
881 arelent *ptr;
882 asymbol *sym;
883 int n;
884
885 ptr = sec->orelocation[idx];
886 sym = *ptr->sym_ptr_ptr;
887 if (sym == last_sym)
888 n = last_sym_idx;
889 else if (bfd_is_abs_section (sym->section) && sym->value == 0)
890 n = STN_UNDEF;
891 else
892 {
893 last_sym = sym;
894 n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym);
895 if (n < 0)
896 {
897 *failedp = TRUE;
898 return;
899 }
900 last_sym_idx = n;
901 }
902
903 if ((*ptr->sym_ptr_ptr)->the_bfd != NULL
904 && (*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec
905 && ! _bfd_elf_validate_reloc (abfd, ptr))
906 {
907 *failedp = TRUE;
908 return;
909 }
910
911 src_rela.r_offset = ptr->address + addr_offset;
912 src_rela.r_info = ELF_R_INFO (n, ptr->howto->type);
913 src_rela.r_addend = ptr->addend;
914 (*swap_out) (abfd, &src_rela, dst_rela);
915 }
916 }
917
918 /* Write out the program headers. */
919
920 int
921 elf_write_out_phdrs (bfd *abfd,
922 const Elf_Internal_Phdr *phdr,
923 unsigned int count)
924 {
925 while (count--)
926 {
927 Elf_External_Phdr extphdr;
928 elf_swap_phdr_out (abfd, phdr, &extphdr);
929 if (bfd_bwrite (&extphdr, sizeof (Elf_External_Phdr), abfd)
930 != sizeof (Elf_External_Phdr))
931 return -1;
932 phdr++;
933 }
934 return 0;
935 }
936
937 /* Write out the section headers and the ELF file header. */
938
939 bfd_boolean
940 elf_write_shdrs_and_ehdr (bfd *abfd)
941 {
942 Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
943 Elf_Internal_Ehdr *i_ehdrp; /* Elf file header, internal form */
944 Elf_External_Shdr *x_shdrp; /* Section header table, external form */
945 Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
946 unsigned int count;
947 bfd_size_type amt;
948
949 i_ehdrp = elf_elfheader (abfd);
950 i_shdrp = elf_elfsections (abfd);
951
952 /* swap the header before spitting it out... */
953
954 #if DEBUG & 1
955 elf_debug_file (i_ehdrp);
956 #endif
957 elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr);
958 amt = sizeof (x_ehdr);
959 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
960 || bfd_bwrite (&x_ehdr, amt, abfd) != amt)
961 return FALSE;
962
963 /* Some fields in the first section header handle overflow of ehdr
964 fields. */
965 if (i_ehdrp->e_shnum >= SHN_LORESERVE)
966 i_shdrp[0]->sh_size = i_ehdrp->e_shnum;
967 if (i_ehdrp->e_shstrndx >= SHN_LORESERVE)
968 i_shdrp[0]->sh_link = i_ehdrp->e_shstrndx;
969
970 /* at this point we've concocted all the ELF sections... */
971 amt = i_ehdrp->e_shnum;
972 amt *= sizeof (*x_shdrp);
973 x_shdrp = bfd_alloc (abfd, amt);
974 if (!x_shdrp)
975 return FALSE;
976
977 for (count = 0; count < i_ehdrp->e_shnum; i_shdrp++, count++)
978 {
979 #if DEBUG & 2
980 elf_debug_section (count, *i_shdrp);
981 #endif
982 elf_swap_shdr_out (abfd, *i_shdrp, x_shdrp + count);
983
984 if (count == SHN_LORESERVE - 1)
985 i_shdrp += SHN_HIRESERVE + 1 - SHN_LORESERVE;
986 }
987 if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0
988 || bfd_bwrite (x_shdrp, amt, abfd) != amt)
989 return FALSE;
990
991 /* need to dump the string table too... */
992
993 return TRUE;
994 }
995
996 long
997 elf_slurp_symbol_table (bfd *abfd, asymbol **symptrs, bfd_boolean dynamic)
998 {
999 Elf_Internal_Shdr *hdr;
1000 Elf_Internal_Shdr *verhdr;
1001 unsigned long symcount; /* Number of external ELF symbols */
1002 elf_symbol_type *sym; /* Pointer to current bfd symbol */
1003 elf_symbol_type *symbase; /* Buffer for generated bfd symbols */
1004 Elf_Internal_Sym *isym;
1005 Elf_Internal_Sym *isymend;
1006 Elf_Internal_Sym *isymbuf = NULL;
1007 Elf_External_Versym *xver;
1008 Elf_External_Versym *xverbuf = NULL;
1009 const struct elf_backend_data *ebd;
1010 bfd_size_type amt;
1011
1012 /* Read each raw ELF symbol, converting from external ELF form to
1013 internal ELF form, and then using the information to create a
1014 canonical bfd symbol table entry.
1015
1016 Note that we allocate the initial bfd canonical symbol buffer
1017 based on a one-to-one mapping of the ELF symbols to canonical
1018 symbols. We actually use all the ELF symbols, so there will be no
1019 space left over at the end. When we have all the symbols, we
1020 build the caller's pointer vector. */
1021
1022 if (! dynamic)
1023 {
1024 hdr = &elf_tdata (abfd)->symtab_hdr;
1025 verhdr = NULL;
1026 }
1027 else
1028 {
1029 hdr = &elf_tdata (abfd)->dynsymtab_hdr;
1030 if (elf_dynversym (abfd) == 0)
1031 verhdr = NULL;
1032 else
1033 verhdr = &elf_tdata (abfd)->dynversym_hdr;
1034 if ((elf_tdata (abfd)->dynverdef_section != 0
1035 && elf_tdata (abfd)->verdef == NULL)
1036 || (elf_tdata (abfd)->dynverref_section != 0
1037 && elf_tdata (abfd)->verref == NULL))
1038 {
1039 if (! _bfd_elf_slurp_version_tables (abfd))
1040 return -1;
1041 }
1042 }
1043
1044 ebd = get_elf_backend_data (abfd);
1045 symcount = hdr->sh_size / sizeof (Elf_External_Sym);
1046 if (symcount == 0)
1047 sym = symbase = NULL;
1048 else
1049 {
1050 isymbuf = bfd_elf_get_elf_syms (abfd, hdr, symcount, 0,
1051 NULL, NULL, NULL);
1052 if (isymbuf == NULL)
1053 return -1;
1054
1055 amt = symcount;
1056 amt *= sizeof (elf_symbol_type);
1057 symbase = bfd_zalloc (abfd, amt);
1058 if (symbase == (elf_symbol_type *) NULL)
1059 goto error_return;
1060
1061 /* Read the raw ELF version symbol information. */
1062 if (verhdr != NULL
1063 && verhdr->sh_size / sizeof (Elf_External_Versym) != symcount)
1064 {
1065 (*_bfd_error_handler)
1066 (_("%s: version count (%ld) does not match symbol count (%ld)"),
1067 abfd->filename,
1068 (long) (verhdr->sh_size / sizeof (Elf_External_Versym)),
1069 symcount);
1070
1071 /* Slurp in the symbols without the version information,
1072 since that is more helpful than just quitting. */
1073 verhdr = NULL;
1074 }
1075
1076 if (verhdr != NULL)
1077 {
1078 if (bfd_seek (abfd, verhdr->sh_offset, SEEK_SET) != 0)
1079 goto error_return;
1080
1081 xverbuf = bfd_malloc (verhdr->sh_size);
1082 if (xverbuf == NULL && verhdr->sh_size != 0)
1083 goto error_return;
1084
1085 if (bfd_bread (xverbuf, verhdr->sh_size, abfd) != verhdr->sh_size)
1086 goto error_return;
1087 }
1088
1089 /* Skip first symbol, which is a null dummy. */
1090 xver = xverbuf;
1091 if (xver != NULL)
1092 ++xver;
1093 isymend = isymbuf + symcount;
1094 for (isym = isymbuf + 1, sym = symbase; isym < isymend; isym++, sym++)
1095 {
1096 memcpy (&sym->internal_elf_sym, isym, sizeof (Elf_Internal_Sym));
1097 sym->symbol.the_bfd = abfd;
1098
1099 sym->symbol.name = bfd_elf_string_from_elf_section (abfd,
1100 hdr->sh_link,
1101 isym->st_name);
1102
1103 sym->symbol.value = isym->st_value;
1104
1105 if (isym->st_shndx == SHN_UNDEF)
1106 {
1107 sym->symbol.section = bfd_und_section_ptr;
1108 }
1109 else if (isym->st_shndx < SHN_LORESERVE
1110 || isym->st_shndx > SHN_HIRESERVE)
1111 {
1112 sym->symbol.section = section_from_elf_index (abfd,
1113 isym->st_shndx);
1114 if (sym->symbol.section == NULL)
1115 {
1116 /* This symbol is in a section for which we did not
1117 create a BFD section. Just use bfd_abs_section,
1118 although it is wrong. FIXME. */
1119 sym->symbol.section = bfd_abs_section_ptr;
1120 }
1121 }
1122 else if (isym->st_shndx == SHN_ABS)
1123 {
1124 sym->symbol.section = bfd_abs_section_ptr;
1125 }
1126 else if (isym->st_shndx == SHN_COMMON)
1127 {
1128 sym->symbol.section = bfd_com_section_ptr;
1129 /* Elf puts the alignment into the `value' field, and
1130 the size into the `size' field. BFD wants to see the
1131 size in the value field, and doesn't care (at the
1132 moment) about the alignment. */
1133 sym->symbol.value = isym->st_size;
1134 }
1135 else
1136 sym->symbol.section = bfd_abs_section_ptr;
1137
1138 /* If this is a relocatable file, then the symbol value is
1139 already section relative. */
1140 if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
1141 sym->symbol.value -= sym->symbol.section->vma;
1142
1143 switch (ELF_ST_BIND (isym->st_info))
1144 {
1145 case STB_LOCAL:
1146 sym->symbol.flags |= BSF_LOCAL;
1147 break;
1148 case STB_GLOBAL:
1149 if (isym->st_shndx != SHN_UNDEF && isym->st_shndx != SHN_COMMON)
1150 sym->symbol.flags |= BSF_GLOBAL;
1151 break;
1152 case STB_WEAK:
1153 sym->symbol.flags |= BSF_WEAK;
1154 break;
1155 }
1156
1157 switch (ELF_ST_TYPE (isym->st_info))
1158 {
1159 case STT_SECTION:
1160 sym->symbol.flags |= BSF_SECTION_SYM | BSF_DEBUGGING;
1161 break;
1162 case STT_FILE:
1163 sym->symbol.flags |= BSF_FILE | BSF_DEBUGGING;
1164 break;
1165 case STT_FUNC:
1166 sym->symbol.flags |= BSF_FUNCTION;
1167 break;
1168 case STT_OBJECT:
1169 sym->symbol.flags |= BSF_OBJECT;
1170 break;
1171 }
1172
1173 if (dynamic)
1174 sym->symbol.flags |= BSF_DYNAMIC;
1175
1176 if (xver != NULL)
1177 {
1178 Elf_Internal_Versym iversym;
1179
1180 _bfd_elf_swap_versym_in (abfd, xver, &iversym);
1181 sym->version = iversym.vs_vers;
1182 xver++;
1183 }
1184
1185 /* Do some backend-specific processing on this symbol. */
1186 if (ebd->elf_backend_symbol_processing)
1187 (*ebd->elf_backend_symbol_processing) (abfd, &sym->symbol);
1188 }
1189 }
1190
1191 /* Do some backend-specific processing on this symbol table. */
1192 if (ebd->elf_backend_symbol_table_processing)
1193 (*ebd->elf_backend_symbol_table_processing) (abfd, symbase, symcount);
1194
1195 /* We rely on the zalloc to clear out the final symbol entry. */
1196
1197 symcount = sym - symbase;
1198
1199 /* Fill in the user's symbol pointer vector if needed. */
1200 if (symptrs)
1201 {
1202 long l = symcount;
1203
1204 sym = symbase;
1205 while (l-- > 0)
1206 {
1207 *symptrs++ = &sym->symbol;
1208 sym++;
1209 }
1210 *symptrs = 0; /* Final null pointer */
1211 }
1212
1213 if (xverbuf != NULL)
1214 free (xverbuf);
1215 if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
1216 free (isymbuf);
1217 return symcount;
1218
1219 error_return:
1220 if (xverbuf != NULL)
1221 free (xverbuf);
1222 if (isymbuf != NULL && hdr->contents != (unsigned char *) isymbuf)
1223 free (isymbuf);
1224 return -1;
1225 }
1226
1227 /* Read relocations for ASECT from REL_HDR. There are RELOC_COUNT of
1228 them. */
1229
1230 static bfd_boolean
1231 elf_slurp_reloc_table_from_section (bfd *abfd,
1232 asection *asect,
1233 Elf_Internal_Shdr *rel_hdr,
1234 bfd_size_type reloc_count,
1235 arelent *relents,
1236 asymbol **symbols,
1237 bfd_boolean dynamic)
1238 {
1239 const struct elf_backend_data * const ebd = get_elf_backend_data (abfd);
1240 void *allocated = NULL;
1241 bfd_byte *native_relocs;
1242 arelent *relent;
1243 unsigned int i;
1244 int entsize;
1245 unsigned int symcount;
1246
1247 allocated = bfd_malloc (rel_hdr->sh_size);
1248 if (allocated == NULL)
1249 goto error_return;
1250
1251 if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
1252 || (bfd_bread (allocated, rel_hdr->sh_size, abfd)
1253 != rel_hdr->sh_size))
1254 goto error_return;
1255
1256 native_relocs = allocated;
1257
1258 entsize = rel_hdr->sh_entsize;
1259 BFD_ASSERT (entsize == sizeof (Elf_External_Rel)
1260 || entsize == sizeof (Elf_External_Rela));
1261
1262 if (dynamic)
1263 symcount = bfd_get_dynamic_symcount (abfd);
1264 else
1265 symcount = bfd_get_symcount (abfd);
1266
1267 for (i = 0, relent = relents;
1268 i < reloc_count;
1269 i++, relent++, native_relocs += entsize)
1270 {
1271 Elf_Internal_Rela rela;
1272
1273 if (entsize == sizeof (Elf_External_Rela))
1274 elf_swap_reloca_in (abfd, native_relocs, &rela);
1275 else
1276 elf_swap_reloc_in (abfd, native_relocs, &rela);
1277
1278 /* The address of an ELF reloc is section relative for an object
1279 file, and absolute for an executable file or shared library.
1280 The address of a normal BFD reloc is always section relative,
1281 and the address of a dynamic reloc is absolute.. */
1282 if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 || dynamic)
1283 relent->address = rela.r_offset;
1284 else
1285 relent->address = rela.r_offset - asect->vma;
1286
1287 if (ELF_R_SYM (rela.r_info) == 0)
1288 relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
1289 else if (ELF_R_SYM (rela.r_info) > symcount)
1290 {
1291 (*_bfd_error_handler)
1292 (_("%s(%s): relocation %d has invalid symbol index %ld"),
1293 abfd->filename, asect->name, i, ELF_R_SYM (rela.r_info));
1294 relent->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
1295 }
1296 else
1297 {
1298 asymbol **ps, *s;
1299
1300 ps = symbols + ELF_R_SYM (rela.r_info) - 1;
1301 s = *ps;
1302
1303 /* Canonicalize ELF section symbols. FIXME: Why? */
1304 if ((s->flags & BSF_SECTION_SYM) == 0)
1305 relent->sym_ptr_ptr = ps;
1306 else
1307 relent->sym_ptr_ptr = s->section->symbol_ptr_ptr;
1308 }
1309
1310 relent->addend = rela.r_addend;
1311
1312 if ((entsize == sizeof (Elf_External_Rela)
1313 && ebd->elf_info_to_howto != NULL)
1314 || ebd->elf_info_to_howto_rel == NULL)
1315 (*ebd->elf_info_to_howto) (abfd, relent, &rela);
1316 else
1317 (*ebd->elf_info_to_howto_rel) (abfd, relent, &rela);
1318 }
1319
1320 if (allocated != NULL)
1321 free (allocated);
1322
1323 return TRUE;
1324
1325 error_return:
1326 if (allocated != NULL)
1327 free (allocated);
1328 return FALSE;
1329 }
1330
1331 /* Read in and swap the external relocs. */
1332
1333 bfd_boolean
1334 elf_slurp_reloc_table (bfd *abfd,
1335 asection *asect,
1336 asymbol **symbols,
1337 bfd_boolean dynamic)
1338 {
1339 struct bfd_elf_section_data * const d = elf_section_data (asect);
1340 Elf_Internal_Shdr *rel_hdr;
1341 Elf_Internal_Shdr *rel_hdr2;
1342 bfd_size_type reloc_count;
1343 bfd_size_type reloc_count2;
1344 arelent *relents;
1345 bfd_size_type amt;
1346
1347 if (asect->relocation != NULL)
1348 return TRUE;
1349
1350 if (! dynamic)
1351 {
1352 if ((asect->flags & SEC_RELOC) == 0
1353 || asect->reloc_count == 0)
1354 return TRUE;
1355
1356 rel_hdr = &d->rel_hdr;
1357 reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
1358 rel_hdr2 = d->rel_hdr2;
1359 reloc_count2 = (rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0);
1360
1361 BFD_ASSERT (asect->reloc_count == reloc_count + reloc_count2);
1362 BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset
1363 || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset));
1364
1365 }
1366 else
1367 {
1368 /* Note that ASECT->RELOC_COUNT tends not to be accurate in this
1369 case because relocations against this section may use the
1370 dynamic symbol table, and in that case bfd_section_from_shdr
1371 in elf.c does not update the RELOC_COUNT. */
1372 if (asect->_raw_size == 0)
1373 return TRUE;
1374
1375 rel_hdr = &d->this_hdr;
1376 reloc_count = NUM_SHDR_ENTRIES (rel_hdr);
1377 rel_hdr2 = NULL;
1378 reloc_count2 = 0;
1379 }
1380
1381 amt = (reloc_count + reloc_count2) * sizeof (arelent);
1382 relents = bfd_alloc (abfd, amt);
1383 if (relents == NULL)
1384 return FALSE;
1385
1386 if (!elf_slurp_reloc_table_from_section (abfd, asect,
1387 rel_hdr, reloc_count,
1388 relents,
1389 symbols, dynamic))
1390 return FALSE;
1391
1392 if (rel_hdr2
1393 && !elf_slurp_reloc_table_from_section (abfd, asect,
1394 rel_hdr2, reloc_count2,
1395 relents + reloc_count,
1396 symbols, dynamic))
1397 return FALSE;
1398
1399 asect->relocation = relents;
1400 return TRUE;
1401 }
1402
1403 #ifdef DEBUG
1404 static void
1405 elf_debug_section (int num, Elf_Internal_Shdr *hdr)
1406 {
1407 fprintf (stderr, "\nSection#%d '%s' 0x%.8lx\n", num,
1408 hdr->bfd_section != NULL ? hdr->bfd_section->name : "",
1409 (long) hdr);
1410 fprintf (stderr,
1411 "sh_name = %ld\tsh_type = %ld\tsh_flags = %ld\n",
1412 (long) hdr->sh_name,
1413 (long) hdr->sh_type,
1414 (long) hdr->sh_flags);
1415 fprintf (stderr,
1416 "sh_addr = %ld\tsh_offset = %ld\tsh_size = %ld\n",
1417 (long) hdr->sh_addr,
1418 (long) hdr->sh_offset,
1419 (long) hdr->sh_size);
1420 fprintf (stderr,
1421 "sh_link = %ld\tsh_info = %ld\tsh_addralign = %ld\n",
1422 (long) hdr->sh_link,
1423 (long) hdr->sh_info,
1424 (long) hdr->sh_addralign);
1425 fprintf (stderr, "sh_entsize = %ld\n",
1426 (long) hdr->sh_entsize);
1427 fflush (stderr);
1428 }
1429
1430 static void
1431 elf_debug_file (Elf_Internal_Ehdr *ehdrp)
1432 {
1433 fprintf (stderr, "e_entry = 0x%.8lx\n", (long) ehdrp->e_entry);
1434 fprintf (stderr, "e_phoff = %ld\n", (long) ehdrp->e_phoff);
1435 fprintf (stderr, "e_phnum = %ld\n", (long) ehdrp->e_phnum);
1436 fprintf (stderr, "e_phentsize = %ld\n", (long) ehdrp->e_phentsize);
1437 fprintf (stderr, "e_shoff = %ld\n", (long) ehdrp->e_shoff);
1438 fprintf (stderr, "e_shnum = %ld\n", (long) ehdrp->e_shnum);
1439 fprintf (stderr, "e_shentsize = %ld\n", (long) ehdrp->e_shentsize);
1440 }
1441
1442 static char *
1443 elf_symbol_flags (flagword flags)
1444 {
1445 static char buffer[1024];
1446
1447 buffer[0] = '\0';
1448 if (flags & BSF_LOCAL)
1449 strcat (buffer, " local");
1450
1451 if (flags & BSF_GLOBAL)
1452 strcat (buffer, " global");
1453
1454 if (flags & BSF_DEBUGGING)
1455 strcat (buffer, " debug");
1456
1457 if (flags & BSF_FUNCTION)
1458 strcat (buffer, " function");
1459
1460 if (flags & BSF_KEEP)
1461 strcat (buffer, " keep");
1462
1463 if (flags & BSF_KEEP_G)
1464 strcat (buffer, " keep_g");
1465
1466 if (flags & BSF_WEAK)
1467 strcat (buffer, " weak");
1468
1469 if (flags & BSF_SECTION_SYM)
1470 strcat (buffer, " section-sym");
1471
1472 if (flags & BSF_OLD_COMMON)
1473 strcat (buffer, " old-common");
1474
1475 if (flags & BSF_NOT_AT_END)
1476 strcat (buffer, " not-at-end");
1477
1478 if (flags & BSF_CONSTRUCTOR)
1479 strcat (buffer, " constructor");
1480
1481 if (flags & BSF_WARNING)
1482 strcat (buffer, " warning");
1483
1484 if (flags & BSF_INDIRECT)
1485 strcat (buffer, " indirect");
1486
1487 if (flags & BSF_FILE)
1488 strcat (buffer, " file");
1489
1490 if (flags & DYNAMIC)
1491 strcat (buffer, " dynamic");
1492
1493 if (flags & ~(BSF_LOCAL
1494 | BSF_GLOBAL
1495 | BSF_DEBUGGING
1496 | BSF_FUNCTION
1497 | BSF_KEEP
1498 | BSF_KEEP_G
1499 | BSF_WEAK
1500 | BSF_SECTION_SYM
1501 | BSF_OLD_COMMON
1502 | BSF_NOT_AT_END
1503 | BSF_CONSTRUCTOR
1504 | BSF_WARNING
1505 | BSF_INDIRECT
1506 | BSF_FILE
1507 | BSF_DYNAMIC))
1508 strcat (buffer, " unknown-bits");
1509
1510 return buffer;
1511 }
1512 #endif
1513 \f
1514 /* Create a new BFD as if by bfd_openr. Rather than opening a file,
1515 reconstruct an ELF file by reading the segments out of remote memory
1516 based on the ELF file header at EHDR_VMA and the ELF program headers it
1517 points to. If not null, *LOADBASEP is filled in with the difference
1518 between the VMAs from which the segments were read, and the VMAs the
1519 file headers (and hence BFD's idea of each section's VMA) put them at.
1520
1521 The function TARGET_READ_MEMORY is called to copy LEN bytes from the
1522 remote memory at target address VMA into the local buffer at MYADDR; it
1523 should return zero on success or an `errno' code on failure. TEMPL must
1524 be a BFD for a target with the word size and byte order found in the
1525 remote memory. */
1526
1527 bfd *
1528 NAME(_bfd_elf,bfd_from_remote_memory)
1529 (bfd *templ,
1530 bfd_vma ehdr_vma,
1531 bfd_vma *loadbasep,
1532 int (*target_read_memory) (bfd_vma, char *, int))
1533 {
1534 Elf_External_Ehdr x_ehdr; /* Elf file header, external form */
1535 Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */
1536 Elf_External_Phdr *x_phdrs;
1537 Elf_Internal_Phdr *i_phdrs, *last_phdr;
1538 bfd *nbfd;
1539 struct bfd_in_memory *bim;
1540 int contents_size;
1541 char *contents;
1542 int err;
1543 unsigned int i;
1544 bfd_vma loadbase;
1545
1546 /* Read in the ELF header in external format. */
1547 err = target_read_memory (ehdr_vma, (char *) &x_ehdr, sizeof x_ehdr);
1548 if (err)
1549 {
1550 bfd_set_error (bfd_error_system_call);
1551 errno = err;
1552 return NULL;
1553 }
1554
1555 /* Now check to see if we have a valid ELF file, and one that BFD can
1556 make use of. The magic number must match, the address size ('class')
1557 and byte-swapping must match our XVEC entry. */
1558
1559 if (! elf_file_p (&x_ehdr)
1560 || x_ehdr.e_ident[EI_VERSION] != EV_CURRENT
1561 || x_ehdr.e_ident[EI_CLASS] != ELFCLASS)
1562 {
1563 bfd_set_error (bfd_error_wrong_format);
1564 return NULL;
1565 }
1566
1567 /* Check that file's byte order matches xvec's */
1568 switch (x_ehdr.e_ident[EI_DATA])
1569 {
1570 case ELFDATA2MSB: /* Big-endian */
1571 if (! bfd_header_big_endian (templ))
1572 {
1573 bfd_set_error (bfd_error_wrong_format);
1574 return NULL;
1575 }
1576 break;
1577 case ELFDATA2LSB: /* Little-endian */
1578 if (! bfd_header_little_endian (templ))
1579 {
1580 bfd_set_error (bfd_error_wrong_format);
1581 return NULL;
1582 }
1583 break;
1584 case ELFDATANONE: /* No data encoding specified */
1585 default: /* Unknown data encoding specified */
1586 bfd_set_error (bfd_error_wrong_format);
1587 return NULL;
1588 }
1589
1590 elf_swap_ehdr_in (templ, &x_ehdr, &i_ehdr);
1591
1592 /* The file header tells where to find the program headers.
1593 These are what we use to actually choose what to read. */
1594
1595 if (i_ehdr.e_phentsize != sizeof (Elf_External_Phdr) || i_ehdr.e_phnum == 0)
1596 {
1597 bfd_set_error (bfd_error_wrong_format);
1598 return NULL;
1599 }
1600
1601 x_phdrs = bfd_malloc (i_ehdr.e_phnum * (sizeof *x_phdrs + sizeof *i_phdrs));
1602 if (x_phdrs == NULL)
1603 {
1604 bfd_set_error (bfd_error_no_memory);
1605 return NULL;
1606 }
1607 err = target_read_memory (ehdr_vma + i_ehdr.e_phoff, (char *) x_phdrs,
1608 i_ehdr.e_phnum * sizeof x_phdrs[0]);
1609 if (err)
1610 {
1611 free (x_phdrs);
1612 bfd_set_error (bfd_error_system_call);
1613 errno = err;
1614 return NULL;
1615 }
1616 i_phdrs = (Elf_Internal_Phdr *) &x_phdrs[i_ehdr.e_phnum];
1617
1618 contents_size = 0;
1619 last_phdr = NULL;
1620 loadbase = ehdr_vma;
1621 for (i = 0; i < i_ehdr.e_phnum; ++i)
1622 {
1623 elf_swap_phdr_in (templ, &x_phdrs[i], &i_phdrs[i]);
1624 if (i_phdrs[i].p_type == PT_LOAD)
1625 {
1626 bfd_vma segment_end;
1627 segment_end = (i_phdrs[i].p_offset + i_phdrs[i].p_filesz
1628 + i_phdrs[i].p_align - 1) & -i_phdrs[i].p_align;
1629 if (segment_end > (bfd_vma) contents_size)
1630 contents_size = segment_end;
1631
1632 if ((i_phdrs[i].p_offset & -i_phdrs[i].p_align) == 0)
1633 loadbase = ehdr_vma - (i_phdrs[i].p_vaddr & -i_phdrs[i].p_align);
1634
1635 last_phdr = &i_phdrs[i];
1636 }
1637 }
1638 if (last_phdr == NULL)
1639 {
1640 /* There were no PT_LOAD segments, so we don't have anything to read. */
1641 free (x_phdrs);
1642 bfd_set_error (bfd_error_wrong_format);
1643 return NULL;
1644 }
1645
1646 /* Trim the last segment so we don't bother with zeros in the last page
1647 that are off the end of the file. However, if the extra bit in that
1648 page includes the section headers, keep them. */
1649 if ((bfd_vma) contents_size > last_phdr->p_offset + last_phdr->p_filesz
1650 && (bfd_vma) contents_size >= (i_ehdr.e_shoff
1651 + i_ehdr.e_shnum * i_ehdr.e_shentsize))
1652 {
1653 contents_size = last_phdr->p_offset + last_phdr->p_filesz;
1654 if ((bfd_vma) contents_size < (i_ehdr.e_shoff
1655 + i_ehdr.e_shnum * i_ehdr.e_shentsize))
1656 contents_size = i_ehdr.e_shoff + i_ehdr.e_shnum * i_ehdr.e_shentsize;
1657 }
1658 else
1659 contents_size = last_phdr->p_offset + last_phdr->p_filesz;
1660
1661 /* Now we know the size of the whole image we want read in. */
1662 contents = bfd_zmalloc (contents_size);
1663 if (contents == NULL)
1664 {
1665 free (x_phdrs);
1666 bfd_set_error (bfd_error_no_memory);
1667 return NULL;
1668 }
1669
1670 for (i = 0; i < i_ehdr.e_phnum; ++i)
1671 if (i_phdrs[i].p_type == PT_LOAD)
1672 {
1673 bfd_vma start = i_phdrs[i].p_offset & -i_phdrs[i].p_align;
1674 bfd_vma end = (i_phdrs[i].p_offset + i_phdrs[i].p_filesz
1675 + i_phdrs[i].p_align - 1) & -i_phdrs[i].p_align;
1676 if (end > (bfd_vma) contents_size)
1677 end = contents_size;
1678 err = target_read_memory ((loadbase + i_phdrs[i].p_vaddr)
1679 & -i_phdrs[i].p_align,
1680 contents + start, end - start);
1681 if (err)
1682 {
1683 free (x_phdrs);
1684 free (contents);
1685 bfd_set_error (bfd_error_system_call);
1686 errno = err;
1687 return NULL;
1688 }
1689 }
1690 free (x_phdrs);
1691
1692 /* If the segments visible in memory didn't include the section headers,
1693 then clear them from the file header. */
1694 if ((bfd_vma) contents_size < (i_ehdr.e_shoff
1695 + i_ehdr.e_shnum * i_ehdr.e_shentsize))
1696 {
1697 memset (&x_ehdr.e_shoff, 0, sizeof x_ehdr.e_shoff);
1698 memset (&x_ehdr.e_shnum, 0, sizeof x_ehdr.e_shnum);
1699 memset (&x_ehdr.e_shstrndx, 0, sizeof x_ehdr.e_shstrndx);
1700 }
1701
1702 /* This will normally have been in the first PT_LOAD segment. But it
1703 conceivably could be missing, and we might have just changed it. */
1704 memcpy (contents, &x_ehdr, sizeof x_ehdr);
1705
1706 /* Now we have a memory image of the ELF file contents. Make a BFD. */
1707 bim = bfd_malloc (sizeof (struct bfd_in_memory));
1708 if (bim == NULL)
1709 {
1710 free (contents);
1711 bfd_set_error (bfd_error_no_memory);
1712 return NULL;
1713 }
1714 nbfd = _bfd_new_bfd ();
1715 if (nbfd == NULL)
1716 {
1717 free (bim);
1718 free (contents);
1719 bfd_set_error (bfd_error_no_memory);
1720 return NULL;
1721 }
1722 nbfd->filename = "<in-memory>";
1723 nbfd->xvec = templ->xvec;
1724 bim->size = contents_size;
1725 bim->buffer = contents;
1726 nbfd->iostream = bim;
1727 nbfd->flags = BFD_IN_MEMORY;
1728 nbfd->direction = read_direction;
1729 nbfd->mtime = time (NULL);
1730 nbfd->mtime_set = TRUE;
1731
1732 if (loadbasep)
1733 *loadbasep = loadbase;
1734 return nbfd;
1735 }
1736 \f
1737 #include "elfcore.h"
1738 #include "elflink.h"
1739 \f
1740 /* Size-dependent data and functions. */
1741 const struct elf_size_info NAME(_bfd_elf,size_info) = {
1742 sizeof (Elf_External_Ehdr),
1743 sizeof (Elf_External_Phdr),
1744 sizeof (Elf_External_Shdr),
1745 sizeof (Elf_External_Rel),
1746 sizeof (Elf_External_Rela),
1747 sizeof (Elf_External_Sym),
1748 sizeof (Elf_External_Dyn),
1749 sizeof (Elf_External_Note),
1750 4,
1751 1,
1752 ARCH_SIZE, LOG_FILE_ALIGN,
1753 ELFCLASS, EV_CURRENT,
1754 elf_write_out_phdrs,
1755 elf_write_shdrs_and_ehdr,
1756 elf_write_relocs,
1757 elf_swap_symbol_in,
1758 elf_swap_symbol_out,
1759 elf_slurp_reloc_table,
1760 elf_slurp_symbol_table,
1761 elf_swap_dyn_in,
1762 elf_swap_dyn_out,
1763 elf_swap_reloc_in,
1764 elf_swap_reloc_out,
1765 elf_swap_reloca_in,
1766 elf_swap_reloca_out
1767 };
This page took 0.10779 seconds and 4 git commands to generate.