• 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: CLANG linker returning "illegal text-relocation to..." for x64
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CLANG linker returning "illegal text-relocation to..." for x64


  • Subject: Re: CLANG linker returning "illegal text-relocation to..." for x64
  • From: Wim Lewis <email@hidden>
  • Date: Tue, 12 Jun 2012 13:37:58 -0700

On 12 Jun 2012, at 11:55 AM, Vojtěch Meluzín wrote:
> I just moved to Lion and its new XCode 4. I'm calling the compiler directly, so no XCode processing. I basically cloned the way XCode uses the compiler. For x86 everything works just fine, in fact CLANG seems to have the same options as GCC used before. But with x64 it ends up with weird linking errors:
>
> ld: illegal text-relocation to ___stdoutp in /Applications/Xcode.app/
> Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/usr/lib/libSystem.dylib from __ZN5MFile9SetStdoutERK7MString in !temp/debugDebug1/test/mlibrary.o for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
> I'm really desperate here as I have no idea what causes this and no options seemed to help it. The calling script is below.


I'm not sure why Clang is giving you a problem that GCC didn't, but it's complaining that you have a static (readonly text-section) variable that's initialized to 'stdout' (on Darwin, this is defined as &___stdoutp), somewhere in the method named MFile::SetStdout(MString const&). Fixups of that kind are forbidden, I think because it makes load-time relocation more expensive (the address of ___stdoutp, and therefore the value of stdout, is not known until the program is dynamically linked at launch time). It should be possible to avoid the error by adjusting the code in that method; just be careful not to treat stdout as a compile-time constant.

You might also be able to do something with the -[no_]pie, -mdynamic, -fPIC, etc. options to the compiler and linker, but I can never remember what the recommended use of those settings is.



 _______________________________________________
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: CLANG linker returning "illegal text-relocation to..." for x64
      • From: Vojtěch Meluzín <email@hidden>
References: 
 >CLANG linker returning "illegal text-relocation to..." for x64 (From: Vojtěch Meluzín <email@hidden>)

  • Prev by Date: Re: Developer ID inconsistent behavior
  • Next by Date: Re: Developer ID inconsistent behavior
  • Previous by thread: CLANG linker returning "illegal text-relocation to..." for x64
  • Next by thread: Re: CLANG linker returning "illegal text-relocation to..." for x64
  • Index(es):
    • Date
    • Thread