On powerpc, a const variable may end up in the .sdata section, which is writable. This means authors cannot depend on the "const" marking to mean "read-only", as is required for sane Linux kernel memory protection security.
At the very least, there should be a way to request never putting a const variable into a writable section.
Actually it is just undefined what happens when a write to a const variable.
So a trap or the write happened for a const both are valid thing.
Now const really should be put in the read only section if possible.
Putting it in the sdata section is valid thing to do but I doubt some people want it there.
Powerpc should have an option which disabled this optimization for const variables.
Right now there is a way to disable all of sdata by -G0 option which is a good workaround.
To access this as sdata is faster and smaller than as rodata (one
instruction instead of two).
You can use -G0 as Andrew says, or -mno-sdata (or -msdata=none).
To clarify, using -mno-sdata means all things are removed from sdata, not just const, yes? I'd like to be able to leave writable stuff there, to avoid any additional performance penalty.
That what it means yes. You can use it as a workaround.
There is no option yet to put only writable data in sdata.