exeption handler

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.
Post Reply
sds2017
Member
Member
Posts: 61
Joined: Tue Jul 05, 2011 10:05 am

exeption handler

Post by sds2017 »

I have been working on a software exception handler for a while and cannot get it working and I keep on getting an error that says "interrupts.o: file not recognized: File format not recognized"(interrupts.o is a assembled version of my asm file interrupt.asm). I use nasm and I linked my c files and that one asm file.
Please help.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: exeption handler

Post by AJ »

Hi,

Are you using the GCC Cross-Compiler detailed on the wiki? If so, your C files are being compiled in to 32 bit ELF object files and this is what ld also expects. You therefore need to tell your assembler to output in the same format. In nasm, you can use -f elf on the command line.

If you aren't using the GCC Cross-Compiler, you need to give more detail in the question (or start using the GCC Cross-Compiler!).

Cheers,
Adam

Edit: If you are using a 64 bit cross compiler, you would use -f elf64. For all supported nasm formats, use "nasm -hf" - basically, get NASM to output the same object file format as your compiler.
sds2017
Member
Member
Posts: 61
Joined: Tue Jul 05, 2011 10:05 am

Re: exeption handler

Post by sds2017 »

Thanks for your reply but I'm compiling it into a flat binary and I'm not using a gcc cross compiler; I'm just using the standard gcc. How would I use the -f command to compile a flat binary?
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: exeption handler

Post by Combuster »

but I'm compiling it into a flat binary
No you are not. You are compiling to an object file, you are linking object files into a flat binary. You do not want to emit flat binaries from either gcc nor nasm because you would not be able to link them afterwards.


Oh and, you also earned a "learn to read" complaint for the following:
AJ's Linked page wrote:Creating a dedicated (cross-)compiler for your OS development work can save you many headaches. If ... your compiler and your assembler can't agree on binary formats
and
AJ wrote:For all supported nasm formats, use "nasm -hf"
Try to make it a habit to read through all relevant and less relevant material carefully because laziness won't get you anywhere and people here are rather keen on reminding you of that.
"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