creating raw executables with gas

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
jimmyhilldrix
Posts: 2
Joined: Sat Jan 12, 2008 5:59 pm

creating raw executables with gas

Post by jimmyhilldrix »

Hello all,

Sorry if this question is old, I searched around for a solution but could find one.

I'm attempting to write all of my boot sector code using the gnu assembler. The problem is that when I assemble and link, it creates a Linux executable. I just want it to create a raw executable that can be run on system start up.

Can some one tell me the assembler and linker directives that I need to pass to get this output?

Thanks,
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:

Post by Combuster »

have you asked LD for a list of options?
"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 ]
jimmyhilldrix
Posts: 2
Joined: Sat Jan 12, 2008 5:59 pm

Post by jimmyhilldrix »

Yes, I did look at the linker, although I've been under the impression that the assembler is what's going to be adding the ELF stuff. Either way nothing there popped out at me.

Is it the Linker that I need to be looking at?
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:

Post by Combuster »

jimmyhilldrix wrote:Yes, I did look at the linker, although I've been under the impression that the assembler is what's going to be adding the ELF stuff. Either way nothing there popped out at me.

Is it the Linker that I need to be looking at?
The linker would have told you among others:
ld --help wrote: --oformat TARGET Specify target of output file
(...)
i386-elf-ld: supported targets: elf32-i386 coff-i386 elf32-little elf32-big srec symbolsrec tekhex binary ihex
Which should get you where you want to be :wink:
"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 ]
2dum2code
Posts: 8
Joined: Fri Jan 11, 2008 5:50 pm

Post by 2dum2code »

I just posted a script for this on this thread: http://www.osdev.org/phpBB2/viewtopic.php?t=15902

ld has bugs related to binary file creation when working with some object file types so my script does not use ld to create the binary. It uses objcopy which appears to have a bug too, but it's non-fatal, and easy to accommodate.

- Rich
Post Reply