Re: [PATCH] scripts: add extract-vmlinux

From: Corentin Chary
Date: Thu Aug 11 2011 - 10:23:28 EST

On Thu, Aug 11, 2011 at 3:33 PM, Michal Marek <mmarek@xxxxxxx> wrote:
> On 11.8.2011 15:08, Corentin Chary wrote:
>> On Thu, Aug 11, 2011 at 1:28 PM, Paul Bolle <pebolle@xxxxxxxxxx> wrote:
>>> On Thu, 2011-08-11 at 10:53 +0200, Corentin Chary wrote:
>>>> +try_decompress()
>>>> +{
>>>> +   for   pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
>>>> + Â Â do
>>>> + Â Â Â Â Â Â pos=${pos%%:*}
>>>> + Â Â Â Â Â Â tail -c+$pos "$img" | $3 > $tmp 2> /dev/null
>>> Perhaps a few comments on the above lines would be nice. Without those
>>> comments I must guess you're finding compressed data somewhere in the
>>> input file. It also seems you're looping through the entire input file.
>>> Or are (sequences of) commands like the above considered obvious?
>> It's copied from extract-ikconfig, there was no comment in it, so I
>> assumed it's obvious.
>> Basically it uses brute force (tm) to find well known headers and try
>> to decompress from here.
> And explanation of the "tr" trick would not hurt though. It replaces the
> binary magic with an ascii sequence on a new line (for older grep
> versions to get it right) and tries all occurrences of that sequence, am
> I right? But I wouldn't call it "obvious" :).

It's that commented in the header of both scripts ? (I can move down
the command if wanted)

>>>> +# That didn't work, so retry after decompression.
>>>> +try_decompress '\037\213\010' xy  Âgunzip
>>>> +try_decompress '\3757zXZ\000' abcde unxz
>>>> +try_decompress 'BZh'     Âxy  Âbunzip2
>>>> +try_decompress '\135\0\0\0'  xxx  unlzma
>>>> +try_decompress '\211\114\132' xy  Â'lzop -d'
>>> Perhaps you could first test whether these commands are available before
>>> running try_decompress() with them?
>> Same as before, if it's ok for extract-ikconfig not to check the
>> command, then it's ok for me.
>> If it's not, then we should patch both.
> Also, if you have lzma to build a lzma-compressed kernel, then you very
> likely also have unlzma.
> Michal

Corentin Chary
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at