__RAM_FUNC breaks when inlined by GCC LTO #16
Labels
enhancement
New feature or request
hal
HAL-LL driver-related issue or pull-request.
internal bug tracker
Issue confirmed and logged into the internal bug tracking system
When GCC inlines functions, it ignores the
section
attribute of the inlined function. (This seems to be considered a feature, not a bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31362, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78903, etc)Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h
has:This is used by
FLASH_Program_Fast
instm32g0xx_hal_flash.c
(which must run from RAM because it needs exclusive access to flash).When compiling with LTO, GCC will inline functions across different source files. That means
FLASH_Program_Fast
may be inlined into the application code that calls it, which is typically not in.RamFunc
, so the code will run from flash and will fail.I believe the best way to fix this is with
noinline
, i.e.Then the function won't be inlined and will remain in the correct section.
(With this change, I was able to successfully build my code with LTO (which significantly reduces code size) and haven't noticed any other problems.)
The text was updated successfully, but these errors were encountered: