Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-01

Different Object Code formats

10 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

This isn´t really a question about free pascal, more a general programming question, but I thougth someone here may have experience with this.

On my efforts to port fpc to symbian I got to compile a simple application using my minimal symbian rtl. It´s of course assembled with GNU Assembler for i386-win32, because the emulator uses standard i386-win32-pe executables.

Next I tryed to feed the .o files to the CodeWarrior linker provided by the symbian SDK, and it promptly refused the files with errors like this:

mwldsym2.exe: Invalid object 'QHelloWorld.o': unexpected storage class 104 ()

mwldsym2.exe: Invalid object 'system.o': unexpected storage class 104 ()

I went througth the documentation of both gnu as and the linker, and both say to be using COFF format. So are there several compilers/linkers using different (read incompatible) interpretations of what a coff .o file should be, all calling it COFF??

thanks,

Felipe Monteiro de Carvalho

Reply by email

Jonas Maebe
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
I went througth the documentation of both gnu as and the linker, and both say to be using COFF format. So are there several compilers/linkers using different (read incompatible) interpretations of what a coff .o file should be, all calling it COFF??

COFF is just a container, it can contain a lot of stuff which cannot necessarily be handled by every linker in existence.

Jonas

Reply by email

Florian Klaempfl
to Jonas Maebe
Show quoted text 11 lines
On 26 jan 2007, at 11:55, Felipe Monteiro de Carvalho wrote: > I went througth the documentation of both gnu as and the linker, and > both say to be using COFF format. So are there several > compilers/linkers using different (read incompatible) interpretations > of what a coff .o file should be, all calling it COFF?? COFF is just a container, it can contain a lot of stuff which cannot necessarily be handled by every linker in existence.

COFF is something like TIFF or AVI. Usually linkers and assembler don't make use of everythin one format supports. Best bet is to dump some object files of CodeWarrior and try to adapt the FPC coff backend so it is also able to create CodeWarrior compatible coffs.

Reply by email

Matt Emson
to Florian Klaempfl
COFF is something like TIFF or AVI. Usually linkers and assembler don't

make use

of everythin one format supports. Best bet is to dump some object files of CodeWarrior and try to adapt the FPC coff backend so it is also able to

create

CodeWarrior compatible coffs.

Or, if CodeWarrior has an assembler (it does on some platforms, not others), it might be worth just going that route. It might well be simpler to create .s files and have codewarrior assemble and link them.

Having worked with CodeWarrior under PowerPC (BeOS and MacOS) it's not the best compiler toolset in the world unfortunately. The other thing to look at: does the CodeWarrior have a native object format? I know it does under MacOS for PEF target. It might be a lot simpler to implement their native object format as, at least under PowerPC, the COFF support sucks.

One trick that one of the BeOS developers (Fred Fish specifically) used was to use GCC to assemble a single big old object file in COFF format (I forget the exact format... it was some lib format for AIX though IIRC) and link that with the mwld... That might be a route to try?

As you're using some other Arch, this is all probably no help, but I feel your pain.

M

Reply by email

Felipe Monteiro de Carvalho
to Matt Emson
Matt Emson wrote
Or, if CodeWarrior has an assembler (it does on some platforms, not others), it might be worth just going that route. It might well be simpler to create .s files and have codewarrior assemble and link them.

Unfortunately the Symbian UIQ SDK only contains a linker, a c/c++ compiler and a resource compiler. There is no assembler there. I already asked if they could provide a compatible assembler, but there was no positive answer on Symbian forum so far.

The other thing to look at: does the CodeWarrior have a native object format? I know it does under MacOS for PEF target. It might be a lot simpler to implement their native object format as, at least under PowerPC, the COFF support sucks.

That would be interresting to know. Just hope someone on symbian forum knows about this...

thanks,

Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to Florian Klaempfl: COFF is something like TIFF or AVI. Usually linkers and assembler don't make use of…
Florian Klaempfl wrote
COFF is something like TIFF or AVI. Usually linkers and assembler don't make use of everythin one format supports. Best bet is to dump some object files of CodeWarrior and try to adapt the FPC coff backend so it is also able to create CodeWarrior compatible coffs.

Ummm, didn´t even know fpc had a internal assembler =)

What is the default for win32? The internal assembler or Gnu As? But even then I´m not sure which will be used because I use Tsymbian, and it seams to ask for a i386-symbian-as.exe (which I generated renaming the as.exe for windows =) )

Also, typing fpc on the command line to see the options there is only -Aelf and Acoff options about internal assembler marked for Linux and Go32V2. Is there a option to force internal assembler on win32?

Felipe Monteiro de Carvalho

Reply by email

Peter Vreman
to Felipe Monteiro de Carvalho
Show quoted text 16 lines
On 1/26/07, Florian Klaempfl wrote: > COFF is something like TIFF or AVI. Usually linkers and assembler don't make use > of everythin one format supports. Best bet is to dump some object files of > CodeWarrior and try to adapt the FPC coff backend so it is also able to create > CodeWarrior compatible coffs. Ummm, didn´t even know fpc had a internal assembler =) What is the default for win32? The internal assembler or Gnu As? But even then I´m not sure which will be used because I use Tsymbian, and it seams to ask for a i386-symbian-as.exe (which I generated renaming the as.exe for windows =) ) Also, typing fpc on the command line to see the options there is only -Aelf and Acoff options about internal assembler marked for Linux and Go32V2. Is there a option to force internal assembler on win32?

All internal assemblers are used by default already for years.

For Windows there is even an internal linker. If symbian uses something like PE coff you can maybe even use that one. It works for all Windows targets (Win32,Win64,WinCE) already.

Reply by email

Felipe Monteiro de Carvalho
to Peter Vreman
Peter Vreman wrote
For Windows there is even an internal linker. If symbian uses something like PE coff you can maybe even use that one. It works for all Windows targets (Win32,Win64,WinCE) already.

Does the internal linker support linking to .LIB files?

The problem is that the executable is a standard win32-pe, but there are some "gotchas" =) Like the entry point must be exported and called _E32EXE .... and we must link together the symbian .lib files.

thanks,

Felipe Monteiro de Carvalho

Reply by email

Daniël Mantione
to Felipe Monteiro de Carvalho

Op Fri, 26 Jan 2007, schreef Felipe Monteiro de Carvalho:

Show quoted text 7 lines
On 1/26/07, Peter Vreman wrote: > For Windows there is even an internal linker. If symbian uses something > like PE coff you can maybe > even use that one. It works for all Windows targets (Win32,Win64,WinCE) > already. Does the internal linker support linking to .LIB files?

No.

The problem is that the executable is a standard win32-pe, but there are some "gotchas" =) Like the entry point must be exported and called _E32EXE .... and we must link together the symbian .lib files.

That doesn't look like a workable situation. The only way to generate OMF object files is using Nasm, however, Nasm is not complete enough to carry the full FPC infrastructure.

Check if you can get the symbian libraries in COFF format. If that doesn't work you have to go the Nasm route or start programming on an OMF backend for the internal assembler (and/or linker).

Daniël

Reply by email

Peter Vreman
to Daniël Mantione
you wrote 11 lines
Op Fri, 26 Jan 2007, schreef Felipe Monteiro de Carvalho: > On 1/26/07, Peter Vreman wrote: > > For Windows there is even an internal linker. If symbian uses something > > like PE coff you can maybe > > even use that one. It works for all Windows targets (Win32,Win64,WinCE) > > already. > > Does the internal linker support linking to .LIB files? No.
What is the .lib format? If it is an ar archive of COFF objects then
it is supported.
> The problem is that the executable is a standard win32-pe, but there > are some "gotchas" =) Like the entry point must be exported and called > _E32EXE .... and we must link together the symbian .lib files.

Those extra gotchas are normally easy to add. The entry point for example is something the compiler can generate and does not require changes in the linker.

Peter

Reply by email