This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Strange LMA/VMA behavior with regions
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: Binutils <binutils at sourceware dot org>
- Date: Mon, 29 Nov 2010 13:37:44 +0100
- Subject: Strange LMA/VMA behavior with regions
Hi,
I have to write a custom linker script to distribute various output sections to
various physical memory regions (for embedded devices). I have this linker
SECTIONS part:
.jcr : {
KEEP (*(.jcr))
} > REGION AT > REGION
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
} > REGION AT > REGION
The .rodata section has a section alignment of 8 (the alignment depends on the
application, it may be higher). Now suppose that the .jcr end is not 8 bytes
aligned. We may have this:
.jcr 0x00000000800198b0 0x4
*(.jcr)
.jcr 0x00000000800198b0 0x0 crtbegin.o
.jcr 0x00000000800198b0 0x4 crtend.o
.rodata 0x00000000800198b8 0x2ba8 load address 0x00000000800198b4
*(.rodata .rodata.* .gnu.linkonce.r.*)
This is pretty bad, since this introduces a 4 byte offset in the .rodata
section. If I use this SECTIONS part:
.jcr : {
KEEP (*(.jcr))
} > REGION AT > REGION
.rodata : ALIGN (8) {
*(.rodata .rodata.* .gnu.linkonce.r.*)
} > REGION AT > REGION
We get this:
.jcr 0x00000000800198b0 0x4
*(.jcr)
.jcr 0x00000000800198b0 0x0 crtbegin.o
.jcr 0x00000000800198b0 0x4 crtend.o
.rodata 0x00000000800198b8 0x2ba8
*(.rodata .rodata.* .gnu.linkonce.r.*)
Unfortunately the section alignment is unknown in advance, so .rodata : ALIGN
(ALIGNOF(.rodata)) { ... } is not possible. Please observe that LMA==VMA in
.jcr. Let OFFSET := LMA - VMA. I think that LD should not introduce an OFFSET
!= 0 due to alignment constraints if the load and runtime region are equal.
Have a nice day!
--
Sebastian Huber, embedded brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.