aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2005-06-06 13:16:15 +0000
committerAlan Modra <amodra@gmail.com>2005-06-06 13:16:15 +0000
commit46de2a7c487120233d6331aa25109dd2aaf83b8b (patch)
tree7cfdcdfb92486135a71dfe4b4bbceece4fa6d380 /bfd/elf64-ppc.c
parentb4f4e59ffff89dd86068046263008836e145ae41 (diff)
downloadgdb-46de2a7c487120233d6331aa25109dd2aaf83b8b.zip
gdb-46de2a7c487120233d6331aa25109dd2aaf83b8b.tar.gz
gdb-46de2a7c487120233d6331aa25109dd2aaf83b8b.tar.bz2
* elf64-ppc.c (ppc_stub_name): Return immediately on bfd_malloc fail.
(ppc64_elf_edit_opd): Ignore zero size .opd. Check bfd_alloc return value.
Diffstat (limited to 'bfd/elf64-ppc.c')
-rw-r--r--bfd/elf64-ppc.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 5c398b1..bd122cf 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3581,26 +3581,26 @@ ppc_stub_name (const asection *input_section,
{
len = 8 + 1 + strlen (h->elf.root.root.string) + 1 + 8 + 1;
stub_name = bfd_malloc (len);
- if (stub_name != NULL)
- {
- sprintf (stub_name, "%08x.%s+%x",
- input_section->id & 0xffffffff,
- h->elf.root.root.string,
- (int) rel->r_addend & 0xffffffff);
- }
+ if (stub_name == NULL)
+ return stub_name;
+
+ sprintf (stub_name, "%08x.%s+%x",
+ input_section->id & 0xffffffff,
+ h->elf.root.root.string,
+ (int) rel->r_addend & 0xffffffff);
}
else
{
len = 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
stub_name = bfd_malloc (len);
- if (stub_name != NULL)
- {
- sprintf (stub_name, "%08x.%x:%x+%x",
- input_section->id & 0xffffffff,
- sym_sec->id & 0xffffffff,
- (int) ELF64_R_SYM (rel->r_info) & 0xffffffff,
- (int) rel->r_addend & 0xffffffff);
- }
+ if (stub_name == NULL)
+ return stub_name;
+
+ sprintf (stub_name, "%08x.%x:%x+%x",
+ input_section->id & 0xffffffff,
+ sym_sec->id & 0xffffffff,
+ (int) ELF64_R_SYM (rel->r_info) & 0xffffffff,
+ (int) rel->r_addend & 0xffffffff);
}
if (stub_name[len - 2] == '+' && stub_name[len - 1] == '0')
stub_name[len - 2] = 0;
@@ -6176,7 +6176,7 @@ ppc64_elf_edit_opd (bfd *obfd, struct bfd_link_info *info,
bfd_size_type cnt_16b = 0;
sec = bfd_get_section_by_name (ibfd, ".opd");
- if (sec == NULL)
+ if (sec == NULL || sec->size == 0)
continue;
amt = sec->size * sizeof (long) / 8;
@@ -6186,6 +6186,8 @@ ppc64_elf_edit_opd (bfd *obfd, struct bfd_link_info *info,
/* check_relocs hasn't been called. Must be a ld -r link
or --just-symbols object. */
opd_adjust = bfd_alloc (obfd, amt);
+ if (opd_adjust == NULL)
+ return FALSE;
ppc64_elf_section_data (sec)->opd.adjust = opd_adjust;
}
memset (opd_adjust, 0, amt);