[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#299567: kernel-image-2.6.8-2-686-smp: x86 has no uncompressed vmlinux (for oprofile)



Dear sir,
I ran your python script as
#python vmlinuz-2.6.26-2-686

i got the following error
Traceback (most recent call last):
  File "/mnt/disk[sda4]/root/Desktop/tmp/vmlinuz/extvmlinuz.py", line 39, in <module>
    vmlinux = open(sys.argv[2], 'wb')
IndexError: list index out of range

why is it so..

On Mon, Oct 5, 2009 at 8:56 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
While we still aren't providing an uncompressed vmlinux image, it is now
possible to extract one from vmlinuz.  The following Python script does
the job; give it the filename of the compressed image followed by the
filename for the uncompressed image.

Ben.

#!/usr/bin/python

import struct, zlib

def vmlinuz_to_image(f):
   # We can't use gzip.GzipFile because that complains if there is
   # trailing data, which is the case for ELFBoot kernel images.
   # Use zlib directly.
   zo = zlib.decompressobj(-15)

   # Look for gzip-deflate header and find end of it
   f.seek(0, 0)
   head = f.read(65536)
   off = head.index('\x1f\x8b\x08')
   flags = ord(head[off + 3])
   off += 10                   # fixed header
   if flags & 0x04:            # FEXTRA
       off += 2 + struct.unpack('<H', head[off:off+2])[0]
   if flags & 0x08:            # FNAME
       off = head.index('\0', off) + 1
   if flags & 0x10:            # FCOMMENT
       off = head.index('\0', off) + 1
   if flags & 0x02:            # FHCRC
       off += 2
   assert not (flags & 0xe0)   # reserved

   # Decompress following deflate blocks
   f.seek(off)
   image = zo.decompress(f.read()) + zo.flush()

   # Verify decompressed data against gzip trailer
   assert (struct.unpack('<LL', zo.unused_data[:8]) ==
           (zlib.crc32(image) & 0xffffffffL, len(image)))

   return image

if __name__ == '__main__':
   import sys
   vmlinuz = open(sys.argv[1], 'rb')
   vmlinux = open(sys.argv[2], 'wb')
   vmlinux.write(vmlinuz_to_image(vmlinuz))
### END ###

--
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.



--
bossganesh
BOSSTeam
CDAC

Reply to: