Interfacing with assembly code

Ian Lance Taylor ian@airs.com
Tue May 17 20:24:00 GMT 2005


"Rob Lyman" <z073074@students.niu.edu> writes:

> I am using gcc package and want to combine C code with assembler.  Although
> I am aware that gcc can in fact assemble code, I am rather set in my ways
> and am more comfortable assembling code with NASM.  So my questions are two:
> 
> 1) Why would the gcc linker be unable to find a symbol called "readTSC" in
> an ELF file generated by NASM?  I am properly exporting the symbol name,
> according to the NASM docs.  (I also tried exporting it as "_readTSC".)

Try using nm and/or objdump -t to see what the ELF code sees in the
symbol table of your object file.  Note that the linker is not part of
gcc.  The GNU linker is part of the GNU binutils; for more information
see:
    http://sourceware.org/binutils/

> 2) Is the gcc compiler capable of generating an object file in Intel OMF/OBJ
> format?  What command line options are required to invoke this?

gcc just generates assembly code, and then invokes the assembler.  If
you want to generate OMF, you will need an assembler which can
interpret gcc's assembly output and generate OMF.  In this context the
-masm=intel option may be helpful.  (The GNU assembler does not
support OMF output, but gcc is regularly used with other assemblers.)

Ian



More information about the Gcc-help mailing list