Added 1993 copyrights to files that I have changed in 1993. Some were
[deliverable/binutils-gdb.git] / bfd / elf.c
index c3836f9351d66b3f33d826d9786935dc5be3c8e6..4f664843eee8e3512b2d5da672c49a6c5b59afb6 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,5 +1,5 @@
 /* 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
@@ -576,8 +576,8 @@ DEFUN(bfd_new_strtab, (abfd),
 {
   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;
@@ -622,7 +622,7 @@ DEFUN(bfd_add_2_to_strtab, (abfd, ss, str, str2),
   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);
@@ -1977,7 +1977,7 @@ DEFUN (elf_slurp_symbol_table, (abfd, symptrs),
   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))
@@ -2112,10 +2112,9 @@ sec_ptr         asect;
     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, 
@@ -2129,8 +2128,20 @@ enum reloc_type
     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",           \
@@ -2144,9 +2155,17 @@ enum reloc_type
     "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),
@@ -2173,6 +2192,11 @@ static reloc_howto_type elf_howto_table[] =
   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
@@ -2182,16 +2206,26 @@ DEFUN(elf_info_to_howto, (abfd, cache_ptr, dst),
       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
@@ -2490,6 +2524,8 @@ DEFUN(elf_set_section_contents, (abfd, section, location, offset, count),
 #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 */
This page took 0.034951 seconds and 4 git commands to generate.