Page 2 of 3
Re: ld linker error
Posted: Thu Jun 25, 2009 9:08 am
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.
Re: ld linker error
Posted: Thu Jun 25, 2009 11:33 am
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.
Re: ld linker error
Posted: Thu Jun 25, 2009 12:45 pm
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.
Re: ld linker error
Posted: Thu Jun 25, 2009 3:15 pm
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.
Re: ld linker error
Posted: Thu Jun 25, 2009 4:59 pm
by Gman
Re: ld linker error
Posted: Thu Jun 25, 2009 5:33 pm
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.
Re: ld linker error
Posted: Thu Jun 25, 2009 6:04 pm
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.
Re: ld linker error
Posted: Fri Jun 26, 2009 2:06 am
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...
Re: ld linker error
Posted: Fri Jun 26, 2009 4:02 am
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.
Re: ld linker error
Posted: Fri Jun 26, 2009 4:34 am
by Solar
...including debugging support? Most binary distros I know of don't compile it in.
Re: ld linker error
Posted: Fri Jun 26, 2009 4:39 am
by pcmattman
Ah, now that's a good reason to compile. I had forgotten about that
Re: ld linker error
Posted: Fri Jun 26, 2009 9:53 am
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
Re: ld linker error
Posted: Fri Jun 26, 2009 4:30 pm
by Combuster
Are you mixing underscore and non-underscore names in your code (there should be no leading underscores in assembly files)
Re: ld linker error
Posted: Fri Jun 26, 2009 6:20 pm
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'
Re: ld linker error
Posted: Sat Jun 27, 2009 6:44 am
by Combuster
But are you still linking those files?