This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Setting the LMA in ld
- From: Nick Clifton <nickc at redhat dot com>
- To: "Schwarz, Konrad" <konrad dot schwarz at siemens dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Mon, 12 Jun 2017 16:38:28 +0100
- Subject: Re: Setting the LMA in ld
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nickc at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 778F34E4E6
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 778F34E4E6
- References: <A45B1767F1002449A37508C2CC6003D74FC80B@DEFTHW99EJ1MSX.ww902.siemens.net>
Hi Konrad,
Sorry for taking so long to answer your email. As you might guess this is a tricky area
for the linker.
> This file is added to the link command via -Wl,-Tscript.ld. The MEMORY command defines
> a ROM and a RAM memory region; the SECTIONS command defines a new (dummy) output section that
> is located to RAM but loaded to ROM. This output section is placed after the last read-only
> data section, and indeed is located in RAM but loaded to ROM. However, the following sections
> including .data, are not loaded to ROM; their LMA is equal to their VMA, which would seem to
> contradict the manual.
It sounds to me as if the cause of the problem is that the .data_located
section is read-only whereas the .data section is read-write. Thus the .data
section is not being placed into the same memory region as .data_located, but
instead is being placed into the unnamed, default memory region which does not
have any run-time address adjustment associated with it.
My recommendation is to bite the bullet and create your own, full blown, linker script.
You can start with the built in script and add the sections, regions and VMAs that you
need as direct edits to the script. In the end I think that this will actually turn
out to be the simpler option.
> Also, the ld manual does not really define the meaning of the I (or L) memory region attribute.
This attribute indicates that the region contains information that should
be loaded into memory when the program runs. In ELF terms it is equivalent
to the PT_LOAD segment type.
> E.g., which
> GNU as ELF .section flags or type parameters needs to be set for a section to be considered initialized?
None! As long as you do *not* include the @nobits section flag then the
section will be considered to be loadable, and hence compatible with the I
(or L) memory region attribute.
Cheers
Nick