* elf32-ppc.c (LIS_11. LIS_12): Define.
[deliverable/binutils-gdb.git] / bfd / elf32-i370.c
index 49ecbb2583fbbef9c597b23f5b768a82d296d5a7..ddbe48f9f24085078ff32fd1bd8181f62d28e35e 100644 (file)
@@ -18,7 +18,7 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 /* This file is based on a preliminary PowerPC ELF ABI.
    But its been hacked on for the IBM 360/370 architectures.
@@ -286,8 +286,6 @@ static void i370_elf_post_process_headers
   PARAMS ((bfd *, struct bfd_link_info *));
 static bfd_boolean i370_elf_create_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean i370_elf_section_from_shdr
-  PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
 static bfd_boolean i370_elf_fake_sections
   PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
 static bfd_boolean i370_elf_check_relocs
@@ -367,8 +365,8 @@ i370_elf_merge_private_bfd_data (ibfd, obfd)
   else                                 /* Incompatible flags */
     {
       (*_bfd_error_handler)
-       ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
-        bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
+       ("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
+        ibfd, (long) new_flags, (long) old_flags);
 
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
@@ -385,15 +383,15 @@ i370_elf_merge_private_bfd_data (ibfd, obfd)
  */
 
 static bfd_boolean
-i370_elf_section_from_shdr (abfd, hdr, name)
-     bfd *abfd;
-     Elf_Internal_Shdr *hdr;
-     const char *name;
+i370_elf_section_from_shdr (bfd *abfd,
+                           Elf_Internal_Shdr *hdr,
+                           const char *name,
+                           int shindex)
 {
   asection *newsect;
   flagword flags;
 
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
     return FALSE;
 
   newsect = hdr->bfd_section;
@@ -451,24 +449,24 @@ i370_elf_create_dynamic_sections (abfd, info)
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
           | SEC_LINKER_CREATED);
 
-  s = bfd_make_section (abfd, ".dynsbss");
-  if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
+  s = bfd_make_section_with_flags (abfd, ".dynsbss",
+                                  SEC_ALLOC | SEC_LINKER_CREATED);
+  if (s == NULL)
     return FALSE;
 
   if (! info->shared)
     {
-      s = bfd_make_section (abfd, ".rela.sbss");
+      s = bfd_make_section_with_flags (abfd, ".rela.sbss",
+                                      flags | SEC_READONLY);
       if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
          || ! bfd_set_section_alignment (abfd, s, 2))
        return FALSE;
     }
 
    /* xxx beats me, seem to need a rela.text ...  */
-   s = bfd_make_section (abfd, ".rela.text");
+   s = bfd_make_section_with_flags (abfd, ".rela.text",
+                                   flags | SEC_READONLY);
    if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
       || ! bfd_set_section_alignment (abfd, s, 2))
     return FALSE;
   return TRUE;
@@ -500,14 +498,11 @@ i370_elf_adjust_dynamic_symbol (info, h)
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
-             && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
-                 || h->weakdef != NULL
-                 || ((h->elf_link_hash_flags
-                      & ELF_LINK_HASH_DEF_DYNAMIC) != 0
-                     && (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_REF_REGULAR) != 0
-                     && (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_DEF_REGULAR) == 0)));
+             && (h->needs_plt
+                 || h->u.weakdef != NULL
+                 || (h->def_dynamic
+                     && h->ref_regular
+                     && !h->def_regular)));
 
   s = bfd_get_section_by_name (dynobj, ".rela.text");
   BFD_ASSERT (s != NULL);
@@ -516,12 +511,12 @@ i370_elf_adjust_dynamic_symbol (info, h)
   /* If this is a weak symbol, and there is a real definition, the
      processor independent code will have arranged for us to see the
      real definition first, and we can just use the same value.  */
-  if (h->weakdef != NULL)
+  if (h->u.weakdef != NULL)
     {
-      BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
-                 || h->weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->weakdef->root.u.def.section;
-      h->root.u.def.value = h->weakdef->root.u.def.value;
+      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+                 || h->u.weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
       return TRUE;
     }
 
@@ -569,7 +564,7 @@ i370_elf_adjust_dynamic_symbol (info, h)
        srel = bfd_get_section_by_name (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
-      h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
+      h->needs_copy = 1;
     }
 
   /* We need to figure out the alignment required for this symbol.  I
@@ -704,7 +699,7 @@ i370_elf_size_dynamic_sections (output_bfd, info)
          if (s->size == 0)
            {
              /* Strip this section if we don't need it; see the
-                 comment below.  */
+                comment below.  */
              strip = TRUE;
            }
          else
@@ -761,18 +756,12 @@ i370_elf_size_dynamic_sections (output_bfd, info)
 
       if (strip)
        {
-         asection **spp;
-
-         for (spp = &s->output_section->owner->sections;
-              *spp != NULL;
-              spp = &(*spp)->next)
+         if (!bfd_section_removed_from_list (s->output_section->owner,
+                                             s->output_section))
            {
-             if (*spp == s->output_section)
-               {
-                 bfd_section_list_remove (s->output_section->owner, spp);
-                 --s->output_section->owner->section_count;
-                 break;
-               }
+             bfd_section_list_remove (s->output_section->owner,
+                                      s->output_section);
+             --s->output_section->owner->section_count;
            }
          continue;
        }
@@ -891,9 +880,8 @@ i370_elf_check_relocs (abfd, info, sec, relocs)
     return TRUE;
 
 #ifdef DEBUG
-  fprintf (stderr, "i370_elf_check_relocs called for section %s in %s\n",
-          bfd_get_section_name (abfd, sec),
-          bfd_archive_filename (abfd));
+  _bfd_error_handler ("i370_elf_check_relocs called for section %A in %B",
+                     sec, abfd);
 #endif
 
   dynobj = elf_hash_table (info)->dynobj;
@@ -942,13 +930,13 @@ i370_elf_check_relocs (abfd, info, sec, relocs)
                {
                  flagword flags;
 
-                 sreloc = bfd_make_section (dynobj, name);
                  flags = (SEC_HAS_CONTENTS | SEC_READONLY
                           | SEC_IN_MEMORY | SEC_LINKER_CREATED);
                  if ((sec->flags & SEC_ALLOC) != 0)
                    flags |= SEC_ALLOC | SEC_LOAD;
+                 sreloc = bfd_make_section_with_flags (dynobj, name,
+                                                       flags);
                  if (sreloc == NULL
-                     || ! bfd_set_section_flags (dynobj, sreloc, flags)
                      || ! bfd_set_section_alignment (dynobj, sreloc, 2))
                    return FALSE;
                }
@@ -1034,20 +1022,16 @@ i370_elf_finish_dynamic_sections (output_bfd, info)
        }
     }
 
-  /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can
-     easily find the address of the _GLOBAL_OFFSET_TABLE_.  */
-/* XXX this is clearly very wrong for the 370 arch */
   if (sgot)
     {
       unsigned char *contents = sgot->contents;
-      bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
 
       if (sdyn == NULL)
-       bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
+       bfd_put_32 (output_bfd, (bfd_vma) 0, contents);
       else
        bfd_put_32 (output_bfd,
                    sdyn->output_section->vma + sdyn->output_offset,
-                   contents+4);
+                   contents);
 
       elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
     }
@@ -1094,7 +1078,7 @@ i370_elf_finish_dynamic_sections (output_bfd, info)
        }
 
       /* Set the sh_info field of the output .dynsym section to the
-         index of the first global symbol.  */
+        index of the first global symbol.  */
       elf_section_data (sdynsym->output_section)->this_hdr.sh_info =
        maxdindx + 1;
     }
@@ -1156,11 +1140,10 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
     return TRUE;
 
 #ifdef DEBUG
-  fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n",
-          bfd_archive_filename (input_bfd),
-          bfd_section_name(input_bfd, input_section),
-          (long) input_section->reloc_count,
-          (info->relocatable) ? " (relocatable)" : "");
+  _bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %ld relocations%s",
+                     input_bfd, input_section,
+                     (long) input_section->reloc_count,
+                     (info->relocatable) ? " (relocatable)" : "");
 #endif
 
   if (!i370_elf_howto_table[ R_I370_ADDR31 ])  /* Initialize howto table if needed */
@@ -1186,8 +1169,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
       if ((unsigned)r_type >= (unsigned)R_I370_max
          || !i370_elf_howto_table[(int)r_type])
        {
-         (*_bfd_error_handler) ("%s: unknown relocation type %d",
-                                bfd_archive_filename (input_bfd),
+         (*_bfd_error_handler) ("%B: unknown relocation type %d",
+                                input_bfd,
                                 (int) r_type);
 
          bfd_set_error (bfd_error_bad_value);
@@ -1220,8 +1203,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              sec = h->root.u.def.section;
              if (info->shared
                  && ((! info->symbolic && h->dynindx != -1)
-                     || (h->elf_link_hash_flags
-                         & ELF_LINK_HASH_DEF_REGULAR) == 0)
+                     || !h->def_regular)
                  && (input_section->flags & SEC_ALLOC) != 0
                  && (r_type == R_I370_ADDR31
                      || r_type == R_I370_COPY
@@ -1229,8 +1211,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                      || r_type == R_I370_RELATIVE))
                {
                  /* In these cases, we don't need the relocation
-                     value.  We check specially because in some
-                     obscure cases sec->output_section will be NULL.  */
+                    value.  We check specially because in some
+                    obscure cases sec->output_section will be NULL.  */
                  relocation = 0;
                }
              else
@@ -1262,9 +1244,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
        default:
          (*_bfd_error_handler)
-           ("%s: unknown relocation type %d for symbol %s",
-            bfd_archive_filename (input_bfd),
-            (int) r_type, sym_name);
+           ("%B: unknown relocation type %d for symbol %s",
+            input_bfd, (int) r_type, sym_name);
 
          bfd_set_error (bfd_error_bad_value);
          ret = FALSE;
@@ -1274,7 +1255,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          continue;
 
        /* Relocations that may need to be propagated if this is a shared
-           object.  */
+          object.  */
        case (int)R_I370_REL31:
          /* If these relocations are not to a named symbol, they can be
             handled right here, no need to bother the dynamic linker.  */
@@ -1284,7 +1265,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        /* fall through */
 
        /* Relocations that always need to be propagated if this is a shared
-           object.  */
+          object.  */
        case (int)R_I370_ADDR31:
        case (int)R_I370_ADDR16:
          if (info->shared
@@ -1301,8 +1282,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 #endif
 
              /* When generating a shared object, these relocations
-                 are copied into the output file to be resolved at run
-                 time.  */
+                are copied into the output file to be resolved at run
+                time.  */
 
              if (sreloc == NULL)
                {
@@ -1338,11 +1319,10 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              if (skip)
                memset (&outrel, 0, sizeof outrel);
              /* h->dynindx may be -1 if this symbol was marked to
-                 become local.  */
+                become local.  */
              else if (h != NULL
                       && ((! info->symbolic && h->dynindx != -1)
-                          || (h->elf_link_hash_flags
-                              & ELF_LINK_HASH_DEF_REGULAR) == 0))
+                          || !h->def_regular))
                {
                  BFD_ASSERT (h->dynindx != -1);
                  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
@@ -1393,8 +1373,8 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
              /* This reloc will be computed at runtime, so there's no
-                 need to do anything now, unless this is a RELATIVE
-                 reloc in an unallocated section.  */
+                need to do anything now, unless this is a RELATIVE
+                reloc in an unallocated section.  */
              if (skip == -1
                  || (input_section->flags & SEC_ALLOC) != 0
                  || ELF32_R_TYPE (outrel.r_info) != R_I370_RELATIVE)
@@ -1405,8 +1385,8 @@ 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_archive_filename (input_bfd),
+           ("%B: Relocation %s is not yet supported for symbol %s.",
+            input_bfd,
             i370_elf_howto_table[(int) r_type]->name,
             sym_name);
 
@@ -1446,7 +1426,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                const char *name;
 
                if (h != NULL)
-                 name = h->root.root.string;
+                 name = NULL;
                else
                  {
                    name = bfd_elf_string_from_elf_section (input_bfd,
@@ -1460,6 +1440,7 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  }
 
                (*info->callbacks->reloc_overflow) (info,
+                                                   (h ? &h->root : NULL),
                                                    name,
                                                    howto->name,
                                                    (bfd_vma) 0,
@@ -1502,7 +1483,6 @@ i370_elf_post_process_headers (abfd, link_info)
 #define elf_info_to_howto      i370_elf_info_to_howto
 
 #define elf_backend_plt_not_loaded 1
-#define elf_backend_got_symbol_offset 4
 #define elf_backend_rela_normal 1
 
 #define bfd_elf32_bfd_reloc_type_lookup                i370_elf_reloc_type_lookup
This page took 0.028627 seconds and 4 git commands to generate.