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);