hacks to prevent ld crashes

This commit is contained in:
Wolfgang Thaller 2015-08-31 16:45:02 +02:00
parent 1c6c1ddd9f
commit c58b44596a
3 changed files with 8 additions and 2 deletions

View File

@ -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,

View File

@ -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

View File

@ -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;