ld linker error

Programming, for all ages and all languages.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

yeah, I'm using 7, I am an admin. I also have XP on my computer, but I accedentally wiped the boot files, and I cant find my installation disk.

Edit:Also, I cannot delete the 2 .exe's in the file. When using windows explorer it tells me I need permisson from an admin, which I am, and it still wont let me. When I use the command line it tells me that the files don't exist, when I use rm *.exe in the correct directory.
"For those about to rock, we salute you"
-Brian Johnson
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: ld linker error

Post by frank »

Try running bash as an admin by right clicking on the launcher and clicking Run as Administrator. Privileges in Vista and 7 are weird. Alternatively find the files in explorer right click on them go to the security tab and try to give your user all privileges.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

It wont let me change the permissions when i run as admin, even with the super-admin. Is there a way i can make the cross compiler with Ubuntu.
"For those about to rock, we salute you"
-Brian Johnson
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Re: ld linker error

Post by frank »

IIRC the compiler available on most Linux distros is suitable for OS deving. If you have any problems the instructions in the wiki for creating a cross compiler will most likely work under Ubuntu.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

Ok, It compiled correctly, now I just need to learn how to use gcc on linux, It isn't the same :(

EDIT:New problem, I think I might have whiped one of my hard drives, The one with all my media. My computer wouldn't book, so I put in my GParted Live CD and it said the entire drive was unallocated. My Ubuntu Disk didn't see the normal partitions either. So, before I have to repartiton my only hard drive with OS's I can boot from, and ALL of my media, I thought I would ask if there was any way to get my data back. I was also smart enough not to have any backups :cry: :cry: :cry: :cry: :cry:
"For those about to rock, we salute you"
-Brian Johnson
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: ld linker error

Post by pcmattman »

How so?

EDIT: Made my post, and then the preceding post was edited. I'm not responding to the data loss in this post.
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

Sorry about all of the memory loss, I know i keep changing the subject.
I changed the line, They both produce .o's. I'm getting a hex editor now to see if there is a difference.

EDIT: Yah, they look the same. The only difference is the header and footer on the elf, I'm not sure if thats what it is supposed to look like

EDIT2: I turned off my computer and my files were back :)
But time for the real problem.
The compiler works. I am trying to convert the .bat script to .sh, but it doesn't work, Help please

Code: Select all

#!/bin/bash

export TARGET=i586-elf
echo Now assembling, compiling, and linking your kernel:

nasm -f elf -o start.elf start.asm

# Remember this spot here: We will add 'gcc' commands here to compile C sources



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o scrn.o scrn.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o gdt.o gdt.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o idt.o idt.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o isrs.o isrs.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o irq.o irq.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o timer.o timer.c



$CCOMP/bin/$TARGET-gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o kb.o kb.c



# This links all your files. Remember that as you add *.o files, you need to

# add them after start.o. If you don't add them at all, they won't be in your kernel!

$CCOMP/bin/$TARGET-ld -T link.ld -o kernel.bin start.elf main.o scrn.o gdt.o idt.o isrs.o irq.o timer.o kb.o

echo Cleaning up object files...

rm *.o

echo Done!

exit 0
This is what I get when it runs

Code: Select all

Now assembling, compiling, and linking your kernel:
'asm: fatal: unable to open input file `start.asm
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
: No such file or directory
i586-elf-gcc: no input files
: command not found
/home/gerik/cross/cross/bin/i586-elf-ld: start.elf: No such file: No such file or directory
Cleaning up object files...
rm: cannot remove `*.o\r': No such file or directory
Done!
the gcc, and nasm (i dont feel like compiling all of the gcc files, so I havent tested ld) commands all work by themselves, but not in the script.
thanks

EDIT3:I'm adding a second problem
I tried installing bochs on Ubuntu and it failed, again. It failed at the make command, here is the error

Code: Select all

proc_ctrl.cc:654: error: ‘CheckPDPTR’ was not declared in this scope
proc_ctrl.cc:668: error: ‘CheckPDPTR’ was not declared in this scope
make[1]: *** [proc_ctrl.o] Error 1
make[1]: Leaving directory `/home/gerik/Desktop/bochs-2.4.1/cpu'
make: *** [cpu/libcpu.a] Error 2
thanks again.
"For those about to rock, we salute you"
-Brian Johnson
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: ld linker error

Post by Solar »

Problem 1 - your script: Put a line "pwd" at its beginning to see which directory it is running in. It looks as if it cannot find your sources...

Problem 2 - That's most likely not the first (i.e., consequential) error message. Probably some message about some header file not found, earlier?

Suggestion: Once you got your script to compile, it's probably a good time to look at the Makefile tutorial. Build scripts suck...
Every good solution is obvious once you've found it.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: ld linker error

Post by pcmattman »

I tried installing bochs on Ubuntu and it failed, again. It failed at the make command, here is the error
You don't need to compile Bochs on Ubuntu. You can use apt-get (or the Synaptic Package Manager) to install Bochs.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: ld linker error

Post by Solar »

...including debugging support? Most binary distros I know of don't compile it in.
Every good solution is obvious once you've found it.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: ld linker error

Post by pcmattman »

Ah, now that's a good reason to compile. I had forgotten about that :)
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

OK, I have bochs working. Thanks to pcmattman.

Ok I almost have my makefile working, but when I link the files it cannot find the routines in the a assembler code from C. I tried changing the .elf back to .o, but that gave me the same error I started with, the file not recognized error.
I think the problem is in the link.ld script, so i will include it too.
here is the error I got
I'm only going to list a couple because they are all the same

Code: Select all

/home/gerik/cross/cross/bin/i586-elf-ld: warning: cannot find entry symbol start; defaulting to 00100000
start.elf:(.text+0x2d): undefined reference to `_main'
start.elf:(.text+0x39): undefined reference to `_gp'
start.elf:(.text+0x56): undefined reference to `_idtp'
start.elf:(.text+0x1a6): undefined reference to `_fault_handler'
start.elf:(.text+0x272): undefined reference to `_irq_handler'
gdt.o: In function `gdt_install':
gdt.c:(.text+0xbb): undefined reference to `gdt_flush'
idt.o: In function `idt_install':
idt.c:(.text+0x5d): undefined reference to `idt_load'
isrs.o: In function `isrs_install':
isrs.c:(.text+0x3e): undefined reference to `isr0'
isrs.c:(.text+0x51): undefined reference to `isr1'
isrs.c:(.text+0x67): undefined reference to `isr2'
irq.o: In function `irq_install':
irq.c:(.text+0x105): undefined reference to `irq0'
irq.c:(.text+0x118): undefined reference to `irq1'
irq.c:(.text+0x12e): undefined reference to `irq2'
irq.c:(.text+0x141): undefined reference to `irq3'

and remeber the is the same for all of my IRS's and IRQ's
Attachments
link.ld
(374 Bytes) Downloaded 160 times
"For those about to rock, we salute you"
-Brian Johnson
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ld linker error

Post by Combuster »

Are you mixing underscore and non-underscore names in your code (there should be no leading underscores in assembly files)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Gman
Member
Member
Posts: 37
Joined: Tue Jun 23, 2009 10:12 pm

Re: ld linker error

Post by Gman »

Ok, I removed al of the underscores, and it didn't do much :(

I'll post the result. All of the functions listed are called from C and are written the the .asm file

Code: Select all

gdt.o: In function `gdt_install':
gdt.c:(.text+0xbb): undefined reference to `gdt_flush'
idt.o: In function `idt_install':
idt.c:(.text+0x5d): undefined reference to `idt_load'
isrs.o: In function `isrs_install':
isrs.c:(.text+0x3e): undefined reference to `isr0'
isrs.c:(.text+0x51): undefined reference to `isr1'
isrs.c:(.text+0x67): undefined reference to `isr2'
isrs.c:(.text+0x7a): undefined reference to `isr3'
isrs.c:(.text+0x90): undefined reference to `isr4'
isrs.c:(.text+0xa3): undefined reference to `isr5'
isrs.c:(.text+0xb9): undefined reference to `isr6'
isrs.c:(.text+0xcc): undefined reference to `isr7'
isrs.c:(.text+0xe2): undefined reference to `isr8'
isrs.c:(.text+0xf5): undefined reference to `isr9'
isrs.c:(.text+0x10b): undefined reference to `isr10'
isrs.c:(.text+0x11e): undefined reference to `isr11'
isrs.c:(.text+0x134): undefined reference to `isr12'
isrs.c:(.text+0x147): undefined reference to `isr13'
isrs.c:(.text+0x15d): undefined reference to `isr14'
isrs.c:(.text+0x170): undefined reference to `isr15'
isrs.c:(.text+0x186): undefined reference to `isr16'
isrs.c:(.text+0x199): undefined reference to `isr17'
isrs.c:(.text+0x1af): undefined reference to `isr18'
isrs.c:(.text+0x1c2): undefined reference to `isr19'
isrs.c:(.text+0x1d8): undefined reference to `isr20'
isrs.c:(.text+0x1eb): undefined reference to `isr21'
isrs.c:(.text+0x201): undefined reference to `isr22'
isrs.c:(.text+0x214): undefined reference to `isr23'
isrs.c:(.text+0x22a): undefined reference to `isr24'
isrs.c:(.text+0x23d): undefined reference to `isr25'
isrs.c:(.text+0x253): undefined reference to `isr26'
isrs.c:(.text+0x266): undefined reference to `isr27'
isrs.c:(.text+0x27c): undefined reference to `isr28'
isrs.c:(.text+0x28f): undefined reference to `isr29'
isrs.c:(.text+0x2a5): undefined reference to `isr30'
isrs.c:(.text+0x2b8): undefined reference to `isr31'
irq.o: In function `irq_install':
irq.c:(.text+0x105): undefined reference to `irq0'
irq.c:(.text+0x118): undefined reference to `irq1'
irq.c:(.text+0x12e): undefined reference to `irq2'
irq.c:(.text+0x141): undefined reference to `irq3'
irq.c:(.text+0x157): undefined reference to `irq4'
irq.c:(.text+0x16a): undefined reference to `irq5'
irq.c:(.text+0x180): undefined reference to `irq6'
irq.c:(.text+0x193): undefined reference to `irq7'
irq.c:(.text+0x1a9): undefined reference to `irq8'
irq.c:(.text+0x1bc): undefined reference to `irq9'
irq.c:(.text+0x1d2): undefined reference to `irq10'
irq.c:(.text+0x1e5): undefined reference to `irq11'
irq.c:(.text+0x1fb): undefined reference to `irq12'
irq.c:(.text+0x20e): undefined reference to `irq13'
irq.c:(.text+0x224): undefined reference to `irq14'
irq.c:(.text+0x237): undefined reference to `irq15'
"For those about to rock, we salute you"
-Brian Johnson
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: ld linker error

Post by Combuster »

But are you still linking those files?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply