cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE 2.0.0 and LOAD segment with RWX permissions

Kraal
Lead

Hello,

I moved an existing project from 1.14 to 2.0.0. To be clear I created a new workspace, then a new project in 2.0.0 in order to prevent any non relevant bit taken from 1.14 (at the project level) and copied only the source files from 1.14 to 2.0.0. The linker file comes from 2.0.0, as well as the startup file (which is not relevant here).

When I compile I get the error that elf has LOAD segment with RWX permissions. The linker file has the READONLY moniker where they are needed, but I have 3 functions that are running from RAM, with __attribute__ ((section(".RamFunc"))). Obviously these are executables, so it is expected to have RWX in the .data section, where .RamFunc resides.

How can I get rid of this warning, please ?

Even though it is not relevant, the MCU is an STM32G0B1CB.

7 REPLIES 7
Souhaib MAZHOUD
ST Employee

Hello @Kraal 

Could you please provide your project in order to investigate the issue?

KR, Souhaib

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

eos1d3
Associate III

This is not 2.0.00 issue. Earlier version of STM32CubeIDE already had this compatibility issue. The older release note note has that information.

You can create a new Project and compare the change in .id to fix old ld file issue.

 

Hi,

I know that this is not related to CubeIDE directly, but to GCC 11 and higher. However the diff with the old linker file will not help me, I need to understand what needs to be added in the new linker file to prevent RamFunc to be seen as a warning by the linker.

Old linker file does not need READONLY as it was compiled with GCC 10.

Kraal
Lead

@Souhaib MAZHOUD You can just create a new project and add a RamFunc function. It will give the warning right away.

as @eos1d3 said, it is not a bug of the IDE per say, but I'm quite sure that I am not the only one who wants to use the latest GCC revision with functions running from RAM.

Is it possible ?

I have checked .ld files. I find that recent STM32CubeIde (I do not know started from which version) has RamFun defined for you. And old versions really do not.

I use IDE 1.9, for STM32G03F6, for example:

* Initialized data sections into "RAM" Ram type memory */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */

It is already there. What does it mean? You do not need to change your link file.

To use it, mark functions like this:

__attribute__((section(".RamFunc"))) void myFunction() {

// This function will be placed in RAM
}

I know all that.
The problem is that with newer versions of GCC, having executable code in RAM (such as RamFunc routines) raise a warning at compile time (if I understood correctly, the reason is because the code in RAM is executable but can be modified (not READONLY) which can lead to security issues).
I can ignore it for now, but I prefer to have it properly fixed (or silenced).

You need to restructure things so there’s no RWX PT_LOAD segment. That means using a PHDRS block and assigning the right flags per segment. For small Cortex-M projects this is usually overkill.

It seems no simple way to fix the warning. To suppress it, I know only 
-Wl,--no-warn-rwx-segments

Hope others can help.