Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Do object files need to be position-independent?



I am working on an object-file converter for x86 and x86-64 code for the purpose of cross-platform development. My goal is to make it easier to make function libraries that work on all x86 platforms from the same assembly source code.

So far, it works for Windows-COFF and ELF file formats, 32 and 64 bit. For example, a static function library made under Windows can be converted so it works on Linux and BSD.

Now I want to convert object files to Mach-O format also. I have investigated a Mach-O object file and found that it contains position-independent code where global variables are accessed relative to EBX. I haven't quite figured out how the GOT works and how function calls are relocated. If position-independent code is required then it is not possible to convert an object file from another system that does not use this method. But if the relocation mechanism supports position-dependent code then it is possible. The ABI is basically the same in 32-bit Windows, Linux, BSD and Intel-based Mac OS X.

As far as I know, there is no objcopy on Mac that supports conversion from ELF to Mach-O ?

A preliminary version of my object file converter can be downloaded from www.agner.org/optimize/. I will publish the source code later.

The conversion works best with code generated from assembly source, because compiler-generated code often contains a lot of exception-handlers, constructor, destructor, debug info, etc. that is system dependent.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-x86 mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-x86/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.