flat assembler
Message board for the users of flat assembler.
Index
> Main > [ FIXED and correct format : COFF/MSCOFF]Mixing Fasm and GCC |
Author |
|
revolution 26 Mar 2008, 18:40
See here
|
|||
26 Mar 2008, 18:40 |
|
vid 26 Mar 2008, 18:41
i suspect "ESP+36" is wrong, or it's some calling standard issue. Are you sure ccall is used - check out assembly listing of kernel_main().
by the way... since when does GCC use COFF format??? Doesn't it use ELF? |
|||
26 Mar 2008, 18:41 |
|
White-spirit 26 Mar 2008, 19:55
The main problem isn't the "undefined reference to 'get_vendor'" but it's that the kernel and the fasm code compiles fine and without error/warnings messages .
When i test the kernel with Bochs, it reboots after printing ">CPU Vendor : " . And yes, i tested COFF, MS COFF and ELF formats ( i'm working on Cygwin ) but it's always the same . I tested also : Code: format coff public get_vendor as '_get_vendor' get_vendor: jmp $ ; DEBUG INSTRUCTION pusha xor eax,eax ; eax <== 0 : get vendor ID cpuid mov eax, [esp+36] mov [eax], ebx mov [eax+4], edx mov [eax+8], ecx mov byte [eax+12],0 popa xor eax,eax ret to see if it's only a bad stack manipulation but it still reboot . Help me please =) Thanks . |
|||
26 Mar 2008, 19:55 |
|
vid 26 Mar 2008, 20:38
did you look at kernel_main() assembly listing, as I told you?
|
|||
26 Mar 2008, 20:38 |
|
rugxulo 26 Mar 2008, 22:25
vid wrote: by the way... since when does GCC use COFF format??? Doesn't it use ELF? I know DJGPP (alone) uses COFF, but I dunno about Cygwin or MingW, probably MS COFF (since I seem to remember hearing it didn't really completely support ELF). |
|||
26 Mar 2008, 22:25 |
|
Goplat 27 Mar 2008, 00:06
Maybe the bootloader didn't set SS equal to DS? gcc assumes a "flat" memory model, i.e. DS, ES, and SS all need to be the same segment or at least have the same base address. (It might also require that CS have the same base address; I'm not sure)
Edit: never mind, didn't see your second post. |
|||
27 Mar 2008, 00:06 |
|
White-spirit 27 Mar 2008, 12:19
I use a i586-elf cross gcc so yes , the output is ELF ^^'
And no , i don't think that there's a problem with my bootloader, it jumps fine to the kernel which prints "> CPU Vendor : " . |
|||
27 Mar 2008, 12:19 |
|
White-spirit 27 Mar 2008, 16:27
Hmm, i changed the compilation instructions from :
Code: fasm bootsector.asm bootsector.bin fasm cpuid.asm cpuid.o gcc -ffreestanding -nostdinc -mno-stack-arg-probe -c kernel.c -o kernel.o ld -i -e kernel_main -Ttext 0x1000 -o kernel cpuid.o kernel.o objcopy -R .note -R .comment -S -O binary kernel kernel.bin to Code: fasm bootsector.asm bootsector.bin fasm cpuid.asm cpuid.o gcc -ffreestanding -nostdinc -mno-stack-arg-probe -c kernel.c -o kernel.o ld -e kernel_main -Ttext 0x1000 -o kernel cpuid.o kernel.o ld -i -e kernel_main -Ttext 0x1000 -o kernel cpuid.o kernel.o objcopy -R .note -R .comment -S -O binary kernel kernel.bin And now, ld shows me an error message like this instead of linking both files : Code: ld: Relocatable linking with relocations from format coff-i386 (cpuid.o) to form at elf32-i386 (kernel) is not supported So it's an issue with the format ? if i change the fasm output format from "ms coff" to "elf", Bochs boots the kernel fine without crashing, but it executes the fasm program instead of loading the kernel ... it's a problem with the start address ? Tell me if you need my bootloader's code . Thanks . PS : i forgot to tell that i've never mixed an assembler program with C x') |
|||
27 Mar 2008, 16:27 |
|
White-spirit 27 Mar 2008, 17:21
Sorry, it works fine with MS COFF ( and COFF ) , the only problem is that the bootloader loads only 2 sectors but my kernel is too big ( 10 sectors ) ^^"
|
|||
27 Mar 2008, 17:21 |
|
vid 27 Mar 2008, 22:39
nice one
have fun with OSdev in future |
|||
27 Mar 2008, 22:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.