This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Setting the LMA in ld

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]