GCC "binary" output
Posted: Sun Dec 05, 2010 6:26 am
My operating system uses a custom binary format, called "DEF", and it is pretty simple.
It assumes that everything (code, data, bss) is loaded at address 0xC0100000. Every DEF file starts with a header. It was easy to get NASM to create DEF binaries. All I did was use the '-f bin' option so that it puts everything in the same place. Then I had the following code to create a program that would trigger INT3. I manually put the header, ORG and BITS directive in:
Simple. The problem is that now I want to make C binaries, and I could not find any way of putting everything in the same place. I tried a linker script, but it says that 'bin output format does not support external references'. So what do I do?
The question is basically: how do i get gcc to compile a program and assume that code, data and bss sections all start at 0xC0100000. And make it export my own executable format.
It assumes that everything (code, data, bss) is loaded at address 0xC0100000. Every DEF file starts with a header. It was easy to get NASM to create DEF binaries. All I did was use the '-f bin' option so that it puts everything in the same place. Then I had the following code to create a program that would trigger INT3. I manually put the header, ORG and BITS directive in:
Code: Select all
org 0xC0100000
bits 32
db 'ADEF'
dd 7
db 0, 0, 1
db 'init'
resb 16 ; padding name 'init'
db 'PROJECT DARMA'
resb 7 ; padding developer name
dd _start
db 32
resb 44
_start:
mov eax,[_start]
int 3
jmp $
The question is basically: how do i get gcc to compile a program and assume that code, data and bss sections all start at 0xC0100000. And make it export my own executable format.