* elf64-alpha.c (elf64_alpha_create_got_section): Always create
authorAlan Modra <amodra@gmail.com>
Fri, 1 Jul 2005 04:46:08 +0000 (04:46 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 1 Jul 2005 04:46:08 +0000 (04:46 +0000)
a new .got section.
(elf64_alpha_create_dynamic_sections): Always make new sections
by using bfd_make_section_anyway_with_flags.  Check that .got not
already created.
(elf64_alpha_check_relocs): Delete "got_created".  Use tdata->gotobj
instead.

bfd/ChangeLog
bfd/elf64-alpha.c

index ad9a7c6..aa7a258 100644 (file)
@@ -1,3 +1,13 @@
+2005-07-01  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf64-alpha.c (elf64_alpha_create_got_section): Always create
+       a new .got section.
+       (elf64_alpha_create_dynamic_sections): Always make new sections
+       by using bfd_make_section_anyway_with_flags.  Check that .got not
+       already created.
+       (elf64_alpha_check_relocs): Delete "got_created".  Use tdata->gotobj
+       instead.
+
 2005-06-30  Alan Modra  <amodra@bigpond.net.au>
 
        * elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Ignore dynamic
index 70642a3..ac7ada2 100644 (file)
@@ -1204,26 +1204,23 @@ static bfd_boolean
 elf64_alpha_create_got_section (bfd *abfd,
                                struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
+  flagword flags;
   asection *s;
 
-  if ((s = bfd_get_section_by_name (abfd, ".got")))
-    {
-      /* Check for a non-linker created .got?  */
-      if (alpha_elf_tdata (abfd)->got == NULL)
-       alpha_elf_tdata (abfd)->got = s;
-      return TRUE;
-    }
-
-  s = bfd_make_section_with_flags (abfd, ".got", (SEC_ALLOC | SEC_LOAD
-                                                 | SEC_HAS_CONTENTS
-                                                 | SEC_IN_MEMORY
-                                                 | SEC_LINKER_CREATED));
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+          | SEC_LINKER_CREATED);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
 
   alpha_elf_tdata (abfd)->got = s;
 
+  /* Make sure the object's gotobj is set to itself so that we default
+     to every object with its own .got.  We'll merge .gots later once
+     we've collected each object's info.  */
+  alpha_elf_tdata (abfd)->gotobj = abfd;
+
   return TRUE;
 }
 
@@ -1233,18 +1230,16 @@ static bfd_boolean
 elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 {
   asection *s;
+  flagword flags;
   struct elf_link_hash_entry *h;
   struct bfd_link_hash_entry *bh;
 
   /* We need to create .plt, .rela.plt, .got, and .rela.got sections.  */
 
-  s = bfd_make_section_with_flags (abfd, ".plt",
-                                  (SEC_ALLOC | SEC_LOAD | SEC_CODE
-                                   | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY
-                                   | SEC_LINKER_CREATED
-                                   | (elf64_alpha_use_secureplt
-                                      ? SEC_READONLY : 0)));
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+          | SEC_LINKER_CREATED
+          | (elf64_alpha_use_secureplt ? SEC_READONLY : 0));
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags);
   if (s == NULL || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
 
@@ -1263,19 +1258,16 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   if (info->shared && ! bfd_elf_link_record_dynamic_symbol (info, h))
     return FALSE;
 
-  s = bfd_make_section_with_flags (abfd, ".rela.plt",
-                                  (SEC_ALLOC | SEC_LOAD
-                                   | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY
-                                   | SEC_LINKER_CREATED
-                                   | SEC_READONLY));
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+          | SEC_LINKER_CREATED | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.plt", flags);
   if (s == NULL || ! bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
 
   if (elf64_alpha_use_secureplt)
     {
-      s = bfd_make_section_with_flags (abfd, ".got.plt",
-                                      SEC_ALLOC | SEC_LINKER_CREATED);
+      flags = SEC_ALLOC | SEC_LINKER_CREATED;
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
       if (s == NULL || ! bfd_set_section_alignment (abfd, s, 3))
        return FALSE;
     }
@@ -1283,15 +1275,15 @@ elf64_alpha_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   /* We may or may not have created a .got section for this object, but
      we definitely havn't done the rest of the work.  */
 
-  if (!elf64_alpha_create_got_section (abfd, info))
-    return FALSE;
+  if (alpha_elf_tdata(abfd)->gotobj == NULL)
+    {
+      if (!elf64_alpha_create_got_section (abfd, info))
+       return FALSE;
+    }
 
-  s = bfd_make_section_with_flags (abfd, ".rela.got",
-                                  (SEC_ALLOC | SEC_LOAD
-                                   | SEC_HAS_CONTENTS
-                                   | SEC_IN_MEMORY
-                                   | SEC_LINKER_CREATED
-                                   | SEC_READONLY));
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+          | SEC_LINKER_CREATED | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.got", flags);
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
@@ -1746,7 +1738,6 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info,
   Elf_Internal_Shdr *symtab_hdr;
   struct alpha_elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel, *relend;
-  bfd_boolean got_created;
   bfd_size_type amt;
 
   if (info->relocatable)
@@ -1769,7 +1760,6 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info,
   rel_sec_name = NULL;
   symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
   sym_hashes = alpha_elf_sym_hashes(abfd);
-  got_created = FALSE;
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; ++rel)
@@ -1881,18 +1871,10 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
       if (need & NEED_GOT)
        {
-         if (!got_created)
+         if (alpha_elf_tdata(abfd)->gotobj == NULL)
            {
              if (!elf64_alpha_create_got_section (abfd, info))
                return FALSE;
-
-             /* Make sure the object's gotobj is set to itself so
-                that we default to every object with its own .got.
-                We'll merge .gots later once we've collected each
-                object's info.  */
-             alpha_elf_tdata(abfd)->gotobj = abfd;
-
-             got_created = 1;
            }
        }