kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Questions about the LMA and VMA in a linker script
@ 2016-07-14  2:33 walker lala
  2016-07-14  6:07 ` Dave Hylands
  0 siblings, 1 reply; 5+ messages in thread
From: walker lala @ 2016-07-14  2:33 UTC (permalink / raw)
  To: kernelnewbies

Hi,
I got some question about the AT directive in linker script. I have
post this question to binutils{at}sourceware.org with no reply.
Hopefully someone can help me out.

After some searching and asking, I finally know that the AT directive
tell the linker about LMA of  a section.

For example there is some linker script like this:

    SECTIONS
    {
        . = 0X80100000;
        .text : AT(0x100000) {
            *(.text .stub .text.* .gnu.linkonce.t.*)
        }

      ... blah blah ...
    }

Now 0x8010000 is a VMA, and 0x100000 is a LMA.

My question is, is LMA the same as the physical address in a ELF
program header ? A typical ELF declaration would be something like
this:

typedef struct
{
  Elf32_Word    p_type;                 /* Segment type */
  Elf32_Off     p_offset;               /* Segment file offset */
  Elf32_Addr    p_vaddr;                /* Segment virtual address */
  Elf32_Addr    p_paddr;                /* Segment physical address */
  Elf32_Word    p_filesz;               /* Segment size in file */
  Elf32_Word    p_memsz;                /* Segment size in memory */
  Elf32_Word    p_flags;                /* Segment flags */
  Elf32_Word    p_align;                /* Segment alignment */
} Elf32_Phdr;

Is LMA just **p_paddr** in the program header?

My understanding is, when the linker link all the object files
together and then output a executable file of ELF format, those LMA
declare in the linker script would be the **p_paddr** in the
executable file, so the loader can correspondingly put that program on
the physical address as declared by **p_paddr**. Is that correct?
Please correct me if you may. I'm reading some low level code and is
not really familiar with those low level stuff.

Thanks in advance!
Ruan.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-16  1:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-14  2:33 Questions about the LMA and VMA in a linker script walker lala
2016-07-14  6:07 ` Dave Hylands
2016-07-14  8:45   ` Yubin Ruan
2016-07-15 18:42     ` Dave Hylands
2016-07-16  1:23       ` Yubin Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).