aboutsummaryrefslogtreecommitdiff
path: root/gas/config
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2020-09-24 15:08:52 -0700
committerJim Wilson <jimw@sifive.com>2020-09-24 15:16:54 -0700
commit743f5cfc006375655a20f255d25f6b8e1452b30b (patch)
tree52077e2ffb5526aaa4b3831554c98a69797309b1 /gas/config
parentdebd1a62c4d250a6257e9018d9f9c7355edcdf8b (diff)
downloadgdb-743f5cfc006375655a20f255d25f6b8e1452b30b.zip
gdb-743f5cfc006375655a20f255d25f6b8e1452b30b.tar.gz
gdb-743f5cfc006375655a20f255d25f6b8e1452b30b.tar.bz2
RISC-V: Error for relaxable branch in absolute section.
Emit an error instead of crashing in frag_new, handling this same as the i386 port. gas/ PR 26400 * config/tc-riscv.c (append_insn): If in absolute section, emit error before add_relaxed_insn call. * testsuite/gas/riscv/absolute-sec.d: New. * testsuite/gas/riscv/absolute-sec.l: New. * testsuite/gas/riscv/absolute-sec.s: New.
Diffstat (limited to 'gas/config')
-rw-r--r--gas/config/tc-riscv.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index eb31e42..7c22843 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -1106,6 +1106,13 @@ append_insn (struct riscv_cl_insn *ip, expressionS *address_expr,
int j = reloc_type == BFD_RELOC_RISCV_JMP;
int best_case = riscv_insn_length (ip->insn_opcode);
unsigned worst_case = relaxed_branch_length (NULL, NULL, 0);
+
+ if (now_seg == absolute_section)
+ {
+ as_bad (_("relaxable branches not supported in absolute section"));
+ return;
+ }
+
add_relaxed_insn (ip, worst_case, best_case,
RELAX_BRANCH_ENCODE (j, best_case == 2, worst_case),
address_expr->X_add_symbol,