1999-09-11 Donn Terry <donn@interix.com>
* peicode.h (coff_swap_scnhdr_in): If COFF_IMAGE_WITH_PE, the get the overflow of the s_nlnno field from the s_nreloc field. * peigen.c (_bfd_pei_swap_scnhdr_out): If doing a final link, swap the s_nlnno overflow of the .text section into the s_nreloc field.
This commit is contained in:
parent
5933bdc9a1
commit
cb43721da5
3 changed files with 60 additions and 19 deletions
|
@ -7,6 +7,12 @@
|
||||||
|
|
||||||
1999-09-11 Donn Terry <donn@interix.com>
|
1999-09-11 Donn Terry <donn@interix.com>
|
||||||
|
|
||||||
|
* peicode.h (coff_swap_scnhdr_in): If COFF_IMAGE_WITH_PE, the
|
||||||
|
get the overflow of the s_nlnno field from the s_nreloc field.
|
||||||
|
* peigen.c (_bfd_pei_swap_scnhdr_out): If doing a final link, swap
|
||||||
|
the s_nlnno overflow of the .text section into the s_nreloc
|
||||||
|
field.
|
||||||
|
|
||||||
* peigen.c (add_data_entry): Declare.
|
* peigen.c (add_data_entry): Declare.
|
||||||
(pei_swap_aouthdr_out): Get image size right. Set linker version
|
(pei_swap_aouthdr_out): Get image size right. Set linker version
|
||||||
more intuitively.
|
more intuitively.
|
||||||
|
|
|
@ -215,8 +215,20 @@ coff_swap_scnhdr_in (abfd, ext, in)
|
||||||
GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
|
GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
|
||||||
scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
|
scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
|
||||||
|
|
||||||
scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
|
/* MS handles overflow of line numbers by carrying into the reloc
|
||||||
scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
|
field (it appears). Since it's supposed to be zero for PE
|
||||||
|
*IMAGE* format, that's safe. This is still a bit iffy. */
|
||||||
|
#ifdef COFF_IMAGE_WITH_PE
|
||||||
|
scnhdr_int->s_nlnno =
|
||||||
|
(bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nlnno)
|
||||||
|
+ (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nreloc) << 16));
|
||||||
|
scnhdr_int->s_nreloc = 0;
|
||||||
|
#else
|
||||||
|
scnhdr_int->s_nreloc = bfd_h_get_16 (abfd,
|
||||||
|
(bfd_byte *) scnhdr_ext->s_nreloc);
|
||||||
|
scnhdr_int->s_nlnno = bfd_h_get_16 (abfd,
|
||||||
|
(bfd_byte *) scnhdr_ext->s_nlnno);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (scnhdr_int->s_vaddr != 0)
|
if (scnhdr_int->s_vaddr != 0)
|
||||||
{
|
{
|
||||||
|
|
27
bfd/peigen.c
27
bfd/peigen.c
|
@ -958,8 +958,29 @@ _bfd_pei_swap_scnhdr_out (abfd, in, out)
|
||||||
bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
|
bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (coff_data (abfd)->link_info
|
||||||
|
&& ! coff_data (abfd)->link_info->relocateable
|
||||||
|
&& ! coff_data (abfd)->link_info->shared
|
||||||
|
&& strcmp (scnhdr_int->s_name, ".text") == 0)
|
||||||
|
{
|
||||||
|
/* By inference from looking at MS output, the 32 bit field
|
||||||
|
which is the combintion of the number_of_relocs and
|
||||||
|
number_of_linenos is used for the line number count in
|
||||||
|
executables. A 16-bit field won't do for cc1. The MS
|
||||||
|
document says that the number of relocs is zero for
|
||||||
|
executables, but the 17-th bit has been observed to be there.
|
||||||
|
Overflow is not an issue: a 4G-line program will overflow a
|
||||||
|
bunch of other fields long before this! */
|
||||||
|
bfd_h_put_16 (abfd, scnhdr_int->s_nlnno & 0xffff,
|
||||||
|
(bfd_byte *) scnhdr_ext->s_nlnno);
|
||||||
|
bfd_h_put_16 (abfd, scnhdr_int->s_nlnno >> 16,
|
||||||
|
(bfd_byte *) scnhdr_ext->s_nreloc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (scnhdr_int->s_nlnno <= 0xffff)
|
if (scnhdr_int->s_nlnno <= 0xffff)
|
||||||
bfd_h_put_16(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
|
bfd_h_put_16 (abfd, scnhdr_int->s_nlnno,
|
||||||
|
(bfd_byte *) scnhdr_ext->s_nlnno);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
|
(*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
|
||||||
|
@ -970,7 +991,8 @@ _bfd_pei_swap_scnhdr_out (abfd, in, out)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
if (scnhdr_int->s_nreloc <= 0xffff)
|
if (scnhdr_int->s_nreloc <= 0xffff)
|
||||||
bfd_h_put_16(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
|
bfd_h_put_16 (abfd, scnhdr_int->s_nreloc,
|
||||||
|
(bfd_byte *) scnhdr_ext->s_nreloc);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*_bfd_error_handler) (_("%s: reloc overflow: 0x%lx > 0xffff"),
|
(*_bfd_error_handler) (_("%s: reloc overflow: 0x%lx > 0xffff"),
|
||||||
|
@ -980,6 +1002,7 @@ _bfd_pei_swap_scnhdr_out (abfd, in, out)
|
||||||
bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
|
bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue