Relocating .data at 0x0
Nick Clifton
nickc@cambridge.redhat.com
Tue Jun 12 06:31:00 GMT 2001
Hi David,
> I tracked down the problem to binutils/ld/aoutx.h ~line 1010:
>
> if (abdp && abdp->zmagic_mapped_contiguous)
> {
> text_pad = (obj_datasec(abfd)->vma
> - obj_textsec(abfd)->vma
> - obj_textsec(abfd)->_raw_size);
> obj_textsec(abfd)->_raw_size += text_pad;
> }
>>
> Since the VMA for .text was 0x30 and .data was at 0x0, text_pad is set
> negative and corrupts the .text output section's _raw_size, causing an
> error (the oh-so-descriptive "bad value") in the bfd_final_link stage.
Would you mind trying out the patch below, to see if it fixes the
problem ?
Cheers
Nick
2001-06-12 Nick Clifton <nickc@cambridge.redhat.com>
* aoutx.h (adjust_z_magic): Do not pad the text section
if the data section is going to be placed before it.
Index: bfd/aoutx.h
===================================================================
RCS file: /cvs/src/src/bfd/aoutx.h,v
retrieving revision 1.19
diff -p -r1.19 aoutx.h
*** aoutx.h 2001/05/23 17:26:35 1.19
--- aoutx.h 2001/06/12 13:29:08
*************** adjust_z_magic (abfd, execp)
*** 1006,1015 ****
}
if (abdp && abdp->zmagic_mapped_contiguous)
{
! text_pad = (obj_datasec(abfd)->vma
! - obj_textsec(abfd)->vma
! - obj_textsec(abfd)->_raw_size);
! obj_textsec(abfd)->_raw_size += text_pad;
}
obj_datasec(abfd)->filepos = (obj_textsec(abfd)->filepos
+ obj_textsec(abfd)->_raw_size);
--- 1006,1019 ----
}
if (abdp && abdp->zmagic_mapped_contiguous)
{
! asection * text = obj_textsec (abfd);
! asection * data = obj_datasec (abfd);
!
! text_pad = data->vma - (text->vma + text->_raw_size);
! /* Only pad the text section if the data
! section is going to be placed after it. */
! if (text_pad > 0)
! text->_raw_size += text_pad;
}
obj_datasec(abfd)->filepos = (obj_textsec(abfd)->filepos
+ obj_textsec(abfd)->_raw_size);
More information about the Binutils
mailing list