-
Notifications
You must be signed in to change notification settings - Fork 110
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 an entry point when signing Arm images #163
base: develop
Are you sure you want to change the base?
Conversation
Reads the entry point and stack pointer from the vector table Assumes vector table is at 0x10000000 unless a vector_table metadata item is present
main.cpp
Outdated
std::shared_ptr<entry_point_item> entry_point = new_block.get_item<entry_point_item>(); | ||
if (entry_point == nullptr) { | ||
std::shared_ptr<vector_table_item> vtor = new_block.get_item<vector_table_item>(); | ||
uint32_t vtor_loc = 0x10000000; |
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.
should come from wherever the start of the image is; which in flash binaries is affected by roll; and would be in RAM for RAM binaries (where i guess it must be at 0x20000000 in these cases)
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.
Fixed - I've added support for adding the rolling window delta to the VTOR location, and it checks if the ELF entry point is in SRAM and reads the VTOR from there if that's the case
std::shared_ptr<entry_point_item> entry_point = new_block.get_item<entry_point_item>(); | ||
if (entry_point == nullptr) { | ||
std::shared_ptr<vector_table_item> vtor = new_block.get_item<vector_table_item>(); | ||
uint32_t vtor_loc = elf->header().entry < SRAM_START ? 0x10000000 : 0x20000000; |
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.
do we need to check for XIP_SRAM-only binaries here? I forget if they can be signed (i believe so)
@@ -4630,6 +4658,27 @@ vector<uint8_t> sign_guts_bin(iostream_memory_access in, private_t private_key, | |||
new_block.items.push_back(version); | |||
} | |||
|
|||
// Add entry point when signing Arm images |
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.
Hmm; i hadn't really considered the BIN case where we don't know where the user is planning to load it. Perhaps we don't do all this and just give a warning instead? (or allow a "target address" option) - i'd be happy with the former for now, we can always add the new option later if it is useful
new_block.items.push_back(entry_point); | ||
} | ||
} | ||
|
||
hash_andor_sign( |
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.
Reads the entry point and stack pointer from the vector table, and adds them to the image_def as a new entry_point item. This is only done for signing Arm executable images.
This assumes that the vector table is at 0x10000000 unless a vector_table metadata item is present, which the SDK adds for no_flash binaries, so it should work with all SDK binaries.