hi,
can I link a 16bit 8086 program with ld? What output formats are possible? Is it possible to use elf file format?
I need this in order to create support for 16bit real-mode programs in my 32bit protected-mode OS.
ld and 16bit programs
Re:ld and 16bit programs
I'm not sure if ld understands 16-bit code (I'm pretty sure it doesn't understand segmentation, though). There's dev86 (http://www.cix.co.uk/~mayday/), which includes a 16-bit assembler, linker, C compiler and libc, and is apparently used to make Linux's setup.S, but I haven't tried it myself.bluecode wrote: hi,
can I link a 16bit 8086 program with ld? What output formats are possible? Is it possible to use elf file format?
I need this in order to create support for 16bit real-mode programs in my 32bit protected-mode OS.
Re:ld and 16bit programs
LD can link 16-bit programs, but I'm not entirely sure about all the details. I can tell you that it can only handle 0-based segments (so that would leave 0x0000, 0x1000 etc.), and that it freaks out when you don't use 0x0000 as base (it gives warnings about every relocation). I've used it for my boot loader, which I've moved to 0x8000 for that reason.
I don't think you really want to use it, but if you use 0-based segments it's ok I guess.
I don't think you really want to use it, but if you use 0-based segments it's ok I guess.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ld and 16bit programs
- real mode programs in your 32-bit OS ?? are you _sure_ you really want that while we now have quite complete, open-source x86 emulators that can also emulate good old graphic cards, good old soundblasters, etc ?
- using ELF for 16-bit ? no, unlikely. ELF is designed for 32-bit and 64-bit, but it doesn't even has a 'target architecture' code for 16 bits x86 ...
- the most common 16-bit format are OBJ, COM and EXE (MZ). Old compilers and multi-environment assemblers (such as NASM) support it. I use EXE-MZ for my bootloader (later converted into a flat binary by some tool of mine) and i use ALINK (http://alink.sourceforge.net/) to create that EXE file. Despite it's initially a DOS program, ALINK can be quite easily adapted to Linux (and probably other unix). All those stuff should be found in my CVS under tools/bootools and tools/asm
- using ELF for 16-bit ? no, unlikely. ELF is designed for 32-bit and 64-bit, but it doesn't even has a 'target architecture' code for 16 bits x86 ...
- the most common 16-bit format are OBJ, COM and EXE (MZ). Old compilers and multi-environment assemblers (such as NASM) support it. I use EXE-MZ for my bootloader (later converted into a flat binary by some tool of mine) and i use ALINK (http://alink.sourceforge.net/) to create that EXE file. Despite it's initially a DOS program, ALINK can be quite easily adapted to Linux (and probably other unix). All those stuff should be found in my CVS under tools/bootools and tools/asm
Re:ld and 16bit programs
I don't want to run real-mode programs, I want a VBE driver or do you guys use the protected-mode interface for that task. My OS will only allow a driver to run in vm8086.Pype.Clicker wrote:- real mode programs in your 32-bit OS ?? are you _sure_ you really want that while we now have quite complete, open-source x86 emulators that can also emulate good old graphic cards, good old soundblasters, etc ?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:ld and 16bit programs
no, virtually all of us that have VBE use vm86 for it. However, afaik, only BI has a 'real' program that has 16-bit code for that ... The most common approach (which the OSLib can help you to build) consist of
- telling VM86 "task" to start execution at the first byte of INT 0x10
- writing on the stack that the return address of that interrupt call is a 'magic address' (that usually contains a 'hlt' command), which the vm monitor interpretes as 'bios interrupt completed'
- telling VM86 "task" to start execution at the first byte of INT 0x10
- writing on the stack that the return address of that interrupt call is a 'magic address' (that usually contains a 'hlt' command), which the vm monitor interpretes as 'bios interrupt completed'
Re:ld and 16bit programs
I'll follow the way the great Jedi beyond infinity ;D
and use real vm86 tasks and stick with raw binaries. I don't want another executable loader in my kernel.
and use real vm86 tasks and stick with raw binaries. I don't want another executable loader in my kernel.