aboutsummaryrefslogtreecommitdiff
path: root/bfd/dwarf2.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-05-27 15:38:55 +0930
committerAlan Modra <amodra@gmail.com>2019-05-28 10:05:02 +0930
commit0eb32b6e1dee07ac199b4bba855205e4de099213 (patch)
tree88dc12d092aaa765abbad027322f67724abbb457 /bfd/dwarf2.c
parent58db964680f0f17197849a714c30430deafb8bc7 (diff)
downloadgdb-0eb32b6e1dee07ac199b4bba855205e4de099213.zip
gdb-0eb32b6e1dee07ac199b4bba855205e4de099213.tar.gz
gdb-0eb32b6e1dee07ac199b4bba855205e4de099213.tar.bz2
XCOFF linker segmentation fault
The XCOFF linker temporarily trims the output bfd section list, without adjusting section_count to suit. This is a little rude, but the dwarf line number code can easily cope with this situation. So check for a NULL end of list as well as limiting the saved section VMAs to the first section_count list entries. Also fixes -FAIL: Weak test 3 (main, static) (32-bit) -FAIL: Weak test 3 (main, static) (64-bit) PR 24596 * dwarf2.c (save_section_vma, section_vma_same): Check for NULL end of section list as well as section_count. * xcofflink.c (xcoff_link_add_symbols): Fix temporarily changed section list before returning error.
Diffstat (limited to 'bfd/dwarf2.c')
-rw-r--r--bfd/dwarf2.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 76af009..65c4161 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -4272,7 +4272,9 @@ save_section_vma (const bfd *abfd, struct dwarf2_debug *stash)
if (stash->sec_vma == NULL)
return FALSE;
stash->sec_vma_count = abfd->section_count;
- for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
+ for (i = 0, s = abfd->sections;
+ s != NULL && i < abfd->section_count;
+ i++, s = s->next)
{
if (s->output_section != NULL)
stash->sec_vma[i] = s->output_section->vma + s->output_offset;
@@ -4301,7 +4303,9 @@ section_vma_same (const bfd *abfd, const struct dwarf2_debug *stash)
if (abfd->section_count != stash->sec_vma_count)
return FALSE;
- for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next)
+ for (i = 0, s = abfd->sections;
+ s != NULL && i < abfd->section_count;
+ i++, s = s->next)
{
bfd_vma vma;