Hello,

Thanks for your answer and the link; it was really a very
interesting lesson.

First , there is also a non-compressed image file on the 2.6.* kernel I
use. It resides, natuarally (?!) , in the "compressed" folder.
(/arch/i386/boot/compressed)
It is called vmlinux.

Running nm -a vmlinux | egrep ext3 gave no results.
Running nm -a vmlinux | egrep memcpy found one occurrence.

However, when building a kernel , you usually copy only the bzImage to the boot
sector; and if you build again the kernel, you don't have the uncompressed
image from the old one. And since this what interests me, I went on:


I had looked in that Makefile (/arch/i386/boot/Makefile):

the bzImage target in 2.4.20 looks like this:
..
bzImage: $(CONFIGURE) bbootsect bsetup compressed/bvmlinux tools/build
$(OBJCOPY) compressed/bvmlinux compressed/bvmlinux.out
tools/build -b bbootsect bsetup compressed/bvmlinux.out $(ROOT_DEV) > bzImage
..



while in 2.6.* based kernel I use ,it looks like this .. $(obj)/zImage $(obj)/bzImage: $(obj)/bootsect $(obj)/setup \ $(obj)/vmlinux.bin $(obj)/tools/build FORCE $(call if_changed,image) @echo 'Kernel: $@ is ready' ..

It seems similiar , with little changes of name. (setup instead bsetup,etc.)

Btw , I also looked in arch/i386/boot/tools/build.c (in my 2.6.* kernel, but it
is so also in 2.4 kernel):
There are in the original code 3 printf() commands displaying Boot sector size,
Setup size and System. I ran Running make from the root
of the kernel source tree in 2.6.7 displays them at the end of the
process. (assuming , of course, that there was some change in the source code
and bzImage was created).


So I ran make (only or a test) and I get:
Boot sector 512 bytes.
Setup is 4799 bytes.
System is 1166 kB


Looking at build.c , in 2.6.7 kernel, we can see that the
number of setup sectors is written in offset 497:
...
if (lseek(1, 497, SEEK_SET) != 497) /* Write sizes to the bootsector */
die("Output: seek failed");
buf[0] = setup_sectors;
if (write(1, buf, 1) != 1)
die("Write of setup sector count failed");
...


so to read it (in decimal form) I ran: (on the original bzImage).

od bzImage -t d --skip-bytes=497 -N 1
gave:
0000761          10
0000762

Which means we have 10  setup sectors, which is reaonable.
(Taking in account that it says that there are 4799 bytes
in setup, and assuming it did not change much, it is 10
sectors (each 512 bytes).


So I ran dd like thus (I am not sure that I used the dd correctly as I don't use it frequently):

First,I used skip=11 for 1 sector of boot sector and 10 of setup
code , as the od shows.

dd bs=512 skip=11 if=bzImage of=kernel

and :

file kernel
gives:

kernel: data
since it's not an ELF file,I ran strings:

but running strings kernel | egrep memcpy
gives nothing.

Maybe I did something wrong is the dd comman (which I do not
use frequently). It seesm to me that bs is ,by default , 512,

Thanks,
Dan



From: guy keren <[EMAIL PROTECTED]>
To: Dan Kaspi <[EMAIL PROTECTED]>
CC: [EMAIL PROTECTED]
Subject: Re: ext3 in the kernel image or as a module Date: Tue, 30 Nov 2004 02:09:52 +0200 (IST)



On Mon, 29 Nov 2004, Dan Kaspi wrote:

> I have a bzImage. It was built with 2.6.* kernel. I do not know the
> configuarion
> ( More rpecisely :I'm not sure I have the .config file it was built with ).
> I want to know if the ext3 was build into this kernel image or as a module.


question: on my old redhat 7.3 system, the installed kernel comes in two
flavors - the compressed file and the non-compressed file. can you check
if you have the non-compressed version of the kernel file too? if you do,
run 'nm filename | egrep ext3' and see if you get any ext3 symbols.

if you only have the compressed file, you'll have to start working:

(note: i'm reading the info for a 2.4-based kernel - perhaps this changed
in 2.6):

the compressed kernel is made of 3 sections:

1. a boot sector - 512 bytes.
2. the setup code - made of a number of sectors which is written in the
   boot sector (the first 512 bytes mentioned in #1).
3. the (copressed) kernel itself.

look in /usr/src/linux/arch/i386/boot/Makefile for the command-line used
to create the bzImage file from these 3. then look at
/usr/src/linux/arch/i386/boot/tools/build.c for the (rather simple) C
program that builds the bzImage file from those 3 files.

in the program you'll see both how the file is constructed, as well as
which byte in the boot sector contains the number of sectors which the
setup code occupies. reading this number from the boot sector (with
'od') will tell you which sector in the bzImage file is the beginning of
the kernel binary itself. then you can extract that from the bzImage using
dd, and then you just need to uncompress it - if it is compressed at all
(i suppose that running 'file' on the resulting file will tell you if it's
compressed, or it is an ELF file).

finally, run the 'strings' command on the resulting file (it's not an ELF
file, it seems, but something else) and grep for ext3. grep for more
fundamental symbols, too, to make sure you got the right kernel image
file.

note: there is a howto called Linux-i386-Boot-Code-HOWTO, which contains a
short-cut for this process, by scanning the bzImage file for the signature
of gzip - see
http://distributions.linux.com/howtos/Linux-i386-Boot-Code-HOWTO/compressed_head.shtml

for details ;)

may the source be with you ;)
--
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]


_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]



Reply via email to