-
Notifications
You must be signed in to change notification settings - Fork 109
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
[WIP] Vtable fixup and relocation #56
Closed
Closed
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
Fixing up vtables indeed fixes the format-macro. |
One can now flash copies of traitobj to the chip and vtables and in particular the format macro work |
- add format! example
Woyten
force-pushed
the
feature/fix-vtable-relocation
branch
from
September 27, 2018 11:25
cf8e26f
to
1dd23a6
Compare
torfmaster
force-pushed
the
feature/fix-vtable-relocation
branch
from
September 30, 2018 17:22
1a73954
to
ef61b1b
Compare
You will need the patched version of elf2tab at https://github.com/torfmaster/elf2tab/tree/experimental/store-vtable-location to get the relocation information. I'm working on making my changes to elf2tab minimal and configurable. |
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.
Vtable fixup and relocation
Pull request Overview
This PR is for tracking work and discussion on relocation. The changes aim to enable correct relocation of vtables in order to make dynamic dispatch on Trait objects work.
Content
Calls to methods on trait objects use vtables for dynamic dispatch. As the functions which are
called are relocated in flash also the vtables must be changed.
The vtables are stored in the rodata-segment and are accessed from flash. However,
the addresses in the vtables need fixup, still. My proposed solution is to move .rodata
to RAM.
Advantages:
&str
-s can now be shared using "allow". So we can now make calls likeconsole.write("hello")
instead ofconsole.write(String::from("hello"))
Disadvantages:
Progress:
[x] write a PoC (dynamic dispatch now works)
[ ] improve the linker script
[ ] put necessary information in the header
[ ] write a PoC to show that proportionally aligned apps do relocation right
[ ] refine the vtable fixup to keep integrity of non-vtable data
[ ] solve the problem of non-proportionality of ram and flash
Not contained in this pull request
RWPI-relocation. This is propably blocked due to missing features in lld. We might give an
ad-hoc solution to construct a global drivers object in a separate PR.
Implementation
The current implementation moves the .rodata from flash to ram. It manipulates the load address
in the linker script so that (assuming proportionality) the references to elements in .rodata are still valid.
Entries in the vtable are manipulated at loading time. The data which entries to fixup is taken from the relocation section which is put into the binary by the patched version of elf2tab (see https://github.com/torfmaster/elf2tab/tree/experimental/store-vtable-location).
It assumes that elements.which need to be fixed have 0x80_00_00_00 set. This potentially destroys non-vtable data.
Currently, the rust compiler makes it hard to identify the Vtable-Symbols during link time
as recently the name of these symbols changed from Vtable* to unknown* which makes them
harder to distinguish from string literals in .rodata
In order for this procedure to work we must align two applications in flash as we do
in ram, i.e. if app 1 and app 2 occupie 1kBytes in flash respectively, then the same
should be true for their ram-segments.
Discussion
What do you think about apps beeing forced to be proptionally aligned?