NEED HELP WITH LINKER!! :D
NEED HELP WITH LINKER!! :D
Hay so I found a problem that is preventing me to compile my kernel :O the boot-loader and main.c compile fine (I am using header files in my C main), BUT when I try to link them to make kernel.bin it messes up here is my linker file(just using the one from Bran's kernel tutorial):
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
and here is how I'm compiling the linker in batch file: ld -T link.ld -o kernel.bin start.o main.o
what am I doing wrong should I use a make file instead??
thanx for help!
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
and here is how I'm compiling the linker in batch file: ld -T link.ld -o kernel.bin start.o main.o
what am I doing wrong should I use a make file instead??
thanx for help!
I've noticed lately that the paranoid fear of computers becoming intelligent and taking over the world has almost entirely disappeared from the common culture. Near as I can tell, this coincides with the release of MS-DOS. (Larry DeLuca)
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: NEED HELP WITH LINKER!! :D
Forum rules, read them.
1. How does it mess up? Does the linker error, does it end up with an invalid binary?
2. Forum Rules, read them
1. How does it mess up? Does the linker error, does it end up with an invalid binary?
2. Forum Rules, read them
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: NEED HELP WITH LINKER!! :D
Sry here is the error it displays in my batch file when it reaches the linker part: main.o:main.c:(.text+0xe): undefined reference to 'printf'
but my header file and library have the function and it compiles fine in GCC just the linker has problems.
but my header file and library have the function and it compiles fine in GCC just the linker has problems.
I've noticed lately that the paranoid fear of computers becoming intelligent and taking over the world has almost entirely disappeared from the common culture. Near as I can tell, this coincides with the release of MS-DOS. (Larry DeLuca)
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: NEED HELP WITH LINKER!! :D
Do you have your own version of printf? You cannot use the C library's version of printf in your kernel. Any and all library functions that you call must be written and compiled in with the kernel.'
Edit: Oh, and your topic title? No. Don't do that. Make an intelligent title next time.
-JL
Edit: Oh, and your topic title? No. Don't do that. Make an intelligent title next time.
-JL
Last edited by piranha on Fri Mar 04, 2011 8:52 pm, edited 1 time in total.
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: NEED HELP WITH LINKER!! :D
You're calling printf. You can't call a libc function that you haven't implemented yourself from your kernel.
Re: NEED HELP WITH LINKER!! :D
I cant use C library? wow! (Me new to kernels in C used to ASM & C#) so I have to make my own cant use C library?
I've noticed lately that the paranoid fear of computers becoming intelligent and taking over the world has almost entirely disappeared from the common culture. Near as I can tell, this coincides with the release of MS-DOS. (Larry DeLuca)
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: NEED HELP WITH LINKER!! :D
Okay, my turn: No. You cannot use the C library. Perhaps a little more research is in order before you write an OS in C?anti149 wrote:I cant use C library? wow! (Me new to kernels in C used to ASM & C#) so I have to make my own cant use C library?
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: NEED HELP WITH LINKER!! :D
OK do you have any suggestions or good tutorials to learn C kernel basics? (Preferably compatible with widows my Linux machine is down)
I've noticed lately that the paranoid fear of computers becoming intelligent and taking over the world has almost entirely disappeared from the common culture. Near as I can tell, this coincides with the release of MS-DOS. (Larry DeLuca)
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: NEED HELP WITH LINKER!! :D
Again Forum Rules, read them
And, you see that link at the top of the page "The OSDev.org Wiki - Got a question? Search this first!"? Click on it.
Edit: (I seem to be a little snappy today, no idea why)
And, you see that link at the top of the page "The OSDev.org Wiki - Got a question? Search this first!"? Click on it.
Edit: (I seem to be a little snappy today, no idea why)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: NEED HELP WITH LINKER!! :D
This was an obvious troll, but, continue.
Re: NEED HELP WITH LINKER!! :D
Oh nvm I figured it out without using the C library making my own headers works fine hanks for your help though!
I've noticed lately that the paranoid fear of computers becoming intelligent and taking over the world has almost entirely disappeared from the common culture. Near as I can tell, this coincides with the release of MS-DOS. (Larry DeLuca)