porting and binary format output

Nick Clifton nickc@redhat.com
Mon Sep 6 08:19:00 GMT 2004


Hi Paul,

> I am trying to design a processor on an FPGA and port gas and gcc
> to it as simply as possible. Is there a way to get gas to output
> plain binary files? I'd like to avoid having to write ELF relocation
> code since I plan to strip all of it to a plain binary to run on
> the FPGA core anyway.

There is no simple way to do this.  The assembler only creates object 
files and there is not enough information in a plain binary file for it 
to be successfully linked with other binary files.  (Except in the 
trivially simple case of just concatenating the binary files, but in 
that situation you do not need a linker at all).  Hence the assembler 
needs to create object files in a more sophisticated file format than 
just plain binary.

Just because GAS is creating an ELF format output file (or COFF, or AOUT 
or one of the other binary file formats), this does not mean that 
automatically have to write relocation code.  This is only needed if the 
instruction set of your target FPGA supports instructions whose exact 
binary layout cannot be fully determined at assembly time.  (eg branch 
instructions to destinations outside of the file/section thats is 
currently being assembled).

If you can restrict your ISA to instructions that are fully resolvable 
at assembly time then you will not need to generate relocations.  You 
may well find that this restricts your ISA too much for it to be useful, 
but you may find it helpful as a starting point before going on to 
develop a more flexible ISA.

Cheers
   Nick



More information about the Binutils mailing list