Page 1 of 1

creating raw executables with gas

Posted: Sat Jan 12, 2008 6:32 pm
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,

Posted: Sun Jan 13, 2008 3:38 am
by Combuster
have you asked LD for a list of options?

Posted: Sun Jan 13, 2008 9:22 am
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?

Posted: Sun Jan 13, 2008 4:15 pm
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:

Posted: Mon Jan 14, 2008 4:45 am
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