summaryrefslogtreecommitdiff
path: root/opcodes/nds32-dis.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-16 09:35:30 +1030
committerAlan Modra <amodra@gmail.com>2019-12-16 17:33:53 +1030
commit4bdb25fe6902963ca9cf91d6b2688cf888527bf8 (patch)
treec59b543c40bf8bc2d741c3b0ed2b1a5a7397746a /opcodes/nds32-dis.c
parentcf950fd4dd4581849a445a76b57514d72074927d (diff)
downloadbinutils-gdb-4bdb25fe6902963ca9cf91d6b2688cf888527bf8.tar.gz
ubsan: nds32: left shift cannot be represented in type 'int'
Note that using 1u in N32_BIT makes all of N32_BIT, __MASK, __MF, __GF and __SEXT evaluate as unsigned int (the latter three when when their v arg is int or smaller). This would be a problem if assigning the result to a bfd_vma, long, or other type wider than an int since the __SEXT result would be zero extended to the wider type. Fortunately nds32 target code doesn't use wider types unnecessarily. include/ * opcode/nds32.h (N32_BIT): Define using 1u. (__SEXT): Use __MASK and N32_BIT. (N32_IMMS): Remove duplicate mask. opcodes/ * nds32-dis.c (print_insn16, print_insn32): Remove forward decls. (struct objdump_disasm_info): Delete. (nds32_parse_audio_ext, nds32_parse_opcode): Cast result of N32_IMMS to unsigned before shifting left.
Diffstat (limited to 'opcodes/nds32-dis.c')
-rw-r--r--opcodes/nds32-dis.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/opcodes/nds32-dis.c b/opcodes/nds32-dis.c
index dfd05cbe459..0e41399ef05 100644
--- a/opcodes/nds32-dis.c
+++ b/opcodes/nds32-dis.c
@@ -72,10 +72,7 @@ extern struct nds32_opcode nds32_opcodes[];
extern const field_t operand_fields[];
extern keyword_t *keywords[];
extern const keyword_t keyword_gpr[];
-static void print_insn16 (bfd_vma pc, disassemble_info *info,
- uint32_t insn, uint32_t parse_mode);
-static void print_insn32 (bfd_vma pc, disassemble_info *info, uint32_t insn,
- uint32_t parse_mode);
+
static uint32_t nds32_mask_opcode (uint32_t);
static void nds32_special_opcode (uint32_t, struct nds32_opcode **);
static int get_mapping_symbol_type (struct disassemble_info *, int,
@@ -83,18 +80,6 @@ static int get_mapping_symbol_type (struct disassemble_info *, int,
static int is_mapping_symbol (struct disassemble_info *, int,
enum map_type *);
-/* define in objdump.c. */
-struct objdump_disasm_info
-{
- bfd * abfd;
- asection * sec;
- bfd_boolean require_sec;
- arelent ** dynrelbuf;
- long dynrelcount;
- disassembler_ftype disassemble_fn;
- arelent * reloc;
-};
-
/* Hash function for disassemble. */
static htab_t opcode_htab;
@@ -128,8 +113,8 @@ nds32_parse_audio_ext (const field_t *pfd,
if (pfd->hw_res == HW_INT || pfd->hw_res == HW_UINT)
{
if (pfd->hw_res == HW_INT)
- int_value =
- N32_IMMS ((insn >> pfd->bitpos), pfd->bitsize) << pfd->shift;
+ int_value = (unsigned) N32_IMMS (insn >> pfd->bitpos,
+ pfd->bitsize) << pfd->shift;
else
int_value = __GF (insn, pfd->bitpos, pfd->bitsize) << pfd->shift;
@@ -321,9 +306,9 @@ nds32_parse_opcode (struct nds32_opcode *opc, bfd_vma pc ATTRIBUTE_UNUSED,
else if ((pfd->hw_res == HW_INT) || (pfd->hw_res == HW_UINT))
{
if (pfd->hw_res == HW_INT)
- int_value =
- N32_IMMS ((insn >> pfd->bitpos),
- pfd->bitsize) << pfd->shift;
+ int_value
+ = (unsigned) N32_IMMS (insn >> pfd->bitpos,
+ pfd->bitsize) << pfd->shift;
else
int_value =
__GF (insn, pfd->bitpos, pfd->bitsize) << pfd->shift;
@@ -411,8 +396,8 @@ nds32_parse_opcode (struct nds32_opcode *opc, bfd_vma pc ATTRIBUTE_UNUSED,
else if ((pfd->hw_res == HW_INT) || (pfd->hw_res == HW_UINT))
{
if (pfd->hw_res == HW_INT)
- int_value =
- N32_IMMS ((insn >> pfd->bitpos), pfd->bitsize) << pfd->shift;
+ int_value = (unsigned) N32_IMMS (insn >> pfd->bitpos,
+ pfd->bitsize) << pfd->shift;
else
int_value =
__GF (insn, pfd->bitpos, pfd->bitsize) << pfd->shift;