This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Build failure after fix for pr17512 cause linking failure when cross linking libgfortran on arm-none-linux-gnueabihf


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]