Skip to content
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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

will-v-pi
Copy link

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.

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
@will-v-pi will-v-pi added this to the 2.0.1 milestone Nov 1, 2024
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;
Copy link
Contributor

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)

Copy link
Author

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;
Copy link
Contributor

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
Copy link
Contributor

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot from 2024-11-19 23-27-37

😉

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.

3 participants