summaryrefslogtreecommitdiff
path: root/bfd/elf32-hppa.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-hppa.c')
-rw-r--r--bfd/elf32-hppa.c69
1 files changed, 17 insertions, 52 deletions
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 432ec1da35..8bea3c67d1 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -334,7 +334,7 @@ static boolean elf32_hppa_check_relocs
asection *, const Elf_Internal_Rela *));
static asection *elf32_hppa_gc_mark_hook
- PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *, Elf_Internal_Sym *));
static boolean elf32_hppa_gc_sweep_hook
@@ -1632,8 +1632,8 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs)
for a given relocation. */
static asection *
-elf32_hppa_gc_mark_hook (abfd, info, rel, h, sym)
- bfd *abfd;
+elf32_hppa_gc_mark_hook (sec, info, rel, h, sym)
+ asection *sec;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
Elf_Internal_Rela *rel;
struct elf_link_hash_entry *h;
@@ -1663,9 +1663,7 @@ elf32_hppa_gc_mark_hook (abfd, info, rel, h, sym)
}
}
else
- {
- return bfd_section_from_elf_index (abfd, sym->st_shndx);
- }
+ return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
return NULL;
}
@@ -2996,10 +2994,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
section != NULL;
section = section->next)
{
- Elf_Internal_Shdr *input_rel_hdr;
- Elf32_External_Rela *external_relocs, *erelaend, *erela;
Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
- bfd_size_type amt;
/* If there aren't any relocs, then there's nothing more
to do. */
@@ -3013,47 +3008,13 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
|| section->output_section->owner != output_bfd)
continue;
- /* Allocate space for the external relocations. */
- amt = section->reloc_count;
- amt *= sizeof (Elf32_External_Rela);
- external_relocs = (Elf32_External_Rela *) bfd_malloc (amt);
- if (external_relocs == NULL)
- {
- goto error_ret_free_local;
- }
-
- /* Likewise for the internal relocations. */
- amt = section->reloc_count;
- amt *= sizeof (Elf_Internal_Rela);
- internal_relocs = (Elf_Internal_Rela *) bfd_malloc (amt);
+ /* Get the relocs. */
+ internal_relocs
+ = _bfd_elf32_link_read_relocs (input_bfd, section, NULL,
+ (Elf_Internal_Rela *) NULL,
+ info->keep_memory);
if (internal_relocs == NULL)
- {
- free (external_relocs);
- goto error_ret_free_local;
- }
-
- /* Read in the external relocs. */
- input_rel_hdr = &elf_section_data (section)->rel_hdr;
- if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0
- || bfd_bread ((PTR) external_relocs,
- input_rel_hdr->sh_size,
- input_bfd) != input_rel_hdr->sh_size)
- {
- free (external_relocs);
- error_ret_free_internal:
- free (internal_relocs);
- goto error_ret_free_local;
- }
-
- /* Swap in the relocs. */
- erela = external_relocs;
- erelaend = erela + section->reloc_count;
- irela = internal_relocs;
- for (; erela < erelaend; erela++, irela++)
- bfd_elf32_swap_reloca_in (input_bfd, erela, irela);
-
- /* We're done with the external relocs, free them. */
- free (external_relocs);
+ goto error_ret_free_local;
/* Now examine each relocation. */
irela = internal_relocs;
@@ -3076,7 +3037,10 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
if (r_type >= (unsigned int) R_PARISC_UNIMPLEMENTED)
{
bfd_set_error (bfd_error_bad_value);
- goto error_ret_free_internal;
+ error_ret_free_internal:
+ if (elf_section_data (section)->relocs == NULL)
+ free (internal_relocs);
+ goto error_ret_free_local;
}
/* Only look for stubs on call instructions. */
@@ -3179,7 +3143,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
if (stub_entry == NULL)
{
free (stub_name);
- goto error_ret_free_local;
+ goto error_ret_free_internal;
}
stub_entry->target_value = sym_value;
@@ -3197,7 +3161,8 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size,
}
/* We're done with the internal relocs, free them. */
- free (internal_relocs);
+ if (elf_section_data (section)->relocs == NULL)
+ free (internal_relocs);
}
}