diff options
author | Alan Modra <amodra@gmail.com> | 2014-01-16 11:50:28 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2014-01-16 11:56:50 +1030 |
commit | b75d42bce5609effad86fb8b5d902f4c337e0cf9 (patch) | |
tree | a3ab5df94d585120feaccb242f426507e806d98c /bfd/elfxx-mips.c | |
parent | ab7f45ba10d0a1a636a5ce7b4784a1d6ce3e94a3 (diff) | |
download | gdb-b75d42bce5609effad86fb8b5d902f4c337e0cf9.zip gdb-b75d42bce5609effad86fb8b5d902f4c337e0cf9.tar.gz gdb-b75d42bce5609effad86fb8b5d902f4c337e0cf9.tar.bz2 |
Fix mips segfault on GOT access of absolute symbol
When a symbol is absolute, this code in mips_elf_record_got_page_entry
entry = bfd_zalloc (sec->owner, sizeof (*entry));
segfaults. sec == bfd_abs_section_ptr and sec->owner == NULL.
* elfxx-mips.c (mips_elf_record_got_page_entry): Pass in a
mips_elf_traverse_got_arg* rather than mips_got_info*.
Adjust caller. Alloc on output_bfd rather than symbol section
owner.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r-- | bfd/elfxx-mips.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index d5f51a3..f51845b 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -4089,9 +4089,10 @@ mips_elf_pages_for_range (const struct mips_got_page_range *range) /* Record that G requires a page entry that can reach SEC + ADDEND. */ static bfd_boolean -mips_elf_record_got_page_entry (struct mips_got_info *g, +mips_elf_record_got_page_entry (struct mips_elf_traverse_got_arg *arg, asection *sec, bfd_signed_vma addend) { + struct mips_got_info *g = arg->g; struct mips_got_page_entry lookup, *entry; struct mips_got_page_range **range_ptr, *range; bfd_vma old_pages, new_pages; @@ -4108,7 +4109,7 @@ mips_elf_record_got_page_entry (struct mips_got_info *g, entry = (struct mips_got_page_entry *) *loc; if (!entry) { - entry = bfd_zalloc (sec->owner, sizeof (*entry)); + entry = bfd_zalloc (arg->info->output_bfd, sizeof (*entry)); if (!entry) return FALSE; @@ -4128,7 +4129,7 @@ mips_elf_record_got_page_entry (struct mips_got_info *g, range = *range_ptr; if (!range || addend < range->min_addend - 0xffff) { - range = bfd_zalloc (sec->owner, sizeof (*range)); + range = bfd_zalloc (arg->info->output_bfd, sizeof (*range)); if (!range) return FALSE; @@ -4248,7 +4249,7 @@ mips_elf_resolve_got_page_ref (void **refp, void *data) else addend = isym->st_value + ref->addend; } - if (!mips_elf_record_got_page_entry (arg->g, sec, addend)) + if (!mips_elf_record_got_page_entry (arg, sec, addend)) { arg->g = NULL; return 0; |