Re: OS constant cause "32-bit RIP relative reference out of range" linker error on x64
Re: OS constant cause "32-bit RIP relative reference out of range" linker error on x64
- Subject: Re: OS constant cause "32-bit RIP relative reference out of range" linker error on x64
- From: Fritz Anderson <email@hidden>
- Date: Wed, 13 Jun 2012 07:56:18 -0500 (CDT)
- Importance: Normal
On Wed, June 13, 2012 6:16 am, Vojtech Meluzín wrote:
> I'm trying to make x64 work on XCode 4 Mac OS 10.7, but whenever I use a
system constant, such as kCFAllocatorDefault, I get this linker error
(on x86 it works fine):
>
> ld: warning: PIE disabled. Absolute addressing (perhaps
-mdynamic-no-pic) not allowed in code signed PIE, but used in
[MClipboard::Set(MString, MBuffer)] from
> /Users/melda/Library/Developer/Xcode/DerivedData/console-elzukurmumezgoaajfaamjcaoeol/Build/Intermediates/console.build/Debug/console.build/Objects-normal/x86_64/mlibrary_teststub.o.
> To fix this warning, don't compile with -mdynamic-no-pic or link with
-Wl,-no_pie
> final section layout:
> __TEXT/__text addr=0x1000012E0, size=0x0015B24B, fileOffset=0x000012E0,
> type=1
>
> __DATA/__common addr=0x1001EB810, size=0x00088680,
fileOffset=0x00000000, type=24
> ld: 32-bit RIP relative reference out of range (-4295653407 max is +/-4GB):
> from MClipboard::Set(MString, MBuffer) (0x1000A70B0) to
> _kCFAllocatorDefault@0x00162A88 (0x00000000) in
> MClipboard::Set(MString, MBuffer) from
[C++ symbols demangled]
> /Users/melda/Library/Developer/Xcode/DerivedData/console-elzukurmumezgoaajfaamjcaoeol/Build/Intermediates/console.build/Debug/console.build/Objects-normal/x86_64/mlibrary_teststub.o
> for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> What is wrong with that? It does that literally with all constants, stdout
> for example too...
The error message itself says what's wrong, and how to fix it. If you want
to sign an application, Lion requires that it be a position-independent
executable (PIE), so the pieces of the app can be shifted to random
locations, denying attackers consistent addresses for access to your code.
My guess is that whatever library MClipboard::Set(MString, MBuffer) is
declared in was "efficiently" compiled with -mdynamic-no-pic (Generate
Position-Dependent Code) and linked with -no_pie (Don't Build Position
Independent Executable). Search for these settings in your targets' Build
Settings panel with "Position".
Set the Generate (the compiler flag) to Yes, and Don't Build to No, as the
error message
> To fix this warning, don't compile with -mdynamic-no-pic or link with
-Wl,-no_pie
told you.
F
--
Fritz Anderson
Xcode 4 Unleashed x4u.manoverboard.org
Fathers' Day. Need I say more?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden