cancel
Showing results for 
Search instead for 
Did you mean: 

What if I *want* a LOAD segment with RWX permissions?

Jim Seymour
Senior

I'm getting the "elf has a LOAD segment with RWX permissions" warning, and a quick search here reveals a couple of ways to get around this: Disable the warning, or edit the .ld file.

However, in my case, I'm using the upper half of the STM32's flash area to emulate non-volatile memory.  So I want my flash to be writeable.

Can anyone suggest some magic to put in my linker file that will make the warning go away, but also allow me to write to flash?

Also: I'm using STM32CubeIDE, so my linker file is auto-generated.  Is there a user-override mechanism (like there is in the source code)?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
mfgkw
Senior III

But the part you write will probably have no code?

Then you can split the flash in two parts: rx for the code and rw for your data.

 

So if you have something like:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 2048K
}

change it to e.g.:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 1024K
  FLASHEMU (rw)    : ORIGIN = 0x8100000,   LENGTH = 1024K
}

(untested, just a proposal)

View solution in original post

3 REPLIES 3
mfgkw
Senior III

But the part you write will probably have no code?

Then you can split the flash in two parts: rx for the code and rw for your data.

 

So if you have something like:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 2048K
}

change it to e.g.:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 512K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 1024K
  FLASHEMU (rw)    : ORIGIN = 0x8100000,   LENGTH = 1024K
}

(untested, just a proposal)

Pavel A.
Super User

So I want my flash to be writeable.

From the linker POV this memory is still not-writeable, so just leave the linker file as is. No change is needed.

If you like, divide the FLASH region as @mfgkw proposed, (with r attribute) - only for convenience, to ensure that the program fits in the reduced FLASH size. 

Thanks. Now that I think this problem through, this solves an issue I was worried about: My code overflowing the first half of flash.

It doesn't solve the warning issue.  But on further research, it seems that the only way to get around that is to suppress it.  This is because I'm using the hal_flash routines - and one of them is declared with __RAM_FUNC (which puts it in the RAM segment - which is rwx).