From 67d74347a3201f032a77c39e23f9a98f030f2c82 Mon Sep 17 00:00:00 2001 From: William Vinnicombe Date: Tue, 19 Nov 2024 16:52:50 +0000 Subject: [PATCH] Get vtor from 0x20000000 for SRAM binaries, and use rwd where present --- main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 69e160f..6185400 100644 --- a/main.cpp +++ b/main.cpp @@ -4613,9 +4613,14 @@ void sign_guts_elf(elf_file* elf, private_t private_key, public_t public_key) { std::shared_ptr entry_point = new_block.get_item(); if (entry_point == nullptr) { std::shared_ptr vtor = new_block.get_item(); - uint32_t vtor_loc = 0x10000000; + uint32_t vtor_loc = elf->header().entry < SRAM_START ? 0x10000000 : 0x20000000; if (vtor != nullptr) { vtor_loc = vtor->addr; + } else { + std::shared_ptr rwd = new_block.get_item(); + if (rwd != nullptr) { + vtor_loc += rwd->addr; + } } auto segment = elf->segment_from_physical_address(vtor_loc); auto content = elf->content(*segment);