* What is the purpose of parse_elf() in misc.c
@ 2011-11-25 5:30 Graeme Russ
2011-12-02 5:41 ` Mulyadi Santosa
0 siblings, 1 reply; 2+ messages in thread
From: Graeme Russ @ 2011-11-25 5:30 UTC (permalink / raw)
To: kernelnewbies
Hi All,
In looking at booting a raw x86 kernel image, I discovered that the
compressed image in bzImage is actually an ELF image created with:
objcopy -R .comment -S vmlinux
After decompressing the image, the parse_elf() function in misc.c copies
the sections from the ELF image (there are 3 sections, only 2 are marked
PT_LOAD) into their final resting place in memory. This got me to thinking,
why not use:
objcopy -O binary -R .comment -S vmlinux
I wrote a little stand-alone parse_elf() program, and lo-and-behold, the
outputs are identical. So, in theory, if bzImage contained a raw binary, it
could be decompressed directly to the target address.
Now there is some adjustment in parse_elf() for relocatable kernels, but I
can't but think that this could be simply catered for in the decompression
target address
Surely this would speed up kernel loading by removing the additional copy
that parse_elf() introduces
Or am I missing something significant?
Regards,
Graeme
^ permalink raw reply [flat|nested] 2+ messages in thread
* What is the purpose of parse_elf() in misc.c
2011-11-25 5:30 What is the purpose of parse_elf() in misc.c Graeme Russ
@ 2011-12-02 5:41 ` Mulyadi Santosa
0 siblings, 0 replies; 2+ messages in thread
From: Mulyadi Santosa @ 2011-12-02 5:41 UTC (permalink / raw)
To: kernelnewbies
Hi Graeme....
On Fri, Nov 25, 2011 at 12:30, Graeme Russ <graeme.russ@gmail.com> wrote:
> I wrote a little stand-alone parse_elf() program, and lo-and-behold, the
> outputs are identical. So, in theory, if bzImage contained a raw binary, it
> could be decompressed directly to the target address.
I find your experiment quite interesting. After looking at parse_elf
(http://lxr.linux.no/#linux+v3.1.4/arch/x86/boot/compressed/misc.c#L276),
I guess it could be codes introduced long time before objcopy support
"binary" form. And since then is rarely touched again.
But maybe it's left there in case there is a platform that doesn't
have objcopy version that supports "binary" form conversion. So I
think it's more about portability issue.
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-02 5:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-25 5:30 What is the purpose of parse_elf() in misc.c Graeme Russ
2011-12-02 5:41 ` Mulyadi Santosa
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).