<div dir="ltr"><div style="font-size:12.8px">Replying to all this time.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Currently, I'm most recently familiar with small non-MMU processors (not running linux), and in that case, the VMA is the final address (typically in RAM) that the section will be loaded to.</div><div style="font-size:12.8px">The LMA is the address (typically in ROM) that the section will be at when the program starts execution.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">A typical example of this is initialized data. In the image, this "initialized data" section will be stored in ROM and copied to RAM by the C runtime library before calling main.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">In the linux kernel, the kernel image will be linked against its final virtual address (the VMA) and the LMA would correspond to the physical address that the kernel will be loaded at (since the MMU is typically off when the kernel image is loaded).</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">There are lots of variations and reasons why things might not be exactly like I described (different architectures have different conventions), but that's the jist of things.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 13, 2016 at 7:33 PM, walker lala <span dir="ltr"><<a href="mailto:ablacktshirt@gmail.com" target="_blank">ablacktshirt@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I got some question about the AT directive in linker script. I have<br>
post this question to binutils{at}<a href="http://sourceware.org" rel="noreferrer" target="_blank">sourceware.org</a> with no reply.<br>
Hopefully someone can help me out.<br>
<br>
After some searching and asking, I finally know that the AT directive<br>
tell the linker about LMA of a section.<br>
<br>
For example there is some linker script like this:<br>
<br>
SECTIONS<br>
{<br>
. = 0X80100000;<br>
.text : AT(0x100000) {<br>
*(.text .stub .text.* .gnu.linkonce.t.*)<br>
}<br>
<br>
... blah blah ...<br>
}<br>
<br>
Now 0x8010000 is a VMA, and 0x100000 is a LMA.<br>
<br>
My question is, is LMA the same as the physical address in a ELF<br>
program header ? A typical ELF declaration would be something like<br>
this:<br>
<br>
typedef struct<br>
{<br>
Elf32_Word p_type; /* Segment type */<br>
Elf32_Off p_offset; /* Segment file offset */<br>
Elf32_Addr p_vaddr; /* Segment virtual address */<br>
Elf32_Addr p_paddr; /* Segment physical address */<br>
Elf32_Word p_filesz; /* Segment size in file */<br>
Elf32_Word p_memsz; /* Segment size in memory */<br>
Elf32_Word p_flags; /* Segment flags */<br>
Elf32_Word p_align; /* Segment alignment */<br>
} Elf32_Phdr;<br>
<br>
Is LMA just **p_paddr** in the program header?<br>
<br>
My understanding is, when the linker link all the object files<br>
together and then output a executable file of ELF format, those LMA<br>
declare in the linker script would be the **p_paddr** in the<br>
executable file, so the loader can correspondingly put that program on<br>
the physical address as declared by **p_paddr**. Is that correct?<br>
Please correct me if you may. I'm reading some low level code and is<br>
not really familiar with those low level stuff.<br>
<br>
Thanks in advance!<br>
Ruan.<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Dave Hylands<br>Shuswap, BC, Canada<br><a href="http://www.davehylands.com" target="_blank">http://www.davehylands.com</a></div>
</div>