Weird elf program that could be ran in both MS-DOS and unix?
-
- Member
- Posts: 70
- Joined: Tue Jul 14, 2020 4:01 am
- Libera.chat IRC: clementttttttttt
Weird elf program that could be ran in both MS-DOS and unix?
So I found this weird program in grub4dos, which is called "bootlace.com", that can be ran in both MS-DOS and unix, and google didn't help. I would like an explanation on how did it do that.
Re: Weird elf program that could be ran in both MS-DOS and u
Have you tried github? bootlace source.clementttttttttt wrote:So I found this weird program in grub4dos, which is called "bootlace.com", that can be ran in both MS-DOS and unix, and google didn't help.
Use the source Luke...!clementttttttttt wrote:I would like an explanation on how did it do that.
The DOS .com executable has no header, it just starts executing the code in real mode from the first byte. ELF needs a header, which starts with 4 magic bytes. Those magic bytes interpreted as real mode code gives:
Code: Select all
# ELF64 header backup here upto the end of file. Its length is 0x40.
.byte 0x7F, 0x45, 0x4C, 0x46 # ELF magic number
// 7F 45 = jg dos_entry_point
// 4C = decw %sp
// 46 = incw %si
Cheers,
bzt