tags:

views:

29

answers:

3

I'm trying to track down a kernel binary; is there a way to determine the version (build string) of a Linux 'uImage' binary?

Running

strings uImage

piped into various trailing grep statements leads me to think I'm dealing with a compressed image...

A: 

I am not sure however you might try uname -a may be this is what you want.

That gives the build string of the host environment; I'm looking to see inside a kernel image I've got stored as a `uImage` file. Thanks for responding though.
Jamie
+1  A: 

Try file uImage. It might identify the file format if it is a commonly known compression format. Other than that, the strings utility is probably the best one for this task.

D.Shawley
A: 

I just realized, the kernels I have immediate access to do have the version string stored uncompressed amongst the headers. strings uImage | grep 2.6 ought to be good enough for any 2.6 kernel which covers pretty much everything in the last 5+ years).

(original answer follows)


It's theoretically possible, but not entirely trivial.

Modern Linux kernel versions use a format called bzImage (for x86/x86_64, YMMV on other platforms). It actually consists of an ELF header and some other minutia (like a bit of decompression code) followed by, yes, a compressed image of the actual kernel.

Traditionally, the compression algorithm was zlib (contrary to popular misconception, 'bzImage' did not stand for "bzipped image", but for "big zImage" -- the original zImage format not being able to handle large kernels), though versions after 2.6.30 also support bzip2 and LZMA.

What you'll probably have to do is determine exactly where the compressed data starts (sorry, can't help you there, but trial and error might work), and write a bit of code to run it through the library for whichever compression algorithm is in use.

Nicholas Knight