mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-28 12:33:36 +08:00
PR26495 UBSAN: tc-score.c, tc-score7.c left shift of negative value
PR 26495 * config/tc-score.c (s3_apply_fix): Use unsigned variables. * config/tc-score7.c (s7_apply_fix): Likewise.
This commit is contained in:
parent
51bf29b1f7
commit
548c8b2ba7
@ -1,3 +1,9 @@
|
||||
2020-08-31 Alan Modra <amodra@gmail.com>
|
||||
|
||||
PR 26495
|
||||
* config/tc-score.c (s3_apply_fix): Use unsigned variables.
|
||||
* config/tc-score7.c (s7_apply_fix): Likewise.
|
||||
|
||||
2020-08-31 Alan Modra <amodra@gmail.com>
|
||||
|
||||
PR 26480
|
||||
|
@ -7065,10 +7065,10 @@ s3_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
|
||||
static void
|
||||
s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
{
|
||||
offsetT value = *valP;
|
||||
offsetT newval;
|
||||
offsetT content;
|
||||
unsigned short HI, LO;
|
||||
valueT value = *valP;
|
||||
valueT newval;
|
||||
valueT content;
|
||||
valueT HI, LO;
|
||||
|
||||
char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
|
||||
|
||||
@ -7099,7 +7099,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
if (fixP->fx_done) /* For la rd, imm32. */
|
||||
{
|
||||
newval = s3_md_chars_to_number (buf, s3_INSN_SIZE);
|
||||
HI = (value) >> 16; /* mul to 2, then take the hi 16 bit. */
|
||||
HI = value >> 16; /* mul to 2, then take the hi 16 bit. */
|
||||
newval |= (HI & 0x3fff) << 1;
|
||||
newval |= ((HI >> 14) & 0x3) << 16;
|
||||
s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
|
||||
@ -7109,7 +7109,7 @@ s3_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
if (fixP->fx_done) /* For la rd, imm32. */
|
||||
{
|
||||
newval = s3_md_chars_to_number (buf, s3_INSN_SIZE);
|
||||
LO = (value) & 0xffff;
|
||||
LO = value & 0xffff;
|
||||
newval |= (LO & 0x3fff) << 1; /* 16 bit: imm -> 14 bit in lo, 2 bit in hi. */
|
||||
newval |= ((LO >> 14) & 0x3) << 16;
|
||||
s3_md_number_to_chars (buf, newval, s3_INSN_SIZE);
|
||||
|
@ -6613,11 +6613,11 @@ s7_section_align (segT segment, valueT size)
|
||||
static void
|
||||
s7_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
{
|
||||
offsetT value = *valP;
|
||||
offsetT abs_value = 0;
|
||||
offsetT newval;
|
||||
offsetT content;
|
||||
unsigned short HI, LO;
|
||||
valueT value = *valP;
|
||||
valueT abs_value = 0;
|
||||
valueT newval;
|
||||
valueT content;
|
||||
valueT HI, LO;
|
||||
|
||||
char *buf = fixP->fx_frag->fr_literal + fixP->fx_where;
|
||||
|
||||
@ -6648,7 +6648,7 @@ s7_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
if (fixP->fx_done)
|
||||
{ /* For la rd, imm32. */
|
||||
newval = s7_md_chars_to_number (buf, s7_INSN_SIZE);
|
||||
HI = (value) >> 16; /* mul to 2, then take the hi 16 bit. */
|
||||
HI = value >> 16; /* mul to 2, then take the hi 16 bit. */
|
||||
newval |= (HI & 0x3fff) << 1;
|
||||
newval |= ((HI >> 14) & 0x3) << 16;
|
||||
s7_number_to_chars (buf, newval, s7_INSN_SIZE);
|
||||
@ -6658,7 +6658,7 @@ s7_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
if (fixP->fx_done) /* For la rd, imm32. */
|
||||
{
|
||||
newval = s7_md_chars_to_number (buf, s7_INSN_SIZE);
|
||||
LO = (value) & 0xffff;
|
||||
LO = value & 0xffff;
|
||||
newval |= (LO & 0x3fff) << 1; /* 16 bit: imm -> 14 bit in lo, 2 bit in hi. */
|
||||
newval |= ((LO >> 14) & 0x3) << 16;
|
||||
s7_number_to_chars (buf, newval, s7_INSN_SIZE);
|
||||
@ -6668,7 +6668,7 @@ s7_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
{
|
||||
content = s7_md_chars_to_number (buf, s7_INSN_SIZE);
|
||||
value = fixP->fx_offset;
|
||||
if (!(value >= 0 && value <= 0x1ffffff))
|
||||
if (value > 0x1ffffff)
|
||||
{
|
||||
as_bad_where (fixP->fx_file, fixP->fx_line,
|
||||
_("j or jl truncate (0x%x) [0 ~ 2^25-1]"), (unsigned int) value);
|
||||
@ -6723,7 +6723,7 @@ s7_apply_fix (fixS *fixP, valueT *valP, segT seg)
|
||||
content = s7_md_chars_to_number (buf, s7_INSN16_SIZE);
|
||||
content &= 0xf001;
|
||||
value = fixP->fx_offset;
|
||||
if (!(value >= 0 && value <= 0xfff))
|
||||
if (value > 0xfff)
|
||||
{
|
||||
as_bad_where (fixP->fx_file, fixP->fx_line,
|
||||
_("j! or jl! truncate (0x%x) [0 ~ 2^12-1]"), (unsigned int) value);
|
||||
|
Loading…
Reference in New Issue
Block a user