Skip to content

Commit

Permalink
RISC-V/gas: Clarify the definition of `relaxable' in md_apply_fix
Browse files Browse the repository at this point in the history
The `relaxable' in md_apply_fix means if the relocation can be relaxed or not
in link-time generally.  We can use `.option relax/norelax' to enable/disable
relaxations for some specific areas, so the value of `riscv_opts.relax'
will be changed dynamically.  The `fixP->fx_tcbit' records the correct value
of `riscv_opts.relax' for every relocation.  Therefore, set `relaxable' to
`riscv_opts.relax' will cause unexpected behavior for the following case,

.option norelax
lla a1, foo1
.option relax
lla a2, foo2
.option norelax
lla a3, foo3

For the current assembler, the final value of `riscv_opts.relax' is false, so
the second `lla a2, foo2' won't have R_RISCV_RELAX relocation, but should have.

gas/
	* config/tc-riscv.c (md_apply_fix): Set the value of `relaxable' to
	`riscv_opts.relax' is wrong.  It should be `true' generally.
  • Loading branch information
Nelson Chu authored and ouuleilei-bot committed Dec 13, 2023
1 parent 324998b commit 5573b6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gas/config/tc-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -4028,7 +4028,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
case BFD_RELOC_RISCV_PCREL_HI20:
case BFD_RELOC_RISCV_PCREL_LO12_S:
case BFD_RELOC_RISCV_PCREL_LO12_I:
relaxable = riscv_opts.relax;
relaxable = true;
break;

case BFD_RELOC_RISCV_ALIGN:
Expand Down

0 comments on commit 5573b6a

Please sign in to comment.