Page 1 of 1
Finding stage2
Posted: Mon Apr 01, 2002 5:00 am
by Darkening
Hi,
I'm searching for a way to find a 2nd stage of a boot loader - best would be to be fs-independent. Any clues??
Thanks
Darkening
Re: Finding stage2
Posted: Mon Apr 01, 2002 5:15 pm
by Chris Giese
If you don't use the filesystem, there are two other ways:
1. Assume the second stage is stored in contiguous sectors
on the disk. The only information you need to find the
second stage is the starting sector and number of sectors.
A file stored on a freshly-formatted FAT12 or FAT16 disk
will be stored in contiguous sectors, but not if you modify
the file afterwards.
2. Write a program to make a list of the disk sectors
which contain the second stage, then write this sector list
into the first stage code. This is how the LILO and GRUB
first stages work, I think.
If you modify the second stage file, you must re-run the
sector list installer.
Re: Finding stage2
Posted: Mon Apr 01, 2002 6:42 pm
by Darkening
Thanks for the hints, I also thought about an asm-header with a signature. Now I'm wondering about the 2nd stage - I'd like to use gcc - but it outputs 32bit (with objcopy) and then I can't read from disk (GRUB does this with switching between 16- and 32bit, but it seems a bit complicated), so does anyone know something about this???
Darkening
Re: Finding stage2
Posted: Tue Apr 02, 2002 6:22 pm
by Chris Giese
There are at least 4 free C compilers that produce 16-bit
(real mode) code. I've used Watcom C and Turbo C. Both work OK.