| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| C++ (Non Visual C++ Issues) Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
convert vmlinuz to vmlinux
Hello everyone,
I am using oprofile on Linux to profile a C/C++ application. Oprofile needs to use vmlinux other than vmlinuz (on my machine, under /boot, I only have vmlinuz -- compressed format). I have tried to use gzip to un-compress vmlinuz, but I have got an error message which indicates un-recognized zip format. Any ideas about how to get a vmlinux? thanks in advance, George |
|
#2
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Not sure how this is relevant in this forum but anyway
![]() The vmlinuz isn't just the compressed kernel, it's complete bootable image including the decompressor. To get just the image search for the GZ signature - 1f 8b 08 00. Now i'm sure there are scripts for it somewhere, but you can do it old-fashioned way - in my case: > od -A d -t x1 vmlinuz | grep '1f 8b 08 00' 0024576 24 26 27 00 ae 21 16 00 1f 8b 08 00 7f 2f 6b 45 so the image begins at 24576+8 => 24584 . Then just copy the image from the point and decompress it - >dd if=vmlinuz bs=1 skip=24584 | zcat > vmlinux 1450414+0 records in 1450414+0 records out 1450414 bytes (1.5 MB) copied, 6.78127 s, 214 kB/s |
|
#3
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Thanks JohnyDog,
Quote:
I have monitored my output from your output. Here are some differences. > dd if=/boot/vmlinuz-2.6.9-11.EL bs=1 skip=13844 | zcat > vmlinux > 1421660+0 records in > 1421660+0 records out You can see I have no information dumped as yours, such as "1450414 bytes (1.5 MB) copied, 6.78127 s, 214 kB/s". When executing oprofile, there are still such errors, > /root/opcontrol --vmlinux=/root/vmlinux > The specified file /root/vmlinux does not seem to be valid > Make sure you are using vmlinux not vmlinuz Any ideas? regards, George |
|
#4
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
I've just realized that when vmlinux image is converted to vmlinuz, the symbols, along with the ELF header are stripped to save space. As the symbols are the thing for which oprofile requires the image, i guess you're out of luck and will have to either find the vmlinux for your distribution somewhere, or recompile the kernel yourself.
|
|
#5
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Thanks JohnyDog,
Quote:
Another question is, do you know why oprofile needs a Linux kernel (vmlinux)? I think if I recompile a Linux kernel to generate a vmlinux (without make install), but in my real Linux environment, the /boot/vmlinuz is the kernel image I actally used, will it take effect to oprofile? regards, George |
|
#6
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Quote:
Quote:
If the kernel is the same version and was compiled with the same options, then the resulting image should be the same.
|
|
#7
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Thanks JohnyDog,
Quote:
To be safe, I think of two more points, 1. Reserve current settings. Do you know some smart way from which I could get the current kernel settings -- if I run make xconfig, the settings displayed is my current kernel settings? 2. Reserve current vmlinuz kernel. I think I could stop after step make bzImage in order to get vmlinux, without running step make install to overwrite my current kernel. Do you think it is all right? regards, George |
|
#8
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Quote:
When you run make (b)zImage/install etc., the script will use file '.config' (note the dot at beggining) in current directory (/usr/src/linux) as kernel settings. When you do make xconfig/menuconfig, it simply reads the ".config" file and displays the options presented there (or defaults, if the .config doesn't exist). Quote:
|
|
#9
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Thanks JohnyDog,
Quote:
How do you think this method? Do you suppose it works? regards, George |
|
#10
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
If your distribution puts the config under /boot, i'd say its preffered method. After all, the config file should be identical to the one in /proc/config.gz.
|
|
#11
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Thanks JohnyDog,
Quote:
regards, George |
|
#12
|
|||
|
|||
|
Re: convert vmlinuz to vmlinux
Yes thats right. As a side note, if you want to recompile the kernel you should use sources provided by your distribution, as they usually differ from the ones in official kernel at kernel.org (added patches etc.).
|
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|