Linker error in Xcode 4.4
Asked Answered
S

2

7

Upon upgrading from Xcode 4.3 to Xcode 4.4, I started to get the following error on building my iPhone app:

ld: section __objc_const (address=0x0010C720, size=7265990088) would make the output executable exceed available address range for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

The memory address and number do not mean anything to me, but they remain consistent across clean and rebuilds. It is not clear to me how to find what they might be referencing.

The code did and still does compile in XCode 4.3.

Does anyone have any idea how I might track down what's causing this error?

Scalenus answered 15/8, 2012 at 18:20 Comment(6)
it's probably that you are not linked to a framework you are using, or you linked to the wrong thing. If the former, check and link it in build settings. If the latter, remove the wrong linker and hopefully XCode will relink to the correct one.Horseleech
Do you have large initialized global or static data in your program?Abortifacient
@MartinR Yes, larger than I've seen in a typical program (I didn't write much of the code) but nothing on the order of 7 billion or even a millionth of that.Scalenus
I can only say that this linker error definitely can be caused by global/static data too large for a 32-bit executable.Abortifacient
It cannot run if it cannot link. You obviously have some global data object which has run amuck. Since most coders usually use "static" for global data (but not always), you could try searching for that and see what you find. Xcode 4.4 uses llvm 3.1, and the preprocessor or compiler is different. Ah, did you try to Analyze your code?Quartus
Unfortunately static analysis seems to require linking. And I did a search on all the static and const variables in the code, but nothing suck out to me as consuming that much space. Perhaps it is some strange macro that's messing it up?Scalenus
J
2

I had the very same error. Luckily, I could recall the moment when it appeared, rolled back and compared the revisions. It was a category with static methods on Google Analytics GAI class. I have no idea why it happened, since other categories in the project work just fine, but hope it helps someone too.

Jalapa answered 17/6, 2013 at 5:38 Comment(0)
A
1

You can see the sizes of all symbols (including global variables) in a Link Map File:

  • In the Build Settings for your target, go to the "Linking" section and set "Write Link Map File" to "Yes".
  • Build the program. The linker will fail, but the link map file is written.
  • Locate the link map file. The log output from the linker shows the parameters -map -Xlinker -/path/to/linkmapfile.txt. It is somewhere in the DerivedData folder of your project.
  • The link map file show addresses (first column) and sizes (second column) for all symbols. For global variables, it shows the name and in which object file they are located.
  • You should find the address of your error message (0x0010C720 in your example) in the link map file.
  • You can check the link map file for other symbols having a large size.

So perhaps this helps to narrow down the problem.

Abortifacient answered 16/8, 2012 at 17:25 Comment(2)
Unfortunately in this case, the linker does not create the file.Scalenus
@TheDirtyCalvinist: Thanks for the feedback. Unfortunately I do not have more ideas how to solve this problem.Abortifacient

© 2022 - 2024 — McMap. All rights reserved.