[PATCH, libiberty] Fix segfault in floatformat.c:get_field on 64-bit hosts

Julian Brown julian@codesourcery.com
Fri Jun 9 16:58:00 GMT 2006


Hi,

This patch fixes a problem with floatformat.c:get_field on 64-bit (on at 
least x86_64), when cross-assembling to arm-none-eabi. The line which reads:

   result = *(data + cur_byte) >> (-cur_bitshift);

was executed with cur_byte = -1 (start + len == 0 and order == 
floatformat_little), which happily segfaulted (during printing of FP 
immediates).

I had a little trouble following the logic of the function, so this is 
basically a rewrite. I hope that's OK.

Tested with cross (binutils) to arm-none-eabi from 
powerpc64-unknown-linux-gnu (i.e. big-endian) and 
x86_64-unknown-linux-gnu (i.e. little-endian). OK to apply?

Cheers,

Julian

ChangeLog:

     * floatformat.c (get_field): Fix segfault with little-endian word
     order on 64-bit hosts.
     (min): Move definition.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: libiberty-getfield-2
URL: <https://sourceware.org/pipermail/binutils/attachments/20060609/d8aa71d6/attachment.ksh>


More information about the Binutils mailing list