<br><br><div class="gmail_quote">2012/6/18 Nicolas Pitre <span dir="ltr"><<a href="mailto:nicolas.pitre@linaro.org" target="_blank">nicolas.pitre@linaro.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Mon, 18 Jun 2012, Michal Simek wrote:<br>
<br>
> Setup correct virtual and physical address in ELF LOAD section.<br>
<br>
</div>We are moving to a single kernel binary for multiple targets, including<br>
targets with different physical load addresses. The kernel code figures<br>
out at run time what the actual physical address is when<br>
CONFIG_ARM_PATCH_PHYS_VIRT is set which is the default these days. In<br>
other words, we don't know the physical offset at build time in that<br>
case and CONFIG_PHYS_OFFSET is simply not defined.<br></blockquote><div><br>ok. good to know and nice features. In that case I expect that you are using any binary format<br>and you copy it to memory and run it. Code find out where it runs and based on that setup things.<br>
(BTW: This is very interesting for me to implement it on Microblaze. Can you point me to that kernel code part? or any doc?)<br><br>But can you do it with elf? From my experience elf loaders are reading physical address from program headers<br>
and load all load sections. At the end they read entry point address and setup PC on it and run it<br>(readelf -l -h). If these values are setup incorrectly to virtual addresses elf loader just load them to virtual memory address<br>
or just failed. <br><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Why do you need this change? Your patch comments are lacking<br>
justification for them.<br><br></blockquote><div>The main reason is to elf loaders. <br>Please correct me if I am wrong IRC ARM Qemu uses zImage but it is no problem to use elf file. For this case<br>Qemu elf loader also uses physical addresses from ELF and also entry point.<br>
<br>There is one more thing in connection with this patch which is that exactly the same description is done<br>in asm-generic/vmlinux.lds.h macros which arm lds.S includes. For example INIT_TEXT_SECTION. <br><br>If you look at vmlinux before and after my changes you will see some differences which shouldn't affect your binary format <br>
at all. Look below to readelf outputs.<br><br>I haven't played with CONFIG_ARM_PATCH_PHYS_VIRT option but what is elf entry point for this case? <br><br>Thanks,<br>Michal<br><br><br><br>Before:<br><br>ELF Header:<br> Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 <br>
Class: ELF32<br> Data: 2's complement, little endian<br> Version: 1 (current)<br> OS/ABI: UNIX - System V<br>
ABI Version: 0<br> Type: EXEC (Executable file)<br> Machine: ARM<br> Version: 0x1<br> Entry point address: 0x80008000<br>
Start of program headers: 52 (bytes into file)<br> Start of section headers: 84873104 (bytes into file)<br> Flags: 0x5000002, has entry point, Version5 EABI<br> Size of this header: 52 (bytes)<br>
Size of program headers: 32 (bytes)<br> Number of program headers: 3<br> Size of section headers: 40 (bytes)<br> Number of section headers: 37<br> Section header string table index: 34<br>
<br>Program Headers:<br> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align<br> LOAD 0x008000 0x80008000 0x80008000 0x254a204 0x255e814 RWE 0x8000<br> NOTE 0x25521e0 0x825521e0 0x825521e0 0x00024 0x00024 R E 0x4<br>
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4<br><br><br>After:<br><br>ELF Header:<br> Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 <br> Class: ELF32<br>
Data: 2's complement, little endian<br> Version: 1 (current)<br> OS/ABI: UNIX - System V<br> ABI Version: 0<br>
Type: EXEC (Executable file)<br> Machine: ARM<br> Version: 0x1<br> Entry point address: 0x10008000<br> Start of program headers: 52 (bytes into file)<br>
Start of section headers: 84873088 (bytes into file)<br> Flags: 0x5000002, has entry point, Version5 EABI<br> Size of this header: 52 (bytes)<br> Size of program headers: 32 (bytes)<br>
Number of program headers: 3<br> Size of section headers: 40 (bytes)<br> Number of section headers: 37<br> Section header string table index: 34<br><br>Program Headers:<br> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align<br>
LOAD 0x008000 0x80008000 0x10008000 0x254a204 0x255e814 RWE 0x8000<br> NOTE 0x25521e0 0x825521e0 0x125521e0 0x00024 0x00024 R E 0x4<br> GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4<br>
<br><br><br><br> <br><br><br><br></div></div>