This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Build failure after fix for pr17512 cause linking failure when cross linking libgfortran on arm-none-linux-gnueabihf
- From: Alan Modra <amodra at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>, Nicholas Clifton <nickc at redhat dot com>, Jiong Wang <jiong dot wang at arm dot com>, Binutils <binutils at sourceware dot org>
- Date: Sat, 8 Nov 2014 12:39:12 +1030
- Subject: Re: Build failure after fix for pr17512 cause linking failure when cross linking libgfortran on arm-none-linux-gnueabihf
- Authentication-results: sourceware.org; auth=none
- References: <5458AAB8 dot 7050302 at arm dot com> <5458BDBC dot 8080007 at redhat dot com> <5458DB83 dot 9010903 at arm dot com> <5458F573 dot 5030409 at redhat dot com> <5458F5FF dot 8060907 at arm dot com> <5458F87E dot 5050601 at redhat dot com> <545b39bd dot 45a4440a dot 0c80 dot 0cb5SMTPIN_ADDED_BROKEN at mx dot google dot com> <CAMe9rOq760L97x7-egNs33ZdUai33h-LBo+=--0_-c7DBHrwDA at mail dot gmail dot com>
On Fri, Nov 07, 2014 at 01:43:09PM -0800, H.J. Lu wrote:
> diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
> index 25f7273..2b63e2a 100644
> --- a/bfd/peXXigen.c
> +++ b/bfd/peXXigen.c
> @@ -1467,7 +1467,7 @@ pe_print_idata (bfd * abfd, void * vfile)
> member_high, member,
> WithoutHighBit (member_high), member);
> /* PR binutils/17512: Handle corrupt PE data. */
> - else if (member - adj + 2 >= datasize)
> + else if (member - adj + 2 >= (unsigned long) datasize)
> fprintf (file, _("\t<corrupt: 0x%04lx>"), member);
> else
> {
> @@ -1502,7 +1502,7 @@ pe_print_idata (bfd * abfd, void * vfile)
> fprintf (file, "\t%04lx\t %4lu <none>",
> member, WithoutHighBit (member));
> /* PR binutils/17512: Handle corrupt PE data. */
> - else if (member - adj + 2 >= datasize)
> + else if (member - adj + 2 >= (unsigned long) datasize)
> fprintf (file, _("\t<corrupt: 0x%04lx>"), member);
> else
> {
No, the lhs expression (of type bfd_signed_vma, aka long long int in
this case) should instead be cast to bfd_vma. You've silenced a
hint that the test wasn't properly checking for a possible buffer
overrun. Casting the rhs to unsigned long means it is then promoted
to long long for the comparison, ie. you have a signed comparison
where you want an unsigned one.
* peXXigen.c (pe_print_idata): Revert last patch, cast lhs instead.
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 2b63e2a..ea1459b 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1467,7 +1467,7 @@ pe_print_idata (bfd * abfd, void * vfile)
member_high, member,
WithoutHighBit (member_high), member);
/* PR binutils/17512: Handle corrupt PE data. */
- else if (member - adj + 2 >= (unsigned long) datasize)
+ else if ((bfd_vma) member - adj + 2 >= datasize)
fprintf (file, _("\t<corrupt: 0x%04lx>"), member);
else
{
@@ -1502,7 +1502,7 @@ pe_print_idata (bfd * abfd, void * vfile)
fprintf (file, "\t%04lx\t %4lu <none>",
member, WithoutHighBit (member));
/* PR binutils/17512: Handle corrupt PE data. */
- else if (member - adj + 2 >= (unsigned long) datasize)
+ else if ((bfd_vma) member - adj + 2 >= datasize)
fprintf (file, _("\t<corrupt: 0x%04lx>"), member);
else
{
--
Alan Modra
Australia Development Lab, IBM