On 01/24/2011 03:16 PM, Stefano Bonifazi wrote: > Hi! Thanks for replying me! >> The thing is, the kernel currently _does_ work, so studying the relevant >> kernel code (and possibly the dynamic loader code) is one way to learn >> how it currently works. > Sorry what kernel? Qemu's? Linux's?
QEMU isn't a kernel, it's an emulator. Linux is a kernel. I meant Linux loads and runs Linux ELF executables. That's pretty much the definition of "how to do it". So if there's ever a conflict between "how qemu does it" and "how the Linux kernel does it", the Linux kernel is going to win. (And yes, this has come up before, for me it was http://www.mail-archive.com/qemu-devel@nongnu.org/msg25336.html ) That said, QEMU's currently working fairly well on this front too, so studying either should work pretty well... One advantage of the kernel is "cat /proc/$PID/maps" which lets you know what the mappings are, and then you can look up the appropriate chunks of the executable and read the elf spec: http://refspecs.freestandards.org/elf/elf.pdf And to be honest, the best way to get up to speed on this is to read this: http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html Where some guy asked "ok, what do we actually NEED" and then set out to prove it. This book is pretty good too, although so dry it's almost unreadable. You might have better luck getting a paper copy out of the library: http://www.iecc.com/linker/ Rob