diff options
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 12 | ||||
-rw-r--r-- | gas/config/tc-pru.c | 18 | ||||
-rw-r--r-- | gas/testsuite/gas/pru/illegal2.l | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/pru/illegal2.s | 5 | ||||
-rw-r--r-- | gas/testsuite/gas/pru/ldi.d | 8 | ||||
-rw-r--r-- | gas/testsuite/gas/pru/pru.exp | 1 |
6 files changed, 37 insertions, 9 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 88ab077..b44c9e3 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,15 @@ +2018-05-09 Dimitar Dimitrov <dimitar@dinux.eu> + + * config/tc-pru.c (md_apply_fix): Make LDI32 relocation conformant + to TI ABI. + (pru_assemble_arg_i): Likewise. + (output_insn_ldi32): Likewise. + * testsuite/gas/pru/ldi.d: Update test for the now fixed LDI32. + * gas/config/tc-pru.c (pru_assemble_arg_b): Check imm8 operand range. + * gas/testsuite/gas/pru/illegal2.l: New test. + * gas/testsuite/gas/pru/illegal2.s: New test. + * gas/testsuite/gas/pru/pru.exp: Register new illegal2 test. + 2018-05-08 Jim Wilson <jimw@sifive.com> * testsuite/gas/riscv/c-zero-imm.d: Add more tests. diff --git a/gas/config/tc-pru.c b/gas/config/tc-pru.c index d0f630e..5121b1f 100644 --- a/gas/config/tc-pru.c +++ b/gas/config/tc-pru.c @@ -814,8 +814,11 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) /* As the only 64-bit "insn", LDI32 needs special handling. */ uint32_t insn1 = insn & 0xffffffff; uint32_t insn2 = insn >> 32; - SET_INSN_FIELD (IMM16, insn1, fixup & 0xffff); - SET_INSN_FIELD (IMM16, insn2, fixup >> 16); + SET_INSN_FIELD (IMM16, insn1, fixup >> 16); + SET_INSN_FIELD (IMM16, insn2, fixup & 0xffff); + + SET_INSN_FIELD (RDSEL, insn1, RSEL_31_16); + SET_INSN_FIELD (RDSEL, insn2, RSEL_15_0); md_number_to_chars (buf, insn1, 4); md_number_to_chars (buf + 4, insn2, 4); @@ -1086,6 +1089,8 @@ pru_assemble_arg_b (pru_insn_infoS *insn_info, const char *argstr) if (src2 == NULL) { unsigned long imm8 = pru_assemble_noreloc_expression (argstr); + if (imm8 >= 0x100) + as_bad (_("value %lu is too large for a byte operand"), imm8); SET_INSN_FIELD (IMM8, insn_info->insn_code, imm8); SET_INSN_FIELD (IO, insn_info->insn_code, 1); } @@ -1141,7 +1146,8 @@ pru_assemble_arg_i (pru_insn_infoS *insn_info, const char *argstr) /* QUIRK: LDI must clear IO bit high, even though it has immediate arg. */ SET_INSN_FIELD (IO, insn_info->insn_code, 0); - SET_INSN_FIELD (IMM16, insn_info->insn_code, imm32 & 0xffff); + SET_INSN_FIELD (RDSEL, insn_info->insn_code, RSEL_31_16); + SET_INSN_FIELD (IMM16, insn_info->insn_code, imm32 >> 16); insn_info->ldi32_imm32 = imm32; } @@ -1475,11 +1481,13 @@ output_insn_ldi32 (pru_insn_infoS *insn) unsigned long insn2; f = frag_more (8); + SET_INSN_FIELD (IMM16, insn->insn_code, insn->ldi32_imm32 >> 16); + SET_INSN_FIELD (RDSEL, insn->insn_code, RSEL_31_16); md_number_to_chars (f, insn->insn_code, 4); insn2 = insn->insn_code; - SET_INSN_FIELD (IMM16, insn2, insn->ldi32_imm32 >> 16); - SET_INSN_FIELD (RDSEL, insn2, RSEL_31_16); + SET_INSN_FIELD (IMM16, insn2, insn->ldi32_imm32 & 0xffff); + SET_INSN_FIELD (RDSEL, insn2, RSEL_15_0); md_number_to_chars (f + 4, insn2, 4); /* Emit debug info. */ diff --git a/gas/testsuite/gas/pru/illegal2.l b/gas/testsuite/gas/pru/illegal2.l new file mode 100644 index 0000000..793eca7 --- /dev/null +++ b/gas/testsuite/gas/pru/illegal2.l @@ -0,0 +1,2 @@ +.*illegal2.s: Assembler messages: +.*illegal2.s:5: Error: value 256 is too large for a byte operand diff --git a/gas/testsuite/gas/pru/illegal2.s b/gas/testsuite/gas/pru/illegal2.s new file mode 100644 index 0000000..c37f1b2 --- /dev/null +++ b/gas/testsuite/gas/pru/illegal2.s @@ -0,0 +1,5 @@ +# Source file used to test illegal operands. + +foo: +# Out-of-bounds immediate value + add r2, r2, 256 diff --git a/gas/testsuite/gas/pru/ldi.d b/gas/testsuite/gas/pru/ldi.d index 8851504..4c2cf7a 100644 --- a/gas/testsuite/gas/pru/ldi.d +++ b/gas/testsuite/gas/pru/ldi.d @@ -6,12 +6,12 @@ .*: +file format elf32-pru Disassembly of section .text: -0+0000 <[^>]*> 240000f0 ldi r16, 0 +0+0000 <[^>]*> 240000d0 ldi r16.w2, 0 [\t ]*0: R_PRU_LDI32 \*ABS\*\+0x12345678 -0+0004 <[^>]*> 240000d0 ldi r16.w2, 0 +0+0004 <[^>]*> 24000090 ldi r16.w0, 0 0+0008 <[^>]*> 241234f0 ldi r16, 4660 0+000c <[^>]*> 240000f0 ldi r16, 0 [\t ]*c: R_PRU_U16_PMEMIMM .text -0+0010 <[^>]*> 240000f0 ldi r16, 0 +0+0010 <[^>]*> 240000d0 ldi r16.w2, 0 [\t ]*10: R_PRU_LDI32 var1 -0+0014 <[^>]*> 240000d0 ldi r16.w2, 0 +0+0014 <[^>]*> 24000090 ldi r16.w0, 0 diff --git a/gas/testsuite/gas/pru/pru.exp b/gas/testsuite/gas/pru/pru.exp index 49bdf03..cacaa2b 100644 --- a/gas/testsuite/gas/pru/pru.exp +++ b/gas/testsuite/gas/pru/pru.exp @@ -22,5 +22,6 @@ if { [istarget pru-*-*] } { run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]] run_list_test "illegal" "" + run_list_test "illegal2" "" run_list_test "warn_reglabel" "" } |