Skip to content

Conversation

@lenary
Copy link
Contributor

@lenary lenary commented Aug 12, 2025

Unlike all other relaxation sequences, TLSDESC relaxations only require a R_RISCV_RELAX on their first relocation. Clarify this fact in the text.

These relaxations are designed so the sequence is not necessarily
adjacent. In this case, each of the relocations needs to be marked as
relaxable, as each instruction is separately modified/removed.

This also removes some spurious `(symbol)` annotations on
`R_RISCV_RELAX` - the relaxation relocation does not point to the same
symbol as the underlying relocation.
Copy link
Collaborator

@kito-cheng kito-cheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh...I found binutils already did that way, and I think adding R_RISCV_RELAX for each is the right way to do.

Copy link
Collaborator

@kito-cheng kito-cheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split the part of dropping symbol from R_RISCV_RELAX to a separate PR, I believe this part could be fast approved since it's apparently document fix, and for the TLSDESC part I would like moving forward after discussion within psABI meeting (although I think this should be no controversial)

@lenary
Copy link
Contributor Author

lenary commented Aug 12, 2025

Split out the document fix into #476

@MaskRay
Copy link
Collaborator

MaskRay commented Aug 23, 2025

There's no need for additional RELAX relocations. I object to such a change.

The R_RISCV_TLSDESC_HI20, R_RISCV_TLSDESC_LOAD_LO12, R_RISCV_TLSDESC_ADD_LO12, and R_RISCV_TLSDESC_CALL relocations form a compact, finite state machine, where each relocation follows the previous one, potentially interspersed with unrelated relocations. A new R_RISCV_TLSDESC_HI20 can only start after an R_RISCV_TLSDESC_CALL has been processed. The optional R_RISCV_RELAX following R_RISCV_TLSDESC_HI20 determines the relaxability of the entire sequence.

It's undefined if a non-empty proper subset of instructions within the code sequence (but not the entire sequence) are relaxed.

@lenary
Copy link
Contributor Author

lenary commented Aug 23, 2025

I'm not in favour of having a completely different relaxation scheme for one set of relocations. All other relaxations in the ABI have all relocations marked with relax.

I wouldn't mind a rule that says if one of the four has a relax relocation, they all must, but I don't like the "look at something else to find out if this is relaxable".

@kito-cheng
Copy link
Collaborator

For TLS relocations it’s indeed a bit special, unlike other reloc relaxations, they’ll still get relaxed even if linker relaxation is turned off. But I still prefer tagging any instructions that might be changed or removed with R_RISCV_RELAX to keep the design consistent.

Copy link
Collaborator

@kito-cheng kito-cheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Give my explicit LGTM here

@kito-cheng
Copy link
Collaborator

Oh, I did some digging and found that there was originally an R_RISCV_RELAX, but it was eventually removed with the agreement of the original TLSDESC proposers (@ishitatsuyuki and @rui314), and I also agreed with the proposal at that time...

#421

@lenary
Copy link
Contributor Author

lenary commented Oct 9, 2025

Ok, I see. We need to write down that this works differently, rather than having it implicit in an example. I will update this PR.

@lenary lenary changed the title TLSDESC Relocs Each Require a RELAX TLSDESC Relax Relocation Clarification Oct 9, 2025
@kito-cheng kito-cheng merged commit 104b7dc into riscv-non-isa:master Oct 13, 2025
5 checks passed
@lenary lenary deleted the pr/tlsdesc-relax branch October 14, 2025 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants