https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103698

Matthijs Kooijman <matthijs at stdin dot nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matthijs at stdin dot nl

--- Comment #4 from Matthijs Kooijman <matthijs at stdin dot nl> ---
I also ran into this problem, with an STM32 codebase that uses libopencm3 (for
peripheral code and the linker script) and uses section(".data") to put a bit
of code in RAM (to prevent flash reads while programming flash).

To fix this problem in my code, I switched from section(".data") to
section(".ramtext"), which is second section that is also put into RAM and
seems intended especially for this purpose. This works with the libopencm3
linker script, which defines this section, YMMV with other linker scripts. E.g.
from
https://github.com/libopencm3/libopencm3/blob/189017b25cebfc609a6c1a5a02047691ef845b1b/ld/linker.ld.S#L136:

        .data : {
                _data = .;
                *(.data*)       /* Read-write initialized data */
                *(.ramtext*)    /* "text" functions to run in ram */
                . = ALIGN(4);
                _edata = .;
        } >ram AT >rom


>From looking at the linker script, it seems that .data and .ramtext are treated
pretty much in the same way, so I suspect that there is something else (maybe
some builtin rules in gcc/ld/as) that make the data section special in a way
that it causes this problem to be triggered.

Hopefully this is helpful for anyone else running into this same problem.

Reply via email to