2
0
mirror of https://frontier.innolan.net/github/amigaos-binutils.git synced 2025-11-23 07:25:48 +00:00

patch also the stab generated offsets

This commit is contained in:
bebbo
2018-03-11 20:35:56 +01:00
parent 4134f14880
commit 7f1f4229f1

View File

@ -151,6 +151,7 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
* 2. perform relocation to the new jmp * 2. perform relocation to the new jmp
* 3. patch the relent: address and howto * 3. patch the relent: address and howto
* 4. patch output_offsets of all input_sections starting behind current input_section * 4. patch output_offsets of all input_sections starting behind current input_section
* 5. patch bfd_section_reloc_link_order entries since the linker already put an offset into these.
* *
* Since the output offsets may change, a dry run is needed to precompute the new section sizes and offsets. * Since the output offsets may change, a dry run is needed to precompute the new section sizes and offsets.
* *
@ -197,7 +198,7 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
DPRINT(10, ("%s: %d relocs\n", s->owner->filename, s->reloc_count)); DPRINT(10, ("%s: %d relocs\n", s->owner->filename, s->reloc_count));
// reset _raw_size // reset rawsize
unsigned cursize = s->_raw_size; unsigned cursize = s->_raw_size;
s->_raw_size = (unsigned)s->userdata; s->_raw_size = (unsigned)s->userdata;
@ -221,10 +222,6 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
DPRINT(10, ("%s %d, ", src->symbol->name, dist)); DPRINT(10, ("%s %d, ", src->symbol->name, dist));
printf("INFO: using long jump from %s to %s:%s\n", s->owner->filename,
src->symbol->section->owner->filename, src->symbol->name);
fflush(stdout);
// check last generated jumps // check last generated jumps
if (rel_jumps) if (rel_jumps)
{ {
@ -274,18 +271,32 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
if (delta == 0) if (delta == 0)
continue; continue;
struct bfd_link_order * lo;
// 5. also patch data's link statements with bfd_section_reloc_link_order, needed for CTs
asection * xs = s->output_section;
for(;xs;xs = xs->next)
{
for (lo = xs->link_order_head; lo; lo = lo->next)
{
if (lo->type == bfd_section_reloc_link_order && lo->u.reloc.p->u.section == s->output_section
&& lo->u.reloc.p->addend >= s->_raw_size + s->output_offset)
lo->u.reloc.p->addend += delta;
}
}
s->output_section->_raw_size += delta; s->output_section->_raw_size += delta;
s->_cooked_size = s->_raw_size; s->_cooked_size = s->_raw_size;
lo1->size += delta; lo1->size += delta;
// 4. // 4. update output_offsets
struct bfd_link_order * lo = lo1->next; for (lo = lo1->next; lo; lo = lo->next)
for (; lo; lo = lo->next)
{ {
asection * s = lo->u.indirect.section; asection * ss = lo->u.indirect.section;
if (0 == strcmp(s->name, ".text")) if (0 == strcmp(ss->name, ".text"))
{ {
s->output_offset += delta; ss->output_offset += delta;
lo->offset += delta; lo->offset += delta;
} }
} }
@ -296,6 +307,8 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
break; break;
} }
input_section->output_section->_cooked_size = input_section->output_section->_raw_size;
// reset count // reset count
rel_jumps_count = 0; rel_jumps_count = 0;
@ -313,7 +326,7 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
} }
/** /**
* * Create the jump tables.
*/ */
if (input_section->owner->xvec->flavour == bfd_target_amiga_flavour && input_section->reloc_count > 0) if (input_section->owner->xvec->flavour == bfd_target_amiga_flavour && input_section->reloc_count > 0)
{ {
@ -364,6 +377,9 @@ static void insert_long_jumps(bfd * abfd, bfd * input_bfd, asection *input_secti
} }
} }
printf("INFO: using long jump from %s to %s:%s\n", input_section->owner->filename,
src->symbol->section->owner->filename, src->symbol->name);
fflush(stdout);
// 1. append a long jump // 1. append a long jump
signed endpos = (unsigned)input_section->userdata; signed endpos = (unsigned)input_section->userdata;