/* ELF executable support for BFD.
- Copyright 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1991, 1992, 1993 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, from information published
in "UNIX System V Release 4, Programmers Guide: ANSI C and
{
struct strtab *ss;
- ss = (struct strtab *)malloc(sizeof(struct strtab));
- ss->tab = malloc(1);
+ ss = (struct strtab *) bfd_xmalloc(sizeof(struct strtab));
+ ss->tab = bfd_xmalloc(1);
BFD_ASSERT(ss->tab != 0);
*ss->tab = 0;
ss->nentries = 0;
if (ss->length)
ss->tab = realloc(ss->tab, ss->length + ln);
else
- ss->tab = malloc(ln);
+ ss->tab = bfd_xmalloc(ln);
BFD_ASSERT(ss->tab != 0);
strcpy(ss->tab + ss->length, str);
sym = symbase;
/* Temporarily allocate room for the raw ELF symbols. */
- x_symp = (Elf_External_Sym *) malloc (symcount * sizeof (Elf_External_Sym));
+ x_symp = (Elf_External_Sym *) bfd_xmalloc (symcount * sizeof (Elf_External_Sym));
if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
!= symcount * sizeof (Elf_External_Sym))
return (0);
}
-/* FIXME!!! sparc howto should go into elf-32-sparc.c */
-#ifdef sparc
enum reloc_type
{
+ R_SPARC_offset = 0,
R_SPARC_NONE = 0,
R_SPARC_8, R_SPARC_16, R_SPARC_32,
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
R_SPARC_RELATIVE,
R_SPARC_UA32,
+ R_SPARC_max,
+
+ R_386_offset = R_SPARC_max,
+ R_386_NONE = 0,
+ R_386_32, R_386_PC32,
+ R_386_GOT32, R_386_PLT32,
+ R_386_COPY,
+ R_386_GLOB_DAT, R_386_JUMP_SLOT,
+ R_386_RELATIVE,
+ R_386_GOTOFF, R_386_GOTPC,
+ R_386_max,
};
+#if 0 /* not used */
#define RELOC_TYPE_NAMES \
"R_SPARC_NONE", \
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32", \
"R_SPARC_COPY", \
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT", \
"R_SPARC_RELATIVE", \
- "R_SPARC_UA32"
+ "R_SPARC_UA32", \
+ "R_386_NONE", \
+ "R_386_32", "R_386_PC32", \
+ "R_386_GOT32", "R_386_PLT32", \
+ "R_386_COPY", \
+ "R_386_GLOB_DAT", "R_386_JUMP_SLOT", \
+ "R_386_RELATIVE", \
+ "R_386_GOTOFF", "R_386_GOTPC"
+#endif
-static reloc_howto_type elf_howto_table[] =
+static reloc_howto_type elf_sparc_howto_table[] =
{
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,false,false, 0,"R_SPARC_NONE", false,0,0x00000000,false),
HOWTO(R_SPARC_8, 0,0, 8,false,0,true, true, 0,"R_SPARC_8", false,0,0x000000ff,false),
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,false,false,0,"R_SPARC_RELATIVE",false,0,0x00000000,false),
HOWTO(R_SPARC_UA32, 0,0,00,false,0,false,false,0,"R_SPARC_UA32", false,0,0x00000000,false),
};
+
+#if 0
+static const reloc_howto_type elf_386_howto_table[] =
+{
+ HOWTO (R_386_NONE, 0, 0, 0, false, 0,
#endif
static void
Elf_Internal_Rela *dst)
{
/* FIXME!!! just doing sparc for now... */
-#ifdef sparc
- BFD_ASSERT (ELF_R_TYPE(dst->r_info) < 24);
+ switch (abfd->arch_info->arch)
+ {
+ case bfd_arch_sparc:
+ BFD_ASSERT (ELF_R_TYPE(dst->r_info) < R_SPARC_max);
+ cache_ptr->howto = &elf_sparc_howto_table[ELF_R_TYPE(dst->r_info)];
+ break;
- cache_ptr->howto = &elf_howto_table[ELF_R_TYPE(dst->r_info)];
-#else
- fprintf (stderr, "elf_info_to_howto not implemented\n");
- abort ();
+#if 0
+ case bfd_arch_i386:
+ BFD_ASSER (ELF_R_TYPE (dst->r_info) < R_386_max);
+ cache_ptr->howto = &elf_i386_howto_table[ELF_R_TYPE (dst->r_info)];
+ break;
#endif
+
+ default:
+ fprintf (stderr, "elf_info_to_howto not implemented\n");
+ abort ();
+ }
}
-
+
static boolean
DEFUN(elf_slurp_reloca_table,(abfd, asect, symbols),
bfd *abfd AND
#define elf_bfd_get_relocated_section_contents \
bfd_generic_get_relocated_section_contents
#define elf_bfd_relax_section bfd_generic_relax_section
+#define elf_bfd_seclet_link bfd_generic_seclet_link
+
bfd_target elf_big_vec =
{
/* name: identify kind of target */