-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for relocations #39
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hmm… looking at this code, I am now inclined to re-read Stephen Kell's The Missing Link, much more carefully this time. |
janvrany
force-pushed
the
pr/add-relocations
branch
2 times, most recently
from
June 24, 2024 11:42
88229db
to
282fbd9
Compare
janvrany
force-pushed
the
pr/add-relocations
branch
from
June 27, 2024 10:48
282fbd9
to
c857bd7
Compare
janvrany
force-pushed
the
pr/add-relocations
branch
from
August 5, 2024 12:32
c857bd7
to
97f5adb
Compare
This commit add `AcDSLCodeObject >> exports` that return symbols "exported" by this code object, that is, a dictionary mapping exported symbol to its address (respecting object's base address). Each exported symbol must be paired with corresponding label in instructions sequence. To export a symbol, `AcDSLAssembler` provides method `global: symbol` just like GNU assembler has .global directive [1]. [1]: https://sourceware.org/binutils/docs/as/Global.html
This commit adds basic support for relocation entries. Each processor instruction can have a relocation entry. A relocation entry is a subclass of `AcRelocation` (one subclass per relocation type) and contains a (relocatable) symbol. Particular relocation type (a concrete subclass of `AcRelocation`) is valid only for some instructions (`#isValidForInstruction`) and knows how to fixup (patch) that instruction, knowing the final address of its symbol (note, that this final address might be address of trampoline or into address table if final address is beyond the maximum displacement). In some cases, relocation entries must come in pairs (like %lo must follow %hi). Currently, there's no way to ensure nor validate that - this is user's responsibility.
This commit adds relocation support to DSL assembler. To to relocate an operand, use `relocation_type % operand`, for example: asm auipc: ra, ra, R_RISCV_PCREL_HI20 % label
This commit adds pool with `*_MIN` and `*_MAX` values for fixed-length integers (both signed and unsigned). Using them rather than integer literals improve readability.
This commit adds pool containing various constants related to RISC-V ISAm such as bit-size of immediates, min / max values of those and so on to improve readability of code.
This commit add basic support for GOT accesses. During relocation processing (linking) a relocation may request GOT entry for its symbol by gotentry := AcRelocationRequestGOTEntry query: self The response (`gotentry` in the above example) is an association from GOT entry symbol to its address (that is, address of the entry). Actual allocation of GOT entries is the responsibility of the linker.
This commit add basic support for PLT calls, using similar mechanism as for GOT entries introduced in previous commit.
This commit adds `R_RISCV_GOT_HI20` relocation class and fixes `R_RISCV_PCREL_LO12_*` to also work with it. This allows consumers to generate GOT access for external symbols.
This commit add simple example showing how to use relocations when using DSL assembler.
janvrany
force-pushed
the
pr/add-relocations
branch
from
November 28, 2024 15:22
97f5adb
to
29f554f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds basic support for relocations.
At the moment, this PR is work in progress. I'm still not 100% happy with it - design wise - but this should be enough to enable further experiments with TR and AoT withing ST25.
One thing that is probably missing is to add proper support for code object sections, so compiler can for example produce jump table for PICs in "data" section or big constants or global variable addresses in "rodata".
Once finalized, this would probably need to be split into 2 or three smallter PRs.