2024-08-02 11:15 AM
I've seen other posts to resolve the compiler warning of "elf has a LOAD segment with RWX permissions", but I'm receiving this warning only when calling functions in RAM using the .RamFunc segment attribute.
From the map file I've verified the function is being loaded into RAM. I could disable the warning, but would like to understand the underlying issue.
I'm working with the latest STMCubeIDE version 1.16.0, but also saw this in 1.15.0. I'm building code for the STM3H735 and STM32H745 families.
2024-08-02 11:27 AM
Issue is probably write + execute. Typically you don't have write permission to sections where you are executing code. Code should be static.
Try the READONLY attribute.
ld - GNU Linker: ELF has a LOAD segment with RWX permissions. Embedded ARM project - Stack Overflow
2024-08-02 12:16 PM
The .ld files shipped with CubeIDE have the "w" attribute for the internal flash. (For 'historic reasons' ?)
Actually the flash can be declared as "rx" because it is not writable from the linker POV. The linker does not care about runtime behavior, it is not aware of MPU and so on. So it's up to the developers how they get rid of this warning.
2024-08-02 01:43 PM
TDK,
Admittedly I'm relatively new to the GCC realm, and I appreciate the support.
The examples from the link you provided are referring to functions in flash, and my linker file already has READONLY attribues for all flash sections.
I've taken my original function definition of:
__attribute__ ((section (".RamFunc"))) void SomeFunction(void)
and instead, tried:
__attribute__ ((READONLY, section (".RamFunc"))) void SomeFunction(void)
but the compiler now gives an addditional warning of 'READONLY' attribute directive ignored [-Wattributes].
Am I missing what you've recommended to eliminate this warning?
2024-08-02 02:42 PM
You should make the changes in the linker file, which is a *.ld file, generally in the top level directory of the project.
Can you attach your linker file?
2024-08-02 02:53 PM