fix .stab/.stabstr hunks, drop if not a debug version otherwise make these the last hunks

This commit is contained in:
bebbo 2017-12-16 22:28:02 +01:00
parent e5ab1ffedf
commit 72e25c3819
1 changed files with 51 additions and 1 deletions

View File

@ -1594,7 +1594,7 @@ amiga_write_object_contents (abfd)
{
long datadata_relocs = 0, bss_size = 0, idx;
int *index_map, max_hunk = -1;
sec_ptr data_sec, p;
sec_ptr data_sec, p, q;
unsigned long i, n[5];
/* Distinguish UNITS, LOAD Files
@ -1603,6 +1603,56 @@ amiga_write_object_contents (abfd)
abfd->output_has_begun = TRUE; /* Output has begun */
if (AMIGA_DATA(abfd)->IsLoadFile)
{
// shuffle .stab and .stabstr to end
for (q = abfd->sections, p = q->next; p != NULL; q = p, p = p->next)
{
if (0 == strcmp (p->name, ".stab"))
{
if (p->next)
{
q->next = p->next;
if (write_debug_hunk)
{
q = p->next;
while (q->next)
q = q->next;
q->next = p;
p->next = 0;
}
}
else
q->next = 0;
break;
}
}
for (q = abfd->sections, p = q->next; p != NULL; q = p, p = p->next)
{
if (0 == strcmp (p->name, ".stabstr"))
{
if (p->next)
{
q->next = p->next;
if (write_debug_hunk)
{
q = p->next;
while (q->next)
q = q->next;
q->next = p;
p->next = 0;
}
}
else
q->next = 0;
break;
}
}
int n = 0;
for (p = abfd->sections; p != NULL; p = p->next)
p->index = n++;
}
index_map = bfd_alloc (abfd, abfd->section_count * sizeof(int));
if (!index_map)
return FALSE;