2001-12-19 Michael Snyder <msnyder@redhat.com>
[deliverable/binutils-gdb.git] / bfd / elf32-i370.c
index 4a43496d29d43f44c2a9e0d39fceb7e449738ff6..5c5740f2d54c2ff0c718d09305fcc1497d09c2a3 100644 (file)
@@ -301,7 +301,6 @@ i370_elf_reloc_type_lookup (abfd, code)
   return i370_elf_howto_table[ (int)i370_reloc ];
 };
 
-static boolean i370_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
 static boolean i370_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
 
 static boolean i370_elf_relocate_section PARAMS ((bfd *,
@@ -381,24 +380,6 @@ i370_elf_set_private_flags (abfd, flags)
   return true;
 }
 
-/* Copy backend specific data from one object module to another */
-static boolean
-i370_elf_copy_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
-{
-  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
-      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return true;
-
-  BFD_ASSERT (!elf_flags_init (obfd)
-             || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
-
-  elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
-  elf_flags_init (obfd) = true;
-  return true;
-}
-
 /* Merge backend specific data from an object file to the output
    object file when linking */
 static boolean
@@ -428,7 +409,7 @@ i370_elf_merge_private_bfd_data (ibfd, obfd)
     {
       (*_bfd_error_handler)
        ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
-        bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
+        bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
 
       bfd_set_error (bfd_error_bad_value);
       return false;
@@ -536,8 +517,8 @@ i370_elf_create_linker_section (abfd, info, which)
        {
        default:
          (*_bfd_error_handler) ("%s: Unknown special linker type %d",
-                                bfd_get_filename (abfd),
-                                (int)which);
+                                bfd_archive_filename (abfd),
+                                (int) which);
 
          bfd_set_error (bfd_error_bad_value);
          return (elf_linker_section_t *)0;
@@ -921,37 +902,40 @@ i370_elf_size_dynamic_sections (output_bfd, info)
         must add the entries now so that we get the correct size for
         the .dynamic section.  The DT_DEBUG entry is filled in by the
         dynamic linker and used by the debugger.  */
-      if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+  bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+      if (!info->shared)
        {
-         if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+         if (!add_dynamic_entry (DT_DEBUG, 0))
            return false;
        }
 
       if (plt)
        {
-         if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
-             || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
-             || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
-             || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+         if (!add_dynamic_entry (DT_PLTGOT, 0)
+             || !add_dynamic_entry (DT_PLTRELSZ, 0)
+             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+             || !add_dynamic_entry (DT_JMPREL, 0))
            return false;
        }
 
       if (relocs)
        {
-         if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
-             || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
-             || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
-                                               sizeof (Elf32_External_Rela)))
+         if (!add_dynamic_entry (DT_RELA, 0)
+             || !add_dynamic_entry (DT_RELASZ, 0)
+             || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
            return false;
        }
 
       if (reltext)
        {
-         if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+         if (!add_dynamic_entry (DT_TEXTREL, 0))
            return false;
          info->flags |= DF_TEXTREL;
        }
     }
+#undef add_dynamic_entry
 
   /* If we are generating a shared library, we generate a section
      symbol for each output section.  These are local symbols, which
@@ -1022,7 +1006,7 @@ i370_elf_check_relocs (abfd, info, sec, relocs)
 #ifdef DEBUG
   fprintf (stderr, "i370_elf_check_relocs called for section %s in %s\n",
           bfd_get_section_name (abfd, sec),
-          bfd_get_filename (abfd));
+          bfd_archive_filename (abfd));
 #endif
 
   dynobj = elf_hash_table (info)->dynobj;
@@ -1174,7 +1158,7 @@ i370_elf_finish_dynamic_sections (output_bfd, info)
   if (sgot)
     {
       unsigned char *contents = sgot->contents;
-      bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
+      bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
 
       if (sdyn == NULL)
        bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
@@ -1206,6 +1190,7 @@ i370_elf_finish_dynamic_sections (output_bfd, info)
       for (s = output_bfd->sections; s != NULL; s = s->next)
        {
          int indx, dindx;
+         Elf32_External_Sym *esym;
 
          sym.st_value = s->vma;
 
@@ -1221,10 +1206,8 @@ i370_elf_finish_dynamic_sections (output_bfd, info)
 
              sym.st_shndx = indx;
 
-             bfd_elf32_swap_symbol_out (output_bfd, &sym,
-                                        (PTR) (((Elf32_External_Sym *)
-                                                sdynsym->contents)
-                                               + dindx));
+             esym = (Elf32_External_Sym *) sdynsym->contents + dindx;
+             bfd_elf32_swap_symbol_out (output_bfd, &sym, (PTR) esym, (PTR) 0);
            }
        }
 
@@ -1289,9 +1272,9 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
 #ifdef DEBUG
   fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n",
-          bfd_get_filename (input_bfd),
+          bfd_archive_filename (input_bfd),
           bfd_section_name(input_bfd, input_section),
-          (long)input_section->reloc_count,
+          (long) input_section->reloc_count,
           (info->relocateable) ? " (relocatable)" : "");
 #endif
 
@@ -1319,8 +1302,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          || !i370_elf_howto_table[(int)r_type])
        {
          (*_bfd_error_handler) ("%s: unknown relocation type %d",
-                                bfd_get_filename (input_bfd),
-                                (int)r_type);
+                                bfd_archive_filename (input_bfd),
+                                (int) r_type);
 
          bfd_set_error (bfd_error_bad_value);
          ret = false;
@@ -1364,9 +1347,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          sec = local_sections[r_symndx];
          sym_name = "<local symbol>";
 
-         relocation = (sec->output_section->vma
-                       + sec->output_offset
-                       + sym->st_value);
+         relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
+         addend = rel->r_addend;
        }
       else
        {
@@ -1417,17 +1399,21 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            }
        }
 
-      switch ((int)r_type)
+      switch ((int) r_type)
        {
        default:
-         (*_bfd_error_handler) ("%s: unknown relocation type %d for symbol %s",
-                                bfd_get_filename (input_bfd),
-                                (int)r_type, sym_name);
+         (*_bfd_error_handler)
+           ("%s: unknown relocation type %d for symbol %s",
+            bfd_archive_filename (input_bfd),
+            (int) r_type, sym_name);
 
          bfd_set_error (bfd_error_bad_value);
          ret = false;
          continue;
 
+       case (int)R_I370_NONE:
+         continue;
+
        /* Relocations that may need to be propagated if this is a shared
            object.  */
        case (int)R_I370_REL31:
@@ -1440,10 +1426,10 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
        /* Relocations that always need to be propagated if this is a shared
            object.  */
-       case (int)R_I370_NONE:
        case (int)R_I370_ADDR31:
        case (int)R_I370_ADDR16:
-         if (info->shared)
+         if (info->shared
+             && r_symndx != 0)
            {
              Elf_Internal_Rela outrel;
              boolean skip;
@@ -1480,22 +1466,11 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
              skip = false;
 
-             if (elf_section_data (input_section)->stab_info == NULL)
-               outrel.r_offset = rel->r_offset;
-             else
-               {
-                 bfd_vma off;
-
-                 off = (_bfd_stab_section_offset
-                        (output_bfd, &elf_hash_table (info)->stab_info,
-                         input_section,
-                         &elf_section_data (input_section)->stab_info,
-                         rel->r_offset));
-                 if (off == (bfd_vma) -1)
-                   skip = true;
-                 outrel.r_offset = off;
-               }
-
+             outrel.r_offset =
+               _bfd_elf_section_offset (output_bfd, info, input_section,
+                                        rel->r_offset);
+             if (outrel.r_offset == (bfd_vma) -1)
+               skip = true;
              outrel.r_offset += (input_section->output_section->vma
                                  + input_section->output_offset);
 
@@ -1579,10 +1554,11 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
        case (int)R_I370_COPY:
        case (int)R_I370_RELATIVE:
-         (*_bfd_error_handler) ("%s: Relocation %s is not yet supported for symbol %s.",
-                                bfd_get_filename (input_bfd),
-                                i370_elf_howto_table[ (int)r_type ]->name,
-                                sym_name);
+         (*_bfd_error_handler)
+           ("%s: Relocation %s is not yet supported for symbol %s.",
+            bfd_archive_filename (input_bfd),
+            i370_elf_howto_table[(int) r_type]->name,
+            sym_name);
 
          bfd_set_error (bfd_error_invalid_operation);
          ret = false;
@@ -1680,7 +1656,6 @@ i370_elf_post_process_headers (abfd, link_info)
 
 #define bfd_elf32_bfd_reloc_type_lookup                i370_elf_reloc_type_lookup
 #define bfd_elf32_bfd_set_private_flags                i370_elf_set_private_flags
-#define bfd_elf32_bfd_copy_private_bfd_data    i370_elf_copy_private_bfd_data
 #define bfd_elf32_bfd_merge_private_bfd_data   i370_elf_merge_private_bfd_data
 #define elf_backend_relocate_section           i370_elf_relocate_section
 
@@ -1704,7 +1679,9 @@ i370_elf_post_process_headers (abfd, link_info)
 
 #define elf_backend_post_process_headers       i370_elf_post_process_headers
 
-int i370_noop()
+static int i370_noop PARAMS ((void));
+
+static int i370_noop ()
 {
   return 1;
 }
This page took 0.027439 seconds and 4 git commands to generate.