From 13902cae7221c1158d6495181de6d407cf06c130 Mon Sep 17 00:00:00 2001 From: Yaya-Cout Date: Wed, 8 Oct 2025 15:06:48 +0200 Subject: [PATCH] [ion/platformInfo] Fix recovery boot address computation --- ion/src/device/bootloader/bootloader_common.ld | 4 +++- ion/src/device/bootloader/platform_info.cpp | 18 ++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ion/src/device/bootloader/bootloader_common.ld b/ion/src/device/bootloader/bootloader_common.ld index 18928a73f..5f2db3750 100644 --- a/ion/src/device/bootloader/bootloader_common.ld +++ b/ion/src/device/bootloader/bootloader_common.ld @@ -58,8 +58,10 @@ SECTIONS { } > FLASH .recovery_boot : { - . = ORIGIN(FLASH) + USERLAND_OFFSET + 0x80; + . = ALIGN(4); + _recovery_boot_start = .; KEEP(*(.recovery_boot)); + _recovery_boot_end = .; } >FLASH .text : { diff --git a/ion/src/device/bootloader/platform_info.cpp b/ion/src/device/bootloader/platform_info.cpp index 00d02b451..8ca190a0d 100644 --- a/ion/src/device/bootloader/platform_info.cpp +++ b/ion/src/device/bootloader/platform_info.cpp @@ -24,6 +24,8 @@ namespace Ion { extern char staticStorageArea[]; } constexpr void * storageAddress = &(Ion::staticStorageArea); +typedef void (*recoveryStartPointerType)(); +constexpr recoveryStartPointerType recoveryStartPointer = &(recovery_start); class KernelHeader { public: @@ -77,16 +79,12 @@ public: m_osType(OSType), m_upsilonMagicFooter(UpsilonMagic), m_upsilonExtraMagicHeader(UpsilonExtraMagic), - // FIXME: Since GCC 13, we can't longer store a pointer to a function in the - // class initialization. I don't know if it's a problem in GCC or our code, - // but it's a bit suspicious as the whole class is blank (0x00) in the - // binary with the data available nowhere else (searching for the username - // returns nothing). - // As a workaround, we fixed the address of recovery_start in flash using - // LD script (ion/src/device/bootloader/bootloader_common.ld). - // This line works on GCC 12 + // We need to be careful with the pointer to the recovery entrypoint as GCC + // will simply generate a blank userland header if it wasn't able to + // generate it. This code used to work on GCC 12, but is broken since GCC 13 + // probably due to the cast preventing LD to just copy the address: // m_recoveryAddress((uint32_t)recovery_start + 1), - m_recoveryAddress(0x90010080 + 1), + m_recoveryAddress(recoveryStartPointer), m_extraVersion(1), m_upsilonExtraMagicFooter(UpsilonExtraMagic) { } @@ -146,7 +144,7 @@ private: uint32_t m_osType; uint32_t m_upsilonMagicFooter; uint32_t m_upsilonExtraMagicHeader; - uint32_t m_recoveryAddress; + recoveryStartPointerType m_recoveryAddress; uint32_t m_extraVersion; uint32_t m_upsilonExtraMagicFooter; };