public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [committed] RISC-V/gas: Clarify the definition of `relaxable' in md_apply_fix
@ 2023-12-11  3:33 Nelson Chu
  0 siblings, 0 replies; only message in thread
From: Nelson Chu @ 2023-12-11  3:33 UTC (permalink / raw)
  To: binutils; +Cc: Nelson Chu

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.
---
 gas/config/tc-riscv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 9365b876ed5..d3b6543413e 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -4283,7 +4283,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:
-- 
2.39.3 (Apple Git-145)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-11  3:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11  3:33 [committed] RISC-V/gas: Clarify the definition of `relaxable' in md_apply_fix Nelson Chu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).