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 suppport for .nvm_data section loading #467
base: master
Are you sure you want to change the base?
Conversation
…sing persistent storage
00778d5
to
6eca1f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should implement something equivalent to LedgerBlue behavior, which doesn't check for neither .text or .nvm_data section but is more generic, what do you think about it?
I agree with that and I see two options:
To do this, we would have to:
In both cases we would still need to parse the elf sections to:
But I think that we also want to mimic the BOLOS loader behavior and I have no information about that. So I am unsure if I would be able to do that currently. |
I think if there is no major reason to change, we must continue taking the elf as a input, cause this is issued in so many places...
I'm not sure to understand your point?
Again, the RAM relocation is necessary to emulate properly the behavior on device.
They are loaded on device memory, and should therefore be present on Speculos so that the emulation is correct. |
Thanks for your answers, that gave me few info on what's the loading behavior on a real device. |
In rust apps, an additional section named
.nvm_data
is created in the provided ELF. This section represents the NVM storage state which is not null by default.When it's not loaded the rust code panics because it can't find any "valid storage" (https://github.com/LedgerHQ/ledger-device-rust-sdk/blob/610a73b500730b28c0b8c1b556e089a6b102d7c6/ledger_device_sdk/src/nvm.rs#L217-L225).
This PR adds a quick fix to load this section in memory if it exists. What should really be done is loading segments instead of sections (which are used for linking) but there are still things I do not understand at the moment. We could also load the ihex file but this would require to change the way we're running speculos in every project.
To test this PR, you can use the Password Manager Rust App and try to store a new password with the app running in speculos.