/* ELF executable support for BFD.
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1991, 1992 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
in "UNIX System V Release 4, Programmers Guide: ANSI C and
#define bfd_prpsinfo(abfd, descdata, descsz, filepos) /* Define away */
#endif
+/* Forward declarations of static functions */
+
+static char *
+elf_read PARAMS ((bfd *, long, int));
+
+static struct sec *
+section_from_elf_index PARAMS ((bfd *, int));
+
+static int
+elf_section_from_bfd_section PARAMS ((bfd *, struct sec *));
+
+static boolean
+elf_slurp_symbol_table PARAMS ((bfd *, asymbol **));
+
+static void
+elf_info_to_howto PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+
+static char *
+elf_get_str_section PARAMS ((bfd *, unsigned int));
+
/* Forward data declarations */
extern bfd_target elf_little_vec, elf_big_vec;
bfd_h_put_32 (abfd, src->r_addend, dst->r_addend);
}
-static char *EXFUN(elf_read, (bfd *, long, int));
-static struct sec * EXFUN(section_from_elf_index, (bfd *, int));
-static int EXFUN(elf_section_from_bfd_section, (bfd *, struct sec *));
-static boolean EXFUN(elf_slurp_symbol_table, (bfd *, asymbol **));
-static void EXFUN(elf_info_to_howto, (bfd *, arelent *, Elf_Internal_Rela *));
-static char *EXFUN(elf_get_str_section, (bfd *, unsigned int));
-
/*
INTERNAL_FUNCTION
bfd_elf_find_section
SYNOPSIS
- struct elf_internal_shdr *bfd_elf_find_section (bfd *abfd, char *name);
+ Elf_Internal_Shdr *bfd_elf_find_section (bfd *abfd, char *name);
DESCRIPTION
Helper functions for GDB to locate the string tables.
mechanisms wouldn't work to find it, even if we had some.
*/
-struct elf_internal_shdr *
+Elf_Internal_Shdr *
DEFUN(bfd_elf_find_section, (abfd, name),
bfd *abfd AND
char *name)
{
- Elf_Internal_Shdr *i_shdrp = elf_elfsections (abfd);
- char *shstrtab = elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
- unsigned int max = elf_elfheader (abfd)->e_shnum;
+ Elf_Internal_Shdr *i_shdrp;
+ Elf_Internal_Shdr *gotit = NULL;
+ char *shstrtab;
+ unsigned int max;
unsigned int i;
- for (i = 1; i < max; i++)
- if (!strcmp (&shstrtab[i_shdrp[i].sh_name], name))
- return &i_shdrp[i];
- return 0;
+ i_shdrp = elf_elfsections (abfd);
+ if (i_shdrp != NULL)
+ {
+ shstrtab = elf_get_str_section (abfd, elf_elfheader (abfd)->e_shstrndx);
+ if (shstrtab != NULL)
+ {
+ max = elf_elfheader (abfd)->e_shnum;
+ for (i = 1; i < max; i++)
+ {
+ if (!strcmp (&shstrtab[i_shdrp[i].sh_name], name))
+ {
+ gotit = &i_shdrp[i];
+ }
+ }
+ }
+ }
+ return (gotit);
}
/* End of GDB support. */
bfd *abfd AND
unsigned int shindex)
{
- Elf_Internal_Shdr *i_shdrp = elf_elfsections (abfd);
- unsigned int shstrtabsize = i_shdrp[shindex].sh_size;
- unsigned int offset = i_shdrp[shindex].sh_offset;
- char *shstrtab = i_shdrp[shindex].rawdata;
+ Elf_Internal_Shdr *i_shdrp;
+ char *shstrtab = NULL;
+ unsigned int offset;
+ unsigned int shstrtabsize;
- if (shstrtab)
- return shstrtab;
-
- if ((shstrtab = elf_read (abfd, offset, shstrtabsize)) == NULL)
+ i_shdrp = elf_elfsections (abfd);
+ if (i_shdrp != NULL)
{
- return (NULL);
+ shstrtab = i_shdrp[shindex].rawdata;
+ if (shstrtab == NULL)
+ {
+ /* No cached one, attempt to read, and cache what we read. */
+ offset = i_shdrp[shindex].sh_offset;
+ shstrtabsize = i_shdrp[shindex].sh_size;
+ shstrtab = elf_read (abfd, offset, shstrtabsize);
+ i_shdrp[shindex].rawdata = (void*) shstrtab;
+ }
}
- i_shdrp[shindex].rawdata = (void*)shstrtab;
- return shstrtab;
+ return (shstrtab);
}
static char *
{
asection *target_sect;
- unsigned int idx;
bfd_section_from_shdr (abfd, hdr->sh_link); /* symbol table */
bfd_section_from_shdr (abfd, hdr->sh_info); /* target */
Elf_Internal_Shdr *i_shdrp; /* Section header table, internal form */
int shindex;
char *shstrtab; /* Internal copy of section header stringtab */
- Elf_Off offset; /* Temp place to stash file offsets */
/* Read in the ELF header in external format. */
Elf_Internal_Shdr *hdr = i_shdrp + elf_onesymtab (abfd);
int symcount; /* Number of external ELF symbols */
int i;
- char *strtab; /* Buffer for raw ELF string table section */
asymbol *sym; /* Pointer to current bfd symbol */
asymbol *symbase; /* Buffer for generated bfd symbols */
Elf_Internal_Sym i_sym;
DEFUN (elf_get_symtab_upper_bound, (abfd), bfd *abfd)
{
unsigned int symcount;
- unsigned int symtab_size;
- Elf_Internal_Shdr *i_shdrp = elf_elfsections (abfd);
- Elf_Internal_Shdr *hdr = i_shdrp + elf_onesymtab (abfd);
+ unsigned int symtab_size = 0;
+ Elf_Internal_Shdr *i_shdrp;
+ Elf_Internal_Shdr *hdr;
- symcount = hdr->sh_size / sizeof (Elf_External_Sym);
- symtab_size = (symcount - 1 + 1) * (sizeof (asymbol));
+ i_shdrp = elf_elfsections (abfd);
+ if (i_shdrp != NULL)
+ {
+ hdr = i_shdrp + elf_onesymtab (abfd);
+ symcount = hdr->sh_size / sizeof (Elf_External_Sym);
+ symtab_size = (symcount - 1 + 1) * (sizeof (asymbol));
+ }
return (symtab_size);
}
RELOC_PROCESSING(cache_ptr, &dst, symbols, abfd, asect);
#else
Elf_Internal_Rela dst;
- asymbol *ptr;
Elf_External_Rela *src;
cache_ptr = reloc_cache + idx;
/* ELF_R_SYM(dst.r_info) is the symbol table offset... */
cache_ptr->sym_ptr_ptr = symbols + ELF_R_SYM(dst.r_info);
cache_ptr->addend = dst.r_addend;
- /* ptr = *(cache_ptr->sym_ptr_ptr); */
/* Fill in the cache_ptr->howto field from dst.r_type */
elf_info_to_howto(abfd, cache_ptr, &dst);
bfd *abfd AND
asymbol **alocation)
{
- unsigned int symcount;
- asymbol **vec;
if (!elf_slurp_symbol_table (abfd, alocation))
return (0);
one for little-endian machines. */
/* Archives are generic or unimplemented. */
-#define elf_slurp_armap bfd_false
+#define elf_slurp_armap bfd_slurp_coff_armap
#define elf_slurp_extended_name_table _bfd_slurp_extended_name_table
#define elf_truncate_arname bfd_dont_truncate_arname
#define elf_openr_next_archived_file bfd_generic_openr_next_archived_file
#define elf_generic_stat_arch_elt bfd_generic_stat_arch_elt
-#define elf_write_armap (PROTO (boolean, (*), \
- (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count, \
- int stridx))) bfd_false
+#define elf_write_armap coff_write_armap
/* Ordinary section reading and writing */
#define elf_new_section_hook _bfd_dummy_new_section_hook
(SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY |
SEC_CODE | SEC_DATA),
-
/* leading_symbol_char: is the first char of a user symbol
predictable, and if so what is it */
0,
bfd_false
},
- /* Initialize a jump table with the standard macro. All names start
- with "elf" */
+ /* Initialize a jump table with the standard macro. All names start with
+ "elf" */
JUMP_TABLE(elf),
- /* SWAP_TABLE */
- NULL, NULL, NULL
+ /* reloc_type_lookup: How applications can find out about amiga relocation
+ types (see documentation on reloc types). */
+ NULL,
+
+ /* _bfd_make_debug_symbol: Back-door to allow format aware applications to
+ create debug symbols while using BFD for everything else. */
+ NULL,
+
+ /* backend_data: */
+ NULL
};
bfd_target elf_little_vec =
bfd_false
},
- /* Initialize a jump table with the standard macro. All names start
- with "elf" */
+ /* Initialize a jump table with the standard macro. All names start with
+ "elf" */
JUMP_TABLE(elf),
- /* SWAP_TABLE */
- NULL, NULL, NULL
+ /* reloc_type_lookup: How applications can find out about amiga relocation
+ types (see documentation on reloc types). */
+ NULL,
+
+ /* _bfd_make_debug_symbol: Back-door to allow format aware applications to
+ create debug symbols while using BFD for everything else. */
+ NULL,
+
+ /* backend_data: */
+ NULL
};