Fix a potentially undefined right shift by replacing it with two smaller right shifts.
PR binutils/17765 * elflink.c (put_value): Avoid using an undefined shift operation.
This commit is contained in:
parent
4fd77a3d12
commit
41cd1ad1b9
|
@ -1,3 +1,9 @@
|
||||||
|
2015-03-05 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
PR binutils/17765
|
||||||
|
* elflink.c (put_value): Avoid using an undefined shift
|
||||||
|
operation.
|
||||||
|
|
||||||
2015-03-05 H.J. Lu <hongjiu.lu@intel.com>
|
2015-03-05 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
PR ld/pr15228
|
PR ld/pr15228
|
||||||
|
|
|
@ -7793,28 +7793,32 @@ put_value (bfd_vma size,
|
||||||
{
|
{
|
||||||
location += (size - chunksz);
|
location += (size - chunksz);
|
||||||
|
|
||||||
for (; size; size -= chunksz, location -= chunksz, x >>= (chunksz * 8))
|
for (; size; size -= chunksz, location -= chunksz)
|
||||||
{
|
{
|
||||||
switch (chunksz)
|
switch (chunksz)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case 0:
|
|
||||||
abort ();
|
|
||||||
case 1:
|
case 1:
|
||||||
bfd_put_8 (input_bfd, x, location);
|
bfd_put_8 (input_bfd, x, location);
|
||||||
|
x >>= 8;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
bfd_put_16 (input_bfd, x, location);
|
bfd_put_16 (input_bfd, x, location);
|
||||||
|
x >>= 16;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
bfd_put_32 (input_bfd, x, location);
|
bfd_put_32 (input_bfd, x, location);
|
||||||
|
x >>= 32;
|
||||||
break;
|
break;
|
||||||
case 8:
|
|
||||||
#ifdef BFD64
|
#ifdef BFD64
|
||||||
|
case 8:
|
||||||
bfd_put_64 (input_bfd, x, location);
|
bfd_put_64 (input_bfd, x, location);
|
||||||
#else
|
/* Computed this way because x >>= 64 is undefined if x is a 64-bit value. */
|
||||||
abort ();
|
x >>= 32;
|
||||||
|
x >>= 32;
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
default:
|
||||||
|
abort ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue