Delete duplicate target short-cuts to dynamic sections
[deliverable/binutils-gdb.git] / bfd / elf32-xstormy16.c
index cab0f23794dce6938251fb1c2ada053927437325..1c458a587afb0f9b7caf0f00beb01351e8364bd8 100644 (file)
@@ -417,7 +417,6 @@ xstormy16_elf_check_relocs (bfd *abfd,
   symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   local_plt_offsets = elf_local_got_offsets (abfd);
-  splt = NULL;
   dynobj = elf_hash_table(info)->dynobj;
 
   relend = relocs + sec->reloc_count;
@@ -457,21 +456,19 @@ xstormy16_elf_check_relocs (bfd *abfd,
 
          if (dynobj == NULL)
            elf_hash_table (info)->dynobj = dynobj = abfd;
+         splt = elf_hash_table (info)->splt;
          if (splt == NULL)
            {
-             splt = bfd_get_linker_section (dynobj, ".plt");
-             if (splt == NULL)
-               {
-                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
-                                   | SEC_READONLY | SEC_CODE);
-
-                 splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
-                                                            flags);
-                 if (splt == NULL
-                     || ! bfd_set_section_alignment (dynobj, splt, 1))
-                   return FALSE;
-               }
+             flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                               | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                               | SEC_READONLY | SEC_CODE);
+
+             splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+                                                        flags);
+             elf_hash_table (info)->splt = splt;
+             if (splt == NULL
+                 || ! bfd_set_section_alignment (dynobj, splt, 1))
+               return FALSE;
            }
 
          if (h != NULL)
@@ -719,7 +716,7 @@ xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
   BFD_ASSERT (splt != NULL);
 
   splt->contents = bfd_zalloc (dynobj, splt->size);
@@ -773,17 +770,13 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
   struct elf_link_hash_entry ** sym_hashes;
   Elf_Internal_Rela *           rel;
   Elf_Internal_Rela *           relend;
-  bfd *dynobj;
   asection *splt;
 
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
   relend     = relocs + input_section->reloc_count;
 
-  dynobj = elf_hash_table (info)->dynobj;
-  splt = NULL;
-  if (dynobj != NULL)
-    splt = bfd_get_linker_section (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
 
   for (rel = relocs; rel < relend; rel ++)
     {
@@ -962,14 +955,13 @@ static bfd_boolean
 xstormy16_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
                                       struct bfd_link_info *info)
 {
-  bfd *dynobj;
-  asection *splt;
+  bfd *dynobj = elf_hash_table (info)->dynobj;
+  asection *splt = elf_hash_table (info)->splt;
 
   /* As an extra sanity check, verify that all plt entries have
      been filled in.  */
 
-  if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
+  if (dynobj != NULL && splt != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
This page took 0.027272 seconds and 4 git commands to generate.