]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[HPPA] Attach linker created dynamic sections to stub bfd
authorAlan Modra <amodra@gmail.com>
Wed, 11 May 2016 13:21:14 +0000 (22:51 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 11 May 2016 13:21:14 +0000 (22:51 +0930)
bfd/
* elf32-hppa.c (elf32_hppa_init_stub_bfd): New function.
(elf32_hppa_check_relocs): Don't set dynobj.
(elf32_hppa_size_stubs): Test !SEC_LINKER_CREATED for stub sections.
(elf32_hppa_build_stubs): Likewise.
* elf32-hppa.h (elf32_hppa_init_stub_bfd): Declare.
ld/
* emultempl/hppaelf.em (hppaelf_create_output_section_statements):
Call elf32_hppa_init_stub_bfd.

bfd/ChangeLog
bfd/elf32-hppa.c
bfd/elf32-hppa.h
ld/ChangeLog
ld/emultempl/hppaelf.em

index 595d7245341c1b46f4204efca1ac1299c0dd1753..25d1db60893da27c8e3d1afa08bd557c28285c49 100644 (file)
@@ -1,3 +1,11 @@
+2016-05-11  Alan Modra  <amodra@gmail.com>
+
+       * elf32-hppa.c (elf32_hppa_init_stub_bfd): New function.
+       (elf32_hppa_check_relocs): Don't set dynobj.
+       (elf32_hppa_size_stubs): Test !SEC_LINKER_CREATED for stub sections.
+       (elf32_hppa_build_stubs): Likewise.
+       * elf32-hppa.h (elf32_hppa_init_stub_bfd): Declare.
+
 2016-05-11  Alan Modra  <amodra@gmail.com>
 
        PR 20060
index 699d02a58282a4f3edb0f527964c8e0c42c72bf0..d67a40eb9cc022b954360542cf3006032d0c181c 100644 (file)
@@ -455,6 +455,18 @@ elf32_hppa_link_hash_table_create (bfd *abfd)
   return &htab->etab.root;
 }
 
+/* Initialize the linker stubs BFD so that we can use it for linker
+   created dynamic sections.  */
+
+void
+elf32_hppa_init_stub_bfd (bfd *abfd, struct bfd_link_info *info)
+{
+  struct elf32_hppa_link_hash_table *htab = hppa_link_hash_table (info);
+
+  elf_elfheader (abfd)->e_ident[EI_CLASS] = ELFCLASS32;
+  htab->etab.dynobj = abfd;
+}
+
 /* Build a name for an entry in the stub hash table.  */
 
 static char *
@@ -1347,8 +1359,6 @@ elf32_hppa_check_relocs (bfd *abfd,
             relocation for this entry.  */
          if (htab->sgot == NULL)
            {
-             if (htab->etab.dynobj == NULL)
-               htab->etab.dynobj = abfd;
              if (!elf32_hppa_create_dynamic_sections (htab->etab.dynobj, info))
                return FALSE;
            }
@@ -1484,9 +1494,6 @@ elf32_hppa_check_relocs (bfd *abfd,
                 this reloc.  */
              if (sreloc == NULL)
                {
-                 if (htab->etab.dynobj == NULL)
-                   htab->etab.dynobj = abfd;
-
                  sreloc = _bfd_elf_make_dynamic_reloc_section
                    (sec, htab->etab.dynobj, 2, abfd, /*rela?*/ TRUE);
 
@@ -3071,7 +3078,8 @@ elf32_hppa_size_stubs
       for (stub_sec = htab->stub_bfd->sections;
           stub_sec != NULL;
           stub_sec = stub_sec->next)
-       stub_sec->size = 0;
+       if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+         stub_sec->size = 0;
 
       bfd_hash_traverse (&htab->bstab, hppa_size_one_stub, htab);
 
@@ -3193,16 +3201,15 @@ elf32_hppa_build_stubs (struct bfd_link_info *info)
   for (stub_sec = htab->stub_bfd->sections;
        stub_sec != NULL;
        stub_sec = stub_sec->next)
-    {
-      bfd_size_type size;
-
-      /* Allocate memory to hold the linker stubs.  */
-      size = stub_sec->size;
-      stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
-      if (stub_sec->contents == NULL && size != 0)
-       return FALSE;
-      stub_sec->size = 0;
-    }
+    if ((stub_sec->flags & SEC_LINKER_CREATED) == 0
+       && stub_sec->size != 0)
+      {
+       /* Allocate memory to hold the linker stubs.  */
+       stub_sec->contents = bfd_zalloc (htab->stub_bfd, stub_sec->size);
+       if (stub_sec->contents == NULL)
+         return FALSE;
+       stub_sec->size = 0;
+      }
 
   /* Build the stubs as directed by the stub hash table.  */
   table = &htab->bstab;
index 87ae5f1f090136f81e606bdd2776c35b70c54da6..ad5cb18935d57832441308f70d66393d7a0c0173 100644 (file)
@@ -36,6 +36,9 @@
 #include "libhppa.h"
 #include "elf/hppa.h"
 
+void elf32_hppa_init_stub_bfd
+  (bfd *, struct bfd_link_info *);
+
 int elf32_hppa_setup_section_lists
   (bfd *, struct bfd_link_info *);
 
index 734c4b5bb6240646d721042fb1c8628b79b8da7d..5c609e2bb17df5cbde20910c8626c6e4dcddf550 100644 (file)
@@ -1,3 +1,8 @@
+2016-05-11  Alan Modra  <amodra@gmail.com>
+
+       * emultempl/hppaelf.em (hppaelf_create_output_section_statements):
+       Call elf32_hppa_init_stub_bfd.
+
 2016-05-11  Alan Modra  <amodra@gmail.com>
 
        PR 20060
index a1d2e80d2a82aaa2215fab88af1dc8e8d493818f..965f9866e61388c11c2b2c798083ba60f32255a9 100644 (file)
@@ -88,6 +88,7 @@ hppaelf_create_output_section_statements (void)
 
   stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
   ldlang_add_file (stub_file);
+  elf32_hppa_init_stub_bfd (stub_file->the_bfd, &link_info);
 }