diff --git a/binutils/bfd/coff-rs6000.c b/binutils/bfd/coff-rs6000.c index fea5f3bc5e..33e0e9567f 100644 --- a/binutils/bfd/coff-rs6000.c +++ b/binutils/bfd/coff-rs6000.c @@ -367,7 +367,7 @@ _bfd_xcoff_copy_private_bfd_data (bfd *ibfd, bfd *obfd) else { sec = coff_section_from_bfd_index (ibfd, ix->sntoc); - if (sec == NULL) + if (sec == NULL || sec->output_section == NULL) ox->sntoc = 0; else ox->sntoc = sec->output_section->target_index; @@ -2564,8 +2564,12 @@ _bfd_xcoff_sizeof_headers (bfd *abfd, Don't try to renumber sections, just compute the upper bound. */ max_index = 0; for (s = abfd->sections; s != NULL; s = s->next) + { if (s->index > max_index) max_index = s->index; + } + if(max_index < 32) // ###RetroPPC: apparently, the above upper bound is incorrect. + max_index = 32; /* Allocate the per section counters. It could be possible to use a preallocated array as the number of sections is limited on XCOFF, diff --git a/binutils/bfd/dwarf2.c b/binutils/bfd/dwarf2.c index 2ba36fdc52..e7ecfbd8e3 100644 --- a/binutils/bfd/dwarf2.c +++ b/binutils/bfd/dwarf2.c @@ -3619,6 +3619,8 @@ save_section_vma (const bfd *abfd, struct dwarf2_debug *stash) return FALSE; for (i = 0, s = abfd->sections; i < abfd->section_count; i++, s = s->next) { + if(!s) // ###RetroPPC: apparently, section_count can be wrong?. + break; if (s->output_section != NULL) stash->sec_vma[i] = s->output_section->vma + s->output_offset; else diff --git a/binutils/bfd/xcofflink.c b/binutils/bfd/xcofflink.c index 7f321ee241..067d53df46 100644 --- a/binutils/bfd/xcofflink.c +++ b/binutils/bfd/xcofflink.c @@ -3871,7 +3871,7 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd, esym = (bfd_byte *) obj_coff_external_syms (sub); esymend = esym + symcount * symesz; - while (esym < esymend) + while (csectpp && esym < esymend) { struct internal_syment sym; union internal_auxent aux;