aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-nios2.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-12 09:29:45 +1030
committerAlan Modra <amodra@gmail.com>2019-12-12 21:58:33 +1030
commit4f7cc14110d67a180f5408a91ac53a91f88f776e (patch)
tree06f9b92f65556383e9d7cad287ce1b51882c7243 /gas/config/tc-nios2.c
parent84bc4ba8168154fae0da7d56dcd11df0d4bc44f2 (diff)
downloadgdb-4f7cc14110d67a180f5408a91ac53a91f88f776e.zip
gdb-4f7cc14110d67a180f5408a91ac53a91f88f776e.tar.gz
gdb-4f7cc14110d67a180f5408a91ac53a91f88f776e.tar.bz2
gas signed overflow fixes
* config/tc-aarch64.c (get_aarch64_insn): Avoid signed overflow. * config/tc-metag.c (parse_dalu): Likewise. * config/tc-tic4x.c (md_pcrel_from): Likewise. * config/tc-tic6x.c (tic6x_output_unwinding): Likewise. * config/tc-csky.c (parse_fexp): Use an unsigned char temp buffer. Don't use register keyword. Avoid signed overflow and remove now unneccesary char masks. Formatting. * config/tc-ia64.c (operand_match): Don't use shifts to sign extend. * config/tc-mep.c (mep_apply_fix): Likewise. * config/tc-pru.c (md_apply_fix): Likewise. * config/tc-riscv.c (load_const): Likewise. * config/tc-nios2.c (md_apply_fix): Likewise. Don't potentially truncate fixup before right shift. Tidy BFD_RELOC_NIOS2_HIADJ16 calculation.
Diffstat (limited to 'gas/config/tc-nios2.c')
-rw-r--r--gas/config/tc-nios2.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index ec572a6..f1a0200 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -1384,7 +1384,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
nios2_diagnose_overflow (fixup, howto, fixP, value);
/* Apply the right shift. */
- fixup = ((signed)fixup) >> howto->rightshift;
+ fixup = (offsetT) fixup >> howto->rightshift;
/* Truncate the fixup to right size. */
switch (fixP->fx_r_type)
@@ -1396,13 +1396,11 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
fixup = fixup & 0xFFFF;
break;
case BFD_RELOC_NIOS2_HIADJ16:
- fixup = ((((fixup >> 16) & 0xFFFF) + ((fixup >> 15) & 0x01))
- & 0xFFFF);
+ fixup = ((fixup + 0x8000) >> 16) & 0xFFFF;
break;
default:
{
- int n = sizeof (fixup) * 8 - howto->bitsize;
- fixup = (fixup << n) >> n;
+ fixup &= ((valueT) 1 << howto->bitsize) - 1;
break;
}
}