X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=opcodes%2Fcgen-asm.c;h=b1675045d9d1139cb850b54657796f375d05a84d;hb=423054beadf317757d43aefb9eddfe711a42e3e1;hp=6ed096b3346a9c4e7fa7bb97ae3e5e1e67d65691;hpb=9b201bb5e5daa9b4f783e6ece9cbfbdbf9f1d6f4;p=deliverable%2Fbinutils-gdb.git diff --git a/opcodes/cgen-asm.c b/opcodes/cgen-asm.c index 6ed096b334..b1675045d9 100644 --- a/opcodes/cgen-asm.c +++ b/opcodes/cgen-asm.c @@ -1,6 +1,5 @@ /* CGEN generic assembler support code. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2007 - Free Software Foundation, Inc. + Copyright (C) 1996-2020 Free Software Foundation, Inc. This file is part of libopcodes. @@ -213,7 +212,7 @@ cgen_parse_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, character of the suffix ('.') is special. */ if (*p) ++p; - + /* Allow letters, digits, and any special characters. */ while (((p - start) < (int) sizeof (buf)) && *p @@ -268,7 +267,23 @@ cgen_parse_signed_integer (CGEN_CPU_DESC cd, &result, &value); /* FIXME: Examine `result'. */ if (!errmsg) - *valuep = value; + { + /* Handle the case where a hex value is parsed on a 64-bit host. + A value like 0xffffe000 is clearly intended to be a negative + 16-bit value, but on a 64-bit host it will be parsed by gas + as 0x00000000ffffe000. + + The shifts below are designed not to produce compile time + warnings on a 32-bit host. */ + if (sizeof (value) > 4 + && result == CGEN_PARSE_OPERAND_RESULT_NUMBER + && value > 0 + && (value & 0x80000000) + && ((value >> 31) == 1)) + value |= ((bfd_vma) -1) << 31; + + *valuep = value; + } return errmsg; }