diff options
author | Nick Clifton <nickc@redhat.com> | 2015-03-05 17:26:10 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2015-03-05 17:26:10 +0000 |
commit | 41cd1ad1b9760ba962fde607ac218b5af760dfbf (patch) | |
tree | fcba3b15af2bf34e9a17d6158c1fa692fb57095f /bfd/elflink.c | |
parent | 4fd77a3d12291cd9351e1f776a5ade11f99a28ac (diff) | |
download | gdb-41cd1ad1b9760ba962fde607ac218b5af760dfbf.zip gdb-41cd1ad1b9760ba962fde607ac218b5af760dfbf.tar.gz gdb-41cd1ad1b9760ba962fde607ac218b5af760dfbf.tar.bz2 |
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.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index 6ee6499..b285e76 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -7793,28 +7793,32 @@ put_value (bfd_vma size, { location += (size - chunksz); - for (; size; size -= chunksz, location -= chunksz, x >>= (chunksz * 8)) + for (; size; size -= chunksz, location -= chunksz) { switch (chunksz) { - default: - case 0: - abort (); case 1: bfd_put_8 (input_bfd, x, location); + x >>= 8; break; case 2: bfd_put_16 (input_bfd, x, location); + x >>= 16; break; case 4: bfd_put_32 (input_bfd, x, location); + x >>= 32; break; - case 8: #ifdef BFD64 + case 8: bfd_put_64 (input_bfd, x, location); -#else - abort (); + /* Computed this way because x >>= 64 is undefined if x is a 64-bit value. */ + x >>= 32; + x >>= 32; + break; #endif + default: + abort (); break; } } |