Skip to content

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Jul 14, 2025

The function Delta(S) returns the current binary's load bias (for the null symbol as well as for locally-defined S), and is only used in the definition of RELATIVE family relocations, which are not expected to have a non-null symbol operand.

Theoretically, a non-null symbol operand could be used to refer to a symbol in another binary, which would then cause Delta(S) to evaluate to the load bias of that binary. But I am unaware of any dynamic loader implementing this (checked glibc/musl/bionic/FreeBSD/NetBSD/OpenBSD), and its utility seems limited.

The description of R__RELATIVE appears to contemplate a different case in which different segments in the same binary have different load biases. It is unclear to me how this would work in practice. If the idea is to accommodate individual segments being loaded at independent addresses, I don't think this would be enough; ELF is not generally designed to accommodate this so numerous other changes to relocation processing would need to be made in order for this to work.

Therefore, simplify the definition of Delta as well as the users, and bring it in line with existing practice, by removing the argument and having it always produce the current binary's load bias, and adjust the R__RELATIVE description to match.

The function Delta(S) returns the current binary's load bias (for the
null symbol as well as for locally-defined S), and is only used in the
definition of RELATIVE family relocations, which are not expected to
have a non-null symbol operand.

Theoretically, a non-null symbol operand could be used to refer to a
symbol in another binary, which would then cause Delta(S) to evaluate
to the load bias of that binary. But I am unaware of any dynamic loader
implementing this (checked glibc/musl/bionic/FreeBSD/NetBSD/OpenBSD),
and its utility seems limited.

The description of R_<CLS>_RELATIVE appears to contemplate a different
case in which different segments in the same binary have different load
biases. It is unclear to me how this would work in practice. If the
idea is to accommodate individual segments being loaded at independent
addresses, I don't think this would be enough; ELF is not generally
designed to accommodate this so numerous other changes to relocation
processing would need to be made in order for this to work.

Therefore, simplify the definition of Delta as well as the users, and
bring it in line with existing practice, by removing the argument and
having it always produce the current binary's load bias, and adjust the
R_<CLS>_RELATIVE description to match.
@smithp35
Copy link
Contributor

I expect that the symbol relative case is a transplant from the 32-bit ABI, in particular the BPABI https://github.com/ARM-software/abi-aa/blob/main/bpabi32/bpabi32.rst

There was a pseudo ELF target for Symbian DLLs (Symbian had an ELF to E32 conversion tool) and the SBREL position independent which was defined for an OS that did not have a MMU, although I don't think that this got used.

In open-source and open-source linkers, particularly for the sysvabi64 then I think the simplification can be made. I'd like to check to see if I can find any information on proprietary toolchains that may have built of the ABI before taking things out.

An alternative could be to find a way of preserving the original content, but moving it out of line, perhaps to an appendix.

@pcc
Copy link
Contributor Author

pcc commented Jul 16, 2025

Interesting. I had thought that this might have had something to do with a no-MMU mode inherited from 32-bit.

Another possibility could be to say that the behavior is unspecified if S is non-null. But I would prefer to just remove it if we can't easily find any evidence of proprietary toolchains implementing it. We can always make another change if we later discover a toolchain implementing it.

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.

2 participants