07.01.2013 Views

Linux i386 Önyükleme Kodu NASIL

Linux i386 Önyükleme Kodu NASIL

Linux i386 Önyükleme Kodu NASIL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Linux</strong> <strong>i386</strong> <strong>Önyükleme</strong> <strong>Kodu</strong> <strong>NASIL</strong><br />

ISIZE Input SIZE (Girdi uzunlu˘gu)) 4 sıkı¸stırılmamı¸s girdi verisi boyunun 2ˆ32 ile<br />

bölümünden kalan<br />

Bu dosya biçimi bilgisini gzipli linux/vmlinux’un ba¸slangıcını bulmak için kullanabiliriz.<br />

[root@localhost boot]# hexdump –C /boot/vmlinuz–2.4.20–28.9 | grep ’1f 8b 08 00’<br />

00004c50 1f 8b 08 00 01 f6 e1 3f 02 03 ec 5d 7d 74 14 55 |.......?...]}t.U|<br />

[root@localhost boot]# hexdump –C /boot/vmlinuz–2.4.20–28.9 –s 0x4c40 –n 64<br />

00004c40 00 80 0b 00 00 fc 21 00 68 00 00 00 1e 01 11 00 |......!.h.......|<br />

00004c50 1f 8b 08 00 01 f6 e1 3f 02 03 ec 5d 7d 74 14 55 |.......?...]}t.U|<br />

00004c60 96 7f d5 a9 d0 1d 4d ac 56 93 35 ac 01 3a 9c 6a |......M.V.5..:.j|<br />

00004c70 4d 46 5c d3 7b f8 48 36 c9 6c 84 f0 25 88 20 9f |MF\.{.H6.l..%. .|<br />

00004c80<br />

[root@localhost boot]# hexdump –C /boot/vmlinuz–2.4.20–28.9 | tail –n 4<br />

00114d40 bd 77 66 da ce 6f 3d d6 33 5c 14 a2 9f 7e fa e9 |.wf..o=.3\...˜..|<br />

00114d50 a7 9f 7e fa ff 57 3f 00 00 00 00 00 d8 bc ab ea |..˜..W?.........|<br />

00114d60 44 5d 76 d1 fd 03 33 58 c2 f0 00 51 27 00 |D]v...3X...Q’.|<br />

00114d6e<br />

Yukarıdaki örnekte gzipli dosyanın 0x4c50 adresinde ba¸sladı˘gını görebiliriz. "1f 8b 08 00"den önceki dört<br />

byte input_len’dir (küçük sonlu olarak 0x0011011e) ve 0x4c50+0x0011011e=0x114d6e de˘geri bzImage<br />

(/boot/vmlinuz–2.4.20–28.9) dosyasının boyuna e¸sittir.<br />

static uch *inbuf; /* girdi tamponu */<br />

static unsigned insize = 0; /* inbuf içindeki geçerli baytlar*/<br />

static unsigned inptr = 0; /* inbuf içinde i¸slenecek sonraki baytın indisi */<br />

///////////////////////////////////////////////////////////////////////////////<br />

static int gunzip(void)<br />

{<br />

Girdi tamponunu {ID1, ID2, CM} için kontrol et, ¸söyle olmalı:<br />

{0x1f, 0x8b, 0x08} (normal durum), veya<br />

{0x1f, 0x9e, 0x08} (gzip 0.5 için);<br />

FLG’yi (seçenek baytı) kontrol et, 1, 5, 6 ve 7. bitler atanmamalı;<br />

Ignore {MTIME, XFL, OS};<br />

FLG biti 2,3 ve 4’e kar¸sılık gelen seçimlik yapıları yönet;<br />

inflate(); // sıkı¸stırılmı¸s blokları yönet<br />

Validate {CRC32, ISIZE};<br />

}<br />

linux/arch/<strong>i386</strong>/boot/compressed/misc.c içinde tanımlı get_byte() ilk defa ça˘gırıldı˘gında,<br />

girdi tamponunu inbuf=input_data ve insize=input_len olacak ¸sekilde ayarlamak için<br />

fill_inbuf() i¸slevini ça˘gırır. input_data ve input_len sembolleri piggy.o ilintileme beti˘ginde<br />

tanımlanmı¸stır. Bakınız linux/arch/<strong>i386</strong>/boot/compressed/Makefile (sayfa: 9).<br />

5.3. inflate()<br />

// misc.c içindeki bazı önemli tanımlamalar<br />

#define WSIZE 0x8000 /* Pencere boyutu en azından 32k olmalı,<br />

* ve ikinin üssü olmalı */<br />

static uch window[WSIZE]; /* Kayan pencere tamponu */<br />

static unsigned outcnt = 0; /* çıktı tamponundaki bayt sayısı */<br />

// linux/lib/inflate.c<br />

#define wp outcnt<br />

#define flush_output(w) (wp=(w),flush_window())<br />

STATIC unsigned long bb; /* bit tamponu */<br />

http://belgeler.org <strong>Linux</strong> Kitaplı˘gı 36 / 77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!