diff --git a/Documentation/NuttXNxFlat.html b/Documentation/NuttXNxFlat.html index 73be5d7b34..4d70ed9c37 100644 --- a/Documentation/NuttXNxFlat.html +++ b/Documentation/NuttXNxFlat.html @@ -229,13 +229,16 @@
- Read-only data must reside in RAM.
+ With older GCC compilers (at least up to 4.3.3), read-only data must reside in RAM.
In code generated by GCC, all data references are indexed by the PIC2 base register (that is usually R10 or sl for the ARM processors).
The includes read-only data (.rodata
).
Embedded firmware developers normally like to keep .rodata
in FLASH with the code sections.
But because all data is referenced with the PIC base register, all of that data must lie in RAM.
A NXFLAT change to work around this is under investigation3.
+ Newer GCC compilers (at least from 4.6.3), read-only data is no long GOT-relative, but is now accessed PC-relative. With PC relative addressing, read-only data must reside in the I-Space. +
abc-nuttx-elf-ld -r -d -warn-common -T binfmt/libnxflat/gnu-nxflat.ld -no-check-sections -o $@ hello.o hello-thunk.o
+ abc-nuttx-elf-ld -r -d -warn-common -T binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections -o $@ hello.o hello-thunk.o
hello.o
here)
along with the assembled thunk file, hello-thunk.o
to create the second relocatable object,
hello.r2
.
- The linker script, gnu-nxflat.ld
is required at this point to correctly position the sections.
+ The linker script, gnu-nxflat-gotoff.ld
is required at this point to correctly position the sections.
This linker script produces two segments:
An I-Space (Instruction Space) segment containing mostly .text
and a D-Space (Data Space) segment
containing .got
, .data
, and .bss
sections.
@@ -518,6 +521,22 @@ cat ../syscall/syscall.csv ../lib/lib.csv | sort >tmp.csv
The option -no-check-sections
is required to prevent the linker from failing because these segments overlap.
+NOTE:
+ There are two linker scripts located at binfmt/libnxflat/gnu-nxflat-gotoff.ld
.
+
binfmt/libnxflat/gnu-nxflat-gotoff.ld
.
+ Older versions of GCC (at least up to GCC 4.3.3), use GOT-relative addressing to access RO data.
+ In that case, read-only data (.rodata) must reside in D-Space and this linker script should be used.
+ binfmt/libnxflat/gnu-nxflat-pcrel.ld
.
+ Newer versions of GCC (at least as of GCC 4.6.3), use PC-relative addressing to access RO data.
+ In that case, read-only data (.rodata) must reside in I-Space and this linker script should be used.
+ Target 4.
Finally, this target will use the hello.r2
relocatable object to create the final, NXFLAT module
hello
by executing ldnxflat
.