This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to load and execute COFF file




From: Toralf Lund <toralf@procaptura.com>
To: Alexander Gdalevich <gdalevich@hotmail.com>
CC: crossgcc@sources.redhat.com
Subject: Re: How to load and execute COFF file
Date: Mon, 15 Sep 2003 09:15:32 +0200


You will either need to write a custom loader (this is not too difficult, COFF is a pretty simple format), or have your code move itself to the proper place in memory.

The plan is to write a loader, or rather, to modify an existing one. I'm just wondering what it needs to do, apart from obvious stuff like actually writing the data to memory.


I don't know exactly how your system works, but the loader just moves the program to the right place in memory and just jump to the entry point.


You may also compile with the "-oformat binary" option to generate binary image (that will still need to be moved to the right place in memory).

Possibly a stupid question, but what would the right place in memory be?
That depends on how the memory is setup on your system. You may compile with the "-Ttext PROG_START" option to tell the compiler (or rather the linker) where to place executable. Here PROG_START would be address where you want the program placed. For instance, "-Ttext 0x00400000" would build code to run from address 0x00400000.



- Toralf




_________________________________________________________________
Compare Cable, DSL or Satellite plans: As low as $29.95. https://broadband.msn.com



------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]