Linking with object files

Adrian Hey ahey@iee.org
Wed, 8 Jan 2003 16:30:59 +0000


Thanks for your answers

On Wednesday 08 January 2003 10:04 am, Simon Marlow wrote:
> > I get the error.. can't find module 'foo.o' <while processing "foo.o">
>
> I think you must be using a version of GHC prior to 5.04.2.  This
> functionality was fixed in 5.04.2.

I just checked, it really is (or claims to be:-) version 5.04.2.
I get the same error using 5.04.2 under Linux too.

> > The second question is what object formats does ghc
> > understand and is the
> > object file suffix significant? If I try elf format, this is
> > accepted without
> > complaint but I get a broken executable (though this could
> > well be because
> > my assembler has generated a broken elf file). Using coff
> > format seems OK.
> > The files have a ".o"  suffix in both cases.
> >
> > FWIW, I'm using ghc 5.04.2 on Win32 with the nasm assembler.
>
> I'm not sure about this one - any Windows experts out there like to
> comment?
>
> My guess is that GHCi should load COFF objects only, but other kinds of
> objects might work when using the system linker (i.e. in batch mode).

I've now tried a variety of formats on both win32 and Linux, the answer
seems to be:

On Linux using ld version 2.10.91
---------------------------------
aout format works.

coff,as86,obj,win32,rdf formats all give the error..
	foo.o: file not recognized: File format not recognized

elf format gives the error..
	/usr/bin/ld: foo.o: invalid section symbol index 0xfff1 (*ABS*) ingored
It does indeed "ingore" the error and go on to produce an executable, but
this time it works.


On Win32 using ld version 2.11.90 (as shipped with ghc)
-------------------------------------------------------
coff and win32 formats work.

as86,obj,rdf formats all give the error..
	foo.o: file not recognized: File format not recognized

elf format gives no error, but the executable is broken

This was all with .o suffix, dunno if changing it to something else
might get rid some of these errors. 

Don't know if any of this is any help. It seems there's something
dodgy with elf format, either in nasm or ld (not sure which).

Regards
--
Adrian Hey