help me loading binary files

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

help me loading binary files

Post by digo_rp »

guys right now I can switch graphics, I got multitasking using stack based taskswitching, I got ring3, memory management using bitmap, so, I need
to understand a thing.

this is my link.ld that I use to create my kernel.bin

OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}

now is my question:
to create a program.bin to execute at my o.s
do I have to change these line: phys = 0x00100000; to
phys = 0x00000000; ??? I cannot understand that line..
is this something like org 100 from msdos .com file ?

and that program.bin need to be started like our kernel ?

using start.asm that call main from .c source ?

please guys help me... in case anyone wants to take a look at my source I´ll be so glad to share...
User avatar
Walling
Member
Member
Posts: 158
Joined: Mon Dec 04, 2006 6:06 am
Location: Berlin, Germany

Re: help me loading binary files

Post by Walling »

digo_rp wrote: now is my question:
to create a program.bin to execute at my o.s
do I have to change these line: phys = 0x00100000; to
phys = 0x00000000; ??? I cannot understand that line..
is this something like org 100 from msdos .com file ?
Yes, it is like org 100. It is the physical memory address you want to load you program.bin at. It is so because you link your file to binary format, which doesn't contain any symbolic information. You will have to load it at the address it is linked to. If however you want to load and link it dynamically you have to use a format containing symbolic information like ELF, COFF or maybe A.OUT can do the job.
digo_rp wrote:and that program.bin need to be started like our kernel ?
I suppose your kernel have to load the program.bin file into memory at the correct location, create a new process, which in fact jumps to the location and executes it. For that to work you need a disk driver and some sort of file system. As a beginning you can just include the content of program.bin in your kernel so it gets loaded in memory, and then relocate (move) it to the correct location in memory, when executing it.

Maybe I missed the point. If so try to reformulate your question. :)
Post Reply