• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Linker refuses to link my dylib? Why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Linker refuses to link my dylib? Why?


  • Subject: Re: Linker refuses to link my dylib? Why?
  • From: Ladd Van Tol <email@hidden>
  • Date: Thu, 15 Feb 2007 15:03:33 -0800


On Feb 15, 2007, at 11:57 AM, Eric Albert wrote:

It definitely isn't supported. You can construct the code, but dyld assumes that all libraries are relocatable, so if the library has to be slid due to other things inserted into the process' address space it'll go ahead and slide the library. If the library is non-PIC, it'll run incorrectly when it's slid.

In other words, I'd strongly suggest that you not ship libraries built non-PIC.

It is actually possible to preserve relocation entries in a dylib, and have dyld rewrite them at runtime, allowing non-PIC code to slide. You do have to pass "-read_only_relocs supress" to ld. I have done this with Intel assembly that was written for Windows with position-dependent code, and needed to be linked into a Mac Intel dylib. This strategy is not really recommended, if you can avoid it, as it will eliminate most of the virtual memory code-sharing benefits that dylibs provide. I have not tried it with output from the C compiler or with PPC code, so there may be other pitfalls as well.


PIC vs. non-PIC shouldn't be an issue on x86_64, as the instruction set adds support for PC-relative addressing. Assuming the compiler uses it, the speed hit of PIC should be minimal or non-existent on x86_64.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Linker refuses to link my dylib? Why?
      • From: Jonas Maebe <email@hidden>
References: 
 >Re: Linker refuses to link my dylib? Why? (From: Greg Guerin <email@hidden>)
 >Re: Linker refuses to link my dylib? Why? (From: Eric Albert <email@hidden>)
 >Re: Linker refuses to link my dylib? Why? (From: Jonas Maebe <email@hidden>)
 >Re: Linker refuses to link my dylib? Why? (From: Eric Albert <email@hidden>)

  • Prev by Date: Re: How to determine libraries and symbols imported by an executable?
  • Next by Date: Re: .cch => {.cc, .h}
  • Previous by thread: Re: Linker refuses to link my dylib? Why?
  • Next by thread: Re: Linker refuses to link my dylib? Why?
  • Index(es):
    • Date
    • Thread