Re: Retrieving function addresses in an object file

"BGB / cr88192" <cr88192@hotmail.com>
Sat, 10 Apr 2010 09:53:11 -0700

          From comp.compilers

Related articles
Retrieving function addresses in an object file px_seven@yahoo.se (Fredric M) (2010-04-06)
Re: Retrieving function addresses in an object file cr88192@hotmail.com (BGB / cr88192) (2010-04-10)
Retrieving function addresses in an object file chakaram@auth.gr (Chariton Karamitas) (2010-04-12)
| List of all articles for this month |

From: "BGB / cr88192" <cr88192@hotmail.com>
Newsgroups: comp.compilers
Date: Sat, 10 Apr 2010 09:53:11 -0700
Organization: albasani.net
References: 10-04-019
Keywords: linker
Posted-Date: 11 Apr 2010 00:22:09 EDT

"Fredric M" <px_seven@yahoo.se> wrote in message
> I am in the process of creating a simple, custom object file format
> (with position independent code) using ld and gcc, with the following
> principal layout:
<snip>
> Is it possible to achieve something like this?




I am not sure your exact reason for doing this, but unless there is some
particularly good reason for doing so (such as interoperation with an
oddball operating system, ...), I would personally recommend against this,
and instead assert that it would likely be better trying to make COFF or ELF
or MachO or similar do whatever is needed.


for example, it may seem like it would be cleaner and nicer to simply design
a new object/image format (since admittedly both COFF and ELF are a bit
crufty), however the non-immediate costs are likely to outweigh most
possible gain from having created a custom format.


in both cases, writing a custom loader for these formats is not particularly
complicated or difficult, and as well offer the benefit of being fairly
widely supported by existing tools (and thus much easier to produce).


note that with a custom loader (for an existing format), it is possible
(within reason) to take code compiled for one OS and use it on another (this
is, of course, subject to matters of CPU architecture or differences in OS
calling conventions, ...).


similarly, ELF images are generally used in a fairly similar manner to how
you have described here, and similarly little prevents using ELF on Windows
(for libraries and similar) for that matter.




a reasonable exception may be if the project is for a custom VM, and the
objects are to contain some custom bytecode and metadata or similar,
however, in this case, I am not as certain about using GCC as a base.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.