Mailing Lists: Apple Mailing Lists

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

Re: Do object files need to be position-independent?




On 08 Jan 2007, at 17:34, Agner Fog wrote:

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.

It's also possible to compile non PIC code.

I haven't quite figured out how the GOT works

There is no explicit GOT in the way there is one on e.g. Linux.

and how function calls are relocated.

Via stubs. I would suggest you to have a look at the output of gcc -S rather than at compiled object code. And maybe also browse through http://developer.apple.com/documentation/developertools/Reference/ Assembler/index.html, in particular the "Assembler Directives" section.


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.

PIC is only required for dynamic libraries (and even then it isn't strictly required, although you'll have to tell the linker to treat errors about relocations in read-only sections as warnings if you want to compile a library without PIC code).


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.

Not entirely. See http://developer.apple.com/documentation/ DeveloperTools/Conceptual/LowLevelABI/Articles/IA32.html


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

No.


Jonas _______________________________________________ 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
References: 
 >Do object files need to be position-independent? (From: Agner Fog <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.