From: Ian Campbell <ijc@hellion.org.uk>
To: Corentin Chary <corentincj@iksaif.net>
Cc: linux-kernel@vger.kernel.org, Michal Marek <mmarek@suse.cz>,
Dick Streefland <dick@streefland.net>,
WANG Cong <xiyou.wangcong@gmail.com>
Subject: Re: [PATCH v3] scripts: add extract-vmlinux
Date: Fri, 19 Aug 2011 07:51:26 +0100 [thread overview]
Message-ID: <1313736686.17978.15.camel@dagon.hellion.org.uk> (raw)
In-Reply-To: <1313484365-22129-1-git-send-email-corentincj@iksaif.net>
[-- Attachment #1.1: Type: text/plain, Size: 886 bytes --]
On Tue, 2011-08-16 at 10:46 +0200, Corentin Chary wrote:
> This script can be used to extract vmlinux from a compressed
> kernel image (bzImage, etc..). It's inspired from (a subset of)
> extract-ikconfig.
FWIW I wrote the attached way back when, it uses the payload_* fields in
the bzImage to find the payload rather than scanning (these are present
in bzImages from somewhere in the mid 2.6.2x range). I'd be happy to
license it under the GPLv2 if that is helpful.
> It's something a lot of people have been looking for (mainly
> people with xen < 4 that doesn't support bzImages at all).
xen 3.4 does, doesn't it (at least the tip of 3.4-testing.hg does)? And
I thought e.g. RHEL5 (which uses an older base version) had it
backported. Possibly what is missing is support for all the various
compression options.
Ian.
--
Ian Campbell
How do I get HOME?
[-- Attachment #1.2: bzexplode.c --]
[-- Type: text/x-csrc, Size: 1309 bytes --]
#include <stdio.h>
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
#include <inttypes.h>
#include <err.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
int main(int argc, char **argv)
{
int fd;
struct stat sb;
void *p;
uint8_t *hdr;
int setup_sectors;
uint32_t compressed_payload_offset;
uint32_t compressed_payload_length;
if (argc != 2)
errx(1, "usage: bzexplode <bzImage>");
fd = open(argv[1], O_RDONLY);
if (fd < 0)
err(1, "open");
if (fstat(fd, &sb) < 0)
err(1, "fstat");
p = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (p == MAP_FAILED)
err(1, "mmap");
hdr = p;
setup_sectors = hdr[0x1f1];
compressed_payload_offset = *(uint32_t*)&hdr[0x248];
fprintf(stderr, "setup sectors %d\n", setup_sectors);
compressed_payload_offset += (setup_sectors+1) * 512;
//compressed_payload_length = *(uint32_t*)(p + compressed_payload_offset - 4);
compressed_payload_length = *(uint32_t*)&hdr[0x24c];
fprintf(stderr, "compressed_payload_offset %"PRIx32" (abs)\n",
compressed_payload_offset);
fprintf(stderr, "compressed_payload_length %"PRIx32"\n",
compressed_payload_length);
write(1,
p + compressed_payload_offset,
compressed_payload_length);
return 0;
}
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2011-08-19 6:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-04 13:52 [PATCH] " Corentin Chary
2011-08-10 13:27 ` Michal Marek
2011-08-11 7:21 ` Corentin Chary
2011-08-11 7:53 ` Dick Streefland
2011-08-11 8:42 ` Américo Wang
2011-08-11 8:53 ` Corentin Chary
2011-08-11 11:28 ` Paul Bolle
2011-08-11 13:08 ` Corentin Chary
2011-08-11 13:33 ` Michal Marek
2011-08-11 14:23 ` Corentin Chary
2011-08-11 15:47 ` Corentin Chary
2011-08-16 8:46 ` [PATCH v3] " Corentin Chary
2011-08-18 10:09 ` Américo Wang
2011-08-26 9:49 ` Corentin Chary
2011-08-19 6:51 ` Ian Campbell [this message]
2011-08-19 7:52 ` Corentin Chary
2011-08-31 14:16 ` Michal Marek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1313736686.17978.15.camel@dagon.hellion.org.uk \
--to=ijc@hellion.org.uk \
--cc=corentincj@iksaif.net \
--cc=dick@streefland.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome