ios - 链接器错误断言失败 : (atom->fixupCount() == 1)

标签 ios xcode4 llvm-gcc

使用 Xcode 4.0.2,我有一个可以在模拟器中正确编译、链接和运行的目标。但是,当我为 iOS 设备编译和链接它时,出现以下(完整)链接器错误:

Ld /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos/FrameworkHarness.app/FrameworkHarness normal armv7
    cd /Users/mike/src/FOO/FOObar
    setenv IPHONEOS_DEPLOYMENT_TARGET 4.2
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos -F/Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos -filelist /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Intermediates/FOObar.build/Debug-iphoneos/FrameworkHarness.build/Objects-normal/armv7/FrameworkHarness.LinkFileList -dead_strip -miphoneos-version-min=4.2 -framework FOObar -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos/FrameworkHarness.app/FrameworkHarness

Assertion failed: (atom->fixupCount() == 1), function targetCString, file /SourceCache/ld64/ld64-123.3/src/ld/parsers/macho_relocatable_file.cpp, line 4831.
0  0x13886  __assert_rtn + 86
1  0x2dfd8  mach_o::relocatable::PointerToCStringSection<arm>::targetCString(mach_o::relocatable::Atom<arm> const*, ld::IndirectBindingTable const&) const + 280
2  0x2b27c  mach_o::relocatable::PointerToCStringSection<arm>::contentHash(mach_o::relocatable::Atom<arm> const*, ld::IndirectBindingTable const&) const + 76
3  0x2c57f  mach_o::relocatable::Atom<arm>::contentHash(ld::IndirectBindingTable const&) const + 47
4  0xae870  ld::tool::SymbolTable::findSlotForReferences(ld::Atom const*, ld::Atom const**) + 704
5  0xb21dc  ld::tool::Resolver::convertReferencesToIndirect(ld::Atom const&) + 268
6  0xb33f2  ld::tool::Resolver::doAtom(ld::Atom const&) + 642
7  0x21f7c  mach_o::relocatable::File<arm>::forEachAtom(ld::File::AtomHandler&) const + 60
8  0xaa29e  ld::tool::InputFiles::forEachInitialAtom(ld::File::AtomHandler&) const + 46
9  0xb5924  ld::tool::Resolver::resolve() + 84
10  0x14ff7  main + 871
collect2: ld returned 1 exit status

有人可以阐明这一点吗?

谢谢迈克

用-v调用

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 -v -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -L/Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos -F/Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos -filelist /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Intermediates/FOObar.build/Debug-iphoneos/FrameworkHarness.build/Objects-normal/armv7/FrameworkHarness.LinkFileList -dead_strip -miphoneos-version-min=4.2 -framework FOObar -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos/FrameworkHarness.app/FrameworkHarness
Using built-in specs.
Target: arm-apple-darwin10
Configured with: /var/tmp/llvmgcc42_Embedded/llvmgcc42_Embedded-2373.6~5/src/configure --enable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/Developer/usr/llvm-gcc-4.2/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --enable-llvm=/var/tmp/llvmgcc42_Embedded/llvmgcc42_Embedded-2373.6~5/dst-llvmCore/Developer/usr/local --enable-werror-always --program-prefix=arm-apple-darwin10- --host=i686-apple-darwin10 --target=arm-apple-darwin10 --with-gxx-include-dir=/usr/include/c++/4.2.1 --with-build-sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.Internal.sdk
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2373.6)
 /Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/../libexec/gcc/arm-apple-darwin10/4.2.1/collect2 -dynamic -arch armv7 -dead_strip -iphoneos_version_min 4.2 -syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -weak_reference_mismatches non-weak -o /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos/FrameworkHarness.app/FrameworkHarness -lcrt1.3.1.o -L/Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/../lib/gcc/arm-apple-darwin10/4.2.1/v7 -L/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/../lib/gcc/arm-apple-darwin10/4.2.1 -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/../lib/gcc -L/Developer/Platforms/iPhoneOS.platform/Developer/usr/llvm-gcc-4.2/bin/../lib/gcc/arm-apple-darwin10/4.2.1/../../.. -filelist /Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Intermediates/FOObar.build/Debug-iphoneos/FrameworkHarness.build/Objects-normal/armv7/FrameworkHarness.LinkFileList -framework FOObar -framework UIKit -framework Foundation -framework CoreGraphics -lgcc_s.1 -lgcc -lSystem -F/Users/mike/Library/Developer/Xcode/DerivedData/FOObar-ezjrxybxyybadxguvscgaqtaelju/Build/Products/Debug-iphoneos
Assertion failed: (atom->fixupCount() == 1), function targetCString, file /SourceCache/ld64/ld64-123.3/src/ld/parsers/macho_relocatable_file.cpp, line 4831.
0  0x13886  __assert_rtn + 86
1  0x2dfd8  mach_o::relocatable::PointerToCStringSection<arm>::targetCString(mach_o::relocatable::Atom<arm> const*, ld::IndirectBindingTable const&) const + 280
2  0x2b27c  mach_o::relocatable::PointerToCStringSection<arm>::contentHash(mach_o::relocatable::Atom<arm> const*, ld::IndirectBindingTable const&) const + 76
3  0x2c57f  mach_o::relocatable::Atom<arm>::contentHash(ld::IndirectBindingTable const&) const + 47
4  0xae870  ld::tool::SymbolTable::findSlotForReferences(ld::Atom const*, ld::Atom const**) + 704
5  0xb21dc  ld::tool::Resolver::convertReferencesToIndirect(ld::Atom const&) + 268
6  0xb33f2  ld::tool::Resolver::doAtom(ld::Atom const&) + 642
7  0x21f7c  mach_o::relocatable::File<arm>::forEachAtom(ld::File::AtomHandler&) const + 60
8  0xaa29e  ld::tool::InputFiles::forEachInitialAtom(ld::File::AtomHandler&) const + 46
9  0xb5924  ld::tool::Resolver::resolve() + 84
10  0x14ff7  main + 871
collect2: ld returned 1 exit status

其他详细信息

当我将名为 FrameworkHarness 的应用程序的已编译 .m 文件与我创建的名为 FOOBar 的框架链接时,就会发生这种情况。框架配方来自:http://db-in.com/blog/2011/07/universal-framework-iphone-ios-2-0/

没有链接错误,当我:

  • 直接使用 FrameworkHarness 的模拟器 .m 文件从 FOObar 框架编译 .m 文件。
  • 直接使用 iOS 设备的 FrameworkHarness .m 文件从 FOObar 框架编译 .m 文件。
  • 将 FOObar 框架与已编译的 FrameworkHarness 的 .m 文件链接到模拟器。

当我出现链接错误时:

  • 将 FOObar 框架与为 iOS 设备编译的 FrameworkHarness .m 文件链接。

我厌倦了通过从框架中删除 5 个区域之一来隔离框架的问题。每次我将修改后的框架与编译后的 FrameworkHarness 的 .m 文件链接到 iOS 设备时,都没有链接错误。

接下来,我保留框架不变,但从应用程序中删除了对框架中 5 个区域之一的调用。我能够隔离会导致 iOS 设备链接器问题的框架区域。我执行了相同的过程,删除了框架中的代码,并且能够识别链接时导致错误的特定代码。我在框架的那个区域移动了代码,链接错误消失了。然而,我移动的代码是肤浅的,我所做的只是将代码从一个函数移动到一个新函数中,然后从原始函数调用该函数。被移动的代码是:

// Prompt are you sure?
NSString *message = [[NSString alloc] initWithFormat:@"Are you sure you want to remove the vlaue \"%@\" from the list?", [array objectAtIndex:[pickerView selectedRowInComponent:0]]];
UIAlertView *alertView =
    [[UIAlertView alloc] initWithTitle:@"Confirmation needed"
                               message:message
                              delegate:self
                     cancelButtonTitle:@"Keep"
                     otherButtonTitles:@"Remove", nil];
[message release];
[alertView show];
[alertView release];

使用nm比较framworks符号

我在 iOS 设备和模拟框架上运行了 nm。版本之间有一些差异,但没有尖叫

纳米-j-a

-j 只显示符号名称(无值或类型)。 -a 显示所有符号表条目,包括插入供调试器使用的条目。

diff nm.ios nm.sim 
125a126,134
> EH_Frame1
> EH_Frame1
> EH_Frame1
> EH_Frame1
> EH_Frame1
> EH_Frame1
> EH_Frame1
> EH_Frame1
> EH_Frame1
313d321
< ___divsi3
324a333
> _objc_msgSend_fpret
327a337,431
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
> func.eh
  • EH_Frame1 和 func.eh 为“S”(除上述以外部分的符号)
  • ___divsi3 和 _objc_msgSend_fpret 是“U”(未定义)

纳米-j-g

-j 只显示符号名称(无值或类型)。 -g 仅显示全局(外部)符号。

diff nm.ios nm.sim 
83d82
< ___divsi3
89a89
> _objc_msgSend_fpret

纳米-j-u

-j 只显示符号名称(无值或类型)。 -u 只显示 undefined symbol 。

diff nm.ios nm.sim 
37d36
< ___divsi3
43a43
> _objc_msgSend_fpret

可能的后续步骤

是否有一个链接器标志告诉它吐出它正在做什么,这样我就可以看到它在断言之前做了什么?

最佳答案

升级到最新版本的 Xcode(目前为 4.1,不包括测试版)。这应该可以解决您的问题。

关于ios - 链接器错误断言失败 : (atom->fixupCount() == 1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13855628/

相关文章:

iphone - iOS : Getting FriendList along with respective name, 使用 FBGraph API 的 id 和图片

objective-c - xcode 上未声明的标识符 __bridge

iphone - 无法确定 UIImage 不透明度属性

c++ - 在 LLVM 2.8 中调用 LLVM bitcode 函数

objective-c - Xcode LLVM+GCC 4.2 - 生成调试符号

gcc - 为什么 GCC 将汇编命令添加到我的内联汇编中?

iphone - initWithNibName 未按预期工作

ios - SceneKit Audio - 如何将 SCNPlayer 添加到 SCNNode 并播放声音

ios - 为不同的 iPhone 设备自动调整 CollectionView 单元格的大小

xcode4 - XCode 4 断点不会在正确的行中断