diff options
author | Jim Wilson <jimw@sifive.com> | 2019-05-30 15:23:10 -0700 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2019-05-30 15:23:10 -0700 |
commit | 4288405d5ec2c68c7e9d8d68a090c6c9ff3825d1 (patch) | |
tree | 06921438e37620645355d10a780474480f4b59ce /gas/config/tc-riscv.c | |
parent | bfcdb85206cd3c3b8ad73b13db6bfb2ec608239b (diff) | |
download | gdb-4288405d5ec2c68c7e9d8d68a090c6c9ff3825d1.zip gdb-4288405d5ec2c68c7e9d8d68a090c6c9ff3825d1.tar.gz gdb-4288405d5ec2c68c7e9d8d68a090c6c9ff3825d1.tar.bz2 |
RISC-V: Fix lui argument parsing.
This fixes a bug reported on the riscv.org sw-dev mailing list. This
rejects "lui x1,symbol", as a symbol should only be accepted here when
used inside %hi(). Without the fix, this gets assembled as "lui x1,0"
with no relocation which is clearly wrong.
gas/
* config/tc-riscv.c (riscv_ip) <'u'>: Move O_constant check inside if
statement. Delete O_symbol and O_constant check after if statement.
* testsuite/gas/riscv/auipc-parsing.s: Test lui with missing %hi.
* testsuite/gas/riscv/auipc-parsing.l: Update.
Diffstat (limited to 'gas/config/tc-riscv.c')
-rw-r--r-- | gas/config/tc-riscv.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 99b007f..f0c1f4c 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -1952,9 +1952,11 @@ branch: case 'u': /* Upper 20 bits. */ p = percent_op_utype; - if (!my_getSmallExpression (imm_expr, imm_reloc, s, p) - && imm_expr->X_op == O_constant) + if (!my_getSmallExpression (imm_expr, imm_reloc, s, p)) { + if (imm_expr->X_op != O_constant) + break; + if (imm_expr->X_add_number < 0 || imm_expr->X_add_number >= (signed)RISCV_BIGIMM_REACH) as_bad (_("lui expression not in range 0..1048575")); @@ -1962,9 +1964,6 @@ branch: *imm_reloc = BFD_RELOC_RISCV_HI20; imm_expr->X_add_number <<= RISCV_IMM_BITS; } - /* The 'u' format specifier must be a symbol or a constant. */ - if (imm_expr->X_op != O_symbol && imm_expr->X_op != O_constant) - break; s = expr_end; continue; |