Cross Compilier problem
Same problem...
Code: Select all
c:/djgpp/bin/ld.exe: warning: cannot find entry symbol _Stage2; defaulting to 000018f8
Heres the symbol table for KERNEL.o:
As you can see, _Stage2 is there. ...Why cant LD see it?
Code: Select all
C:\djgpp\MicroOS_Main\Kernel\KERNEL.o: file format coff-go32-exe
SYMBOL TABLE:
[ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000016 Main.c
File
[ 2](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00002000 __xPos
[ 3](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00002004 __yPos
[ 4](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00002008 LC0
[ 5](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000193c __clrscr
[ 6](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001a3c __printf
[ 7](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001936 __Die
[ 8](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001956 L5
[ 9](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001961 L8
[ 10](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001980 L6
[ 11](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001996 __putch
[ 12](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000019b7 L11
[ 13](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000019dc L10
[ 14](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001a3a L9
[ 15](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001a70 __gotoxy
[ 16](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001a80 L16
[ 17](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001a8d L17
[ 18](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001a9a L18
[ 19](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00001aa7 L19
[ 20](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00001900 .text
[ 21](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00002000 .data
[ 22](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000001b ..\MicroOS_Mai
File
[ 24](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00001ac0 .text
AUX scnlen 0x7 nreloc 1 nlnno 0
[ 26](sec -1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 .absolut
[ 27](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002000 djgpp_first_dtor
[ 28](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002000 djgpp_last_ctor
[ 29](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002000 djgpp_last_dtor
[ 30](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002010 edata
[ 31](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002000 djgpp_first_ctor
[ 32](sec 0)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _Stage2
[ 33](sec 4)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 _rodata
[ 34](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001930 _foo
[ 35](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 end
[ 36](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001ac7 etext
[ 37](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 _bss
[ 38](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 __end
[ 39](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 bss
[ 40](sec 4)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 __rodata
[ 41](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002200 data
[ 42](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000200c ___EH_FRAME_BEGIN__
[ 43](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002200 __data
[ 44](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 __bss
[ 45](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00002200 _data
[ 46](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 _end
[ 47](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001c00 code
[ 48](sec 4)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00003000 rodata
[ 49](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001c00 __code
[ 50](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001c00 _code
[ 51](sec 2)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000200c ___EH_FRAME_END__
[ 52](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001900 _main
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
After setting it, I dont get the warning anymoreI think that if you change the entry point from _Stage2 to 0x00000000 it might just work.
_Stage2 doesnt get executed though...
The basic problem here I am trying to solve is defining routines
before main. I could define it after just fine, before main, it triple faults.
I learned through these forums a common solution is creating an assembly
stub (In my case its _Stage2). This is what I am trying to accomplish.
I suspect that _main is being loaded at 0x1000 (Not _Stage2), as the
kernel does execute.
Heres _Stage2 as of now:
Code: Select all
; We should be in pmode, so insure code is 32bit
[BITS 32]
extern _main
global _Stage2
; ----------------------------------------- Second stage loader
_Stage2:
; might need to setup stack here
; Give control to kernel
hlt
call _main
cli ; Should never get here
hlt
instruction should have been executed (It wasnt though)
My kernel runs fine, which tells me _main() is being executed just fine...
What versions of GCC and LD do you have?
Do you have a download link?
I have gcc v. 3.1, and LD v. 2.11.2. After noticing my LD doesnt
support the -i option, I am suspecting its my version of DJGPP..
I set the stack in my bootloader:
I am currently assembling my bootloader with binary output:
Then I assembled my Stage2 (Asm stub) with COFF format:
(I should note I have also tried ELF format, but same problems..)
Next I compilie my C kernel:
Then link the kernel with Stage2 to produce KERNEL:
Then objcopy:
Then I combine my BOOT.bin with KERNEL.bin to produce an image:
I am posting this so you know what I was doing (and thinking).
And to see if there could be problems with my setup.
(I am going to look through that tutorial, and see if I can find anything)
Code: Select all
;------------------------------------------ Enter: Protected Mode ---------
[BITS 32]
EnterStage2:
; setup 32bit registers
mov ax, 10h
mov ds, ax
mov ss, ax
mov esp, 90000h ; stack begins from 90000h
; stop floppy drive controller
xor al, al
mov dx, 03f2h ; port number
out dx, al
; jump to second stage bootloader (0:01000h)
jmp 08h:1000h
Code: Select all
nasm -f bin BOOT.asm -o BOOT.bin
(I should note I have also tried ELF format, but same problems..)
Code: Select all
nasm -f coff Stage2.asm -o Stage2.o
Code: Select all
gcc -ffreestanding -nostdlib -nostartfiles -fwritable-strings -c -o Main.o Main.c
Code: Select all
ld Link.ld -o KERNEL.o Main.o Stage2.o
Code: Select all
objcopy -R .note -R .comment -S -O binary KERNEL.o KERNEL.bin
Code: Select all
makeboot Floppy.img BOOT.bin KERNEL.bin
And to see if there could be problems with my setup.
(I am going to look through that tutorial, and see if I can find anything)
lol!Stage2.o should be linked first because it's the one containing the entry point.
I have just thought that when I was looking at my post, tried it,
and it works! _Stage2 is being executed, and I can now define
routines before main!!
(It litterally took about 2months, and all I had to do was a simple
swap! Sheesh!)--Makes me look bad
Thanks to everyone SO much!!
I am going to see if my pointers/strings are still missed up now...