Page 1 of 1
NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:22 pm
by anti149
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!
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:27 pm
by thepowersgang
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
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:34 pm
by anti149
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.
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:49 pm
by piranha
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
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:50 pm
by TylerH
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
Posted: Fri Mar 04, 2011 8:51 pm
by anti149
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?
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:53 pm
by piranha
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?
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?
-JL
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 8:56 pm
by anti149
OK do you have any suggestions or good tutorials to learn C kernel basics? (Preferably compatible with widows my Linux machine is down)
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 9:26 pm
by thepowersgang
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)
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 9:37 pm
by Brynet-Inc
This was an obvious troll, but, continue.
Re: NEED HELP WITH LINKER!! :D
Posted: Fri Mar 04, 2011 9:39 pm
by anti149
Oh nvm I figured it out without using the C library making my own headers works fine hanks for your help though!