Jump to content











Photo
- - - - -

Layout of Modern Syslinux


  • Please log in to reply
7 replies to this topic

#1 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 31 December 2012 - 07:05 PM

Here is a bit of detail regarding the on-disk and in-memory layout of modern Syslinux, such as 4.06 and 5.00.  This only applies to SYSLINUX- and EXTLINUX-based installations (the so-called "HDD variants").

 

  • ldlinux.bin's physical (file) layout:
    • Volume boot record (512 bytes).
      BIOS or an MBR is typically responsible for loading a VBR and executing its code.
      This contains code which the installer patches into a volume's actual boot record.  The code ranges are:
      • [0, 2]
      • [0x5A, 0x1FD]
    • 512 bytes of padding, used for alignment purposes
    • ldlinux.sys, which is:
      • "Sect1" code (494 bytes).  This contains a patch area, checksum, and code which is responsible for loading the rest of ldlinux.sys.
      • At the end of "Sect1" is enough room (18 bytes) for at least one extent (10 bytes), which the installer populates with the location of the next chunk of ldlinux.sys.  "Sect1" ranges from [0x400, 0x5FF] relative to ldlinux.bin or, relative to only ldlinux.sys, [0, 0x1FF]
      • The entire extent map (which includes the previously-described 18 bytes of "Sect1") ranges from [0x5EE, 0xD6E] relative to ldlinux.bin or, relative to only ldlinux.sys, [0x1EE, 0x96D] (1920 bytes).
      • The rest of the ldlinux.sys code is the rest of the Syslinux core.  It includes the filesystem drivers, for example.
        For Syslinux 5.00, some of what used to be "core" in Syslinux 4.06 has been moved out into ldlinux.c32, but this fact should be irrelevant, as long as that file is available in the filesystem that Syslinux is installed to.
  • ldlinux.bin's in-memory layout:
    • VBR @ 0:0x7C00 (or wherever else a crazy BIOS might put it)
    • 512 bytes of padding @ 0:0x7E00
    • ldlinux.sys @ 0:0x8000
      • "Sect1" @ 0:0x8000 (ranging [0x8000, 0x8200]
      • Extent pointers @ 0:0x81EE (ranging [0x81EE, 0x896D])
      • The rest of the code @ 0:0x896E

Enjoy!

 

So the sequence of events [roughly] goes:

  1. Syslinux VBR is loaded and executed by BIOS or MBR (or whatever else)
  2. VBR has an 8-byte LBA describing where the first sector (hence "Sect1") of ldlinux.sys lives.  It loads and executes this sector
  3. "Sect1" has at least one extent (8-byte LBA + length) describing where the next sector of ldlinux.sys lives.  It loads this sector.
  4. That next sector has more extents, so "Sect1" is able to load the rest of ldlinux.sys

:)



#2 Agent47

Agent47

    Frequent Member

  • Advanced user
  • 164 posts
  •  
    India

Posted 01 January 2013 - 01:25 PM

Hi,

 

I used isolinux to make multiboot cd using mkisofs or its GUI version CDRFE. I can use ISOLINUX V 4.05 and 4.06 without any problems but 5.00 is throwing ldlinux is missing errors when booting.As far as i know ldlinux is not needed for boot cds. Am i doing anything wrong or version 5 is broken?   

 



#3 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 01 January 2013 - 01:43 PM

There must have been some non-trivial changes between 4.06 and 5.00.

 

During the building of the COSMIAS syslinux.g4b I quickly found out how syslinux.com of the 5.00 does NOT work in DOS (where it should).

In any case - most probably thanks to the ldlynux.c32 (whatever it is/does) size of the .com has become 196,594 bytes (was 54,112 in 4.06).

Same thing is happening for the win32 Syslinux.exe, which was 82,432 in 4.06 and is in 5.00 527,872 :w00t:

 

I would like to remark how - independently from the fact that the DOS version doesn't run, the actual "installed" used space is for the 5.0 version:

  • ldlinux.sys 54,784 bytes <- in 4.06 it is 37,736 bytes
  • ldlinux.c32 428,010 bytes :w00t: <- in 4.06 this file does NOT exist

this latter precludes - in practice - the use of the new version on 1.44 floppy images (unless you want more that 1/3 of it occupied by the system loader)

 

For the moment I am putting the 5.00 aside.

@Sha0

Thank you for the details, the only problem is that they are:

  1. not detailed enough for me to be of use to make a grub4dos "installer batch"
  2. not entirely correct/exhaustive

What I quickly found out is:

the ONLY bytes that change from the "blank" ldlinux.sys in /core/ and an installed one are seemingly:

  1. bytes from 0x20 to 0x2C
  2. bytes from 0x01EE to 0x01EF <- these could actually be from 0x01EE to  0x01F5
  3. byte at 0x01F6 <- these could actually be from 0x01F6 to  0x01FD
  4. bytes from 0x3798 to 0x379F <- this is the sum of 0x01EE to 0x01EF + 0x01F6
  5. bytes from 0x37A0 to 0x37A7 <- this is 0x3798 to 0x379F +1 (most probably because I tested installs on freshly formatted images)

 

Additionally the "blank" ldlinux.sys is padded with 172 00's and then two identical between them sectors containing a "header" and a "signature" are added to the installed syslinux.sys, making it's size grow from 36,180 to 37,376 bytes.

These headers/signatures seem like being not changed on different installs.

 

Can you provide some more details?

 

 

 

:cheers:

Wonko



#4 ady

ady

    Frequent Member

  • Advanced user
  • 165 posts

Posted 01 January 2013 - 05:18 PM

@Agent 47

Off-topic:
As far as i know ldlinux is not needed for boot cds. Am i doing anything wrong or version 5 is broken?   

Syslinux (and its variants, including ISOLINUX) 5.xx requires ldlinux.c32 in addition to other file(s). Independently of "doing something wrong" (ie. not learning the new requirements / usage of Syslinux 5.xx - which is something not so simple to do since ATM there is very little clear organized documentation about 5.xx for the end user), there are at least 2 points to be considered by the "end user" (in this context, "end user" means, for example, the author of the syslinux.cfg files and/or the author of the ISOLINUX 5.00 image):

1_ There is no new feature (for the end user) between 4.06 and 5.00; and,
2_ Version 5.00 indeed has (known) bugs that are not present in 4.06, that will probably be solved in future releases.

So, if you still want to use Syslinux 5.00, I would suggest starting a new topic specific for your case.



 
 
For the moment I am putting the 5.00 aside.
Good call :), specially for usage with DOS. I could mention several reasons for this, but I'm not sure it would be on-topic.
 
@Sha0
...

Of course I am not Shao :), but it might help to know that the installers can be compressed with UPX. The *.c32 files in Syslinux 5.00 can't - at least not with UPX 3.08 :(.

#5 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 01 January 2013 - 08:28 PM

I used isolinux to make multiboot cd using mkisofs or its GUI version CDRFE. I can use ISOLINUX V 4.05 and 4.06 without any problems but 5.00 is throwing ldlinux is missing errors when booting.As far as i know ldlinux is not needed for boot cds. Am i doing anything wrong or version 5 is broken?

Please feel free to start a new thread for your topic.
 

There must have been some non-trivial changes between 4.06 and 5.00.

Yes.  4.06 to 5.00 has major changes.
 

During the building of the COSMIAS syslinux.g4b I quickly found out how syslinux.com of the 5.00 does NOT work in DOS (where it should).

D'oh!
 

In any case - ...<discussion about size>...

For the moment I am putting the 5.00 aside.

That's too bad about putting it aside. The size differences have been discussed in the mailing-list.
 

Thank you for the details,

You're welcome, I'm sure.
 

the only problem is that they are:

  • not detailed enough for me to be of use to make a grub4dos "installer batch"
  • not entirely correct/exhaustive
 

#1: Yes, I know. I haven't yet typed the exact details that you require. The first post is more general.

#2: I don't know what is "incorrect," but it's certainly not exhaustive.
 

What I quickly found out is:
the ONLY bytes that change from the "blank" ldlinux.sys in /core/ and an installed one are seemingly:

  • bytes from 0x20 to 0x2C
  • bytes from 0x01EE to 0x01EF <- these could actually be from 0x01EE to  0x01F5
  • byte at 0x01F6 <- these could actually be from 0x01F6 to  0x01FD
  • bytes from 0x3798 to 0x379F <- this is the sum of 0x01EE to 0x01EF + 0x01F6
  • bytes from 0x37A0 to 0x37A7 <- this is 0x3798 to 0x379F +1 (most probably because I tested installs on freshly formatted images)

#1: That's in the "Sect1" patch area, I think.
 
#2, #3: That's in the extent area.  Each extent pointer describes the location of a chunk of ldlinux.sys on the disk.  If the file is contiguous, there might only be one extent pointer.
 
#4, #5: I'll have to look those up to find out what they are.
 

Additionally the "blank" ldlinux.sys is padded with 172 00's and then two identical between them sectors containing a "header" and a "signature" are added to the installed syslinux.sys, making it's size grow from 36,180 to 37,376 bytes.
These headers/signatures seem like being not changed on different installs.

Padded where? I'm not familiar with a syslinux.sys.  If that's just a typographical error for ldlinux.sys, ok.

 

Can you provide some more details?

Yes.



#6 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1063 posts
  •  
    Belgium

Posted 01 January 2013 - 11:25 PM

That's too bad about putting it aside. The size differences have been discussed in the mailing-list.

The size issue will be probably fixed soon.

If you compile it yourself you can strip all the binaries to get small files again:

http://www.syslinux....ber/018889.html

 

Padded where? I'm not familiar with a syslinux.sys.  If that's just a typographical error for ldlinux.sys, ok.

I guess Wonko means at the end of the ldlinux.sys file.

At least in Syslinux 4.xx 2 ADV areas of 512 bytes are added to the end of ldlinux.sys (not necessarily appended right after ldlinux.sys on disk level).

At this place the installation directory is stored and also options like "boot once". It is loosely comparable with the default file in grub(4dos).


  • Sha0 likes this

#7 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 02 January 2013 - 11:21 AM

I guess Wonko means at the end of the ldlinux.sys file.

Yes, my bad :blush: typo!

I meant the "installed" ldlinux.sys.

 

At least in Syslinux 4.xx 2 ADV areas of 512 bytes are added to the end of ldlinux.sys (not necessarily appended right after ldlinux.sys on disk level).

At this place the installation directory is stored and also options like "boot once". It is loosely comparable with the default file in grub(4dos).

Yes, there are (in my "plain" install, i.e. run simply as Syslinux.com <drive>) two added sectors (and before that the 172 00's padding to make the /core/ldlinux.sys file end on sector boundary).

In my tests the two sectors were identical.

The acronym ADV stands for?

 

If I may they don't seem even loosely comparable with the default file in grub4dos (which is plain text), they are IMHO more directly comparable with the boot options set in the first bytes of the grub4dos MBR, if I get what they are for...

 

:cheers:

Wonko



#8 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 02 January 2013 - 11:39 AM

The acronym ADV stands for?

Auxiliary Data Vector.  Do-once-on-next-boot is stored there, along with other stuff.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users