NEED HELP WITH LINKER!! :D

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.
Locked
anti149
Posts: 15
Joined: Mon Feb 28, 2011 5:42 pm

NEED HELP WITH LINKER!! :D

Post 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!
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)
User avatar
thepowersgang
Member
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

Post 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
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
anti149
Posts: 15
Joined: Mon Feb 28, 2011 5:42 pm

Re: NEED HELP WITH LINKER!! :D

Post 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.
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)
User avatar
piranha
Member
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

Post 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
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
TylerH
Member
Member
Posts: 285
Joined: Tue Apr 13, 2010 8:00 pm
Contact:

Re: NEED HELP WITH LINKER!! :D

Post by TylerH »

You're calling printf. You can't call a libc function that you haven't implemented yourself from your kernel.
anti149
Posts: 15
Joined: Mon Feb 28, 2011 5:42 pm

Re: NEED HELP WITH LINKER!! :D

Post 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?
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)
User avatar
piranha
Member
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

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
anti149
Posts: 15
Joined: Mon Feb 28, 2011 5:42 pm

Re: NEED HELP WITH LINKER!! :D

Post 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)
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)
User avatar
thepowersgang
Member
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

Post 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)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: NEED HELP WITH LINKER!! :D

Post by Brynet-Inc »

This was an obvious troll, but, continue.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
anti149
Posts: 15
Joined: Mon Feb 28, 2011 5:42 pm

Re: NEED HELP WITH LINKER!! :D

Post by anti149 »

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)
Locked