GCC/Arm-Cortex-M3 position independant code AND data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't know where to start to contribute a small modification
(as far as I expect) of GCC -fpic option to support position
independent code and data on microcontrollers where code and
data are separately allocated into flash and ram.

I am developping radio-linked devices on STM32 microcontrollers
(with on-chip embedded ARM-Cortex-M3 + 32 Kb flash + 6 Kb ram)
using arm-none-linux-gnueabi-gcc-4.2.3 (www.codesourcery.com)
cross-compiler on GNU-Linux-Ubuntu host.

Each device program is split into separately compiled modules,
after finding that, between two software releases, only a few
modules change and have to be radio-downloaded and updated into
the device.

Each module has its code (.text and .rodata sections) in flash,
and its private static data (.data and .bss sections) in ram,
modules are only communicating by inter-module calls through
a shared call-frames stack (no shared static data).

A small (<1K) resident linker moves modules within a circular
flash buffer to remove the obsolete modules and obtain virgin
relocation entries, where it then writes, with the help of
compact link tables, the inter-module branch instructions used
for inter-module calls, and the ram statics-base pointer for
each module.

The arm-gcc current -fpic option generates pc-relative addressing
for jumps, calls, and constant pools, and r9-relative addressing
for the .rodata, .data, and .bss sections: this implies that
.rodata (read-only data, which resides in flash) cannot be
allocated separately from .data and .bss (which reside in ram).

Then I'd like to modify the -fpic option to generate pc-relative
instead of r9-relative addressing for the .rodata section.
This won't be a regression for position independant programs
where code and data are relocated together, so the -fpic option
generation may be modified without the need for a new option.

Can anybody here point me to places in GCC sources where the
.text and .rodata section addressing modes are selected, and
to documentation to read to contribute cleanly this modification?

CL
http://christophe.lavarenne.free.fr

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux