aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-hppa.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2016-05-11 22:51:14 +0930
committerAlan Modra <amodra@gmail.com>2016-05-11 22:51:14 +0930
commita464198b013940745d43cff029330b9e7dda71c2 (patch)
treee2e4185ebd4621db9467b5b2205c2821743c017f /bfd/elf32-hppa.c
parent3bd43ebcb6025a8a43f119238f490e2e238697a2 (diff)
downloadgdb-a464198b013940745d43cff029330b9e7dda71c2.zip
gdb-a464198b013940745d43cff029330b9e7dda71c2.tar.gz
gdb-a464198b013940745d43cff029330b9e7dda71c2.tar.bz2
[HPPA] Attach linker created dynamic sections to stub bfd
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.
Diffstat (limited to 'bfd/elf32-hppa.c')
-rw-r--r--bfd/elf32-hppa.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 699d02a..d67a40e 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -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;