为什么Apple的Clang(来自Xcode 5)为arm64制作typeinfos private_extern?

时间:2013-12-23 23:41:45

标签: c++ ios clang typeinfo arm64

如果您编译此文件p3.cxx:

class foobarclass
{
 public:
  int i0;
};

void otherfun(void);
void mumble(void);

void fun(void)
{
  try {
    otherfun();
  } catch(foobarclass &e) {
    mumble();
  }
}

像这样:

xcrun clang++ -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -fexceptions -c p3.cxx -p3.64.o

xcrun clang++ -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -fexceptions -c p3.cxx -o p3.32.o

然后检查“typeinfo for foobarclass”的符号:

nm -m p3.64.o|grep ZTI
0000000000000110 (__DATA,__datacoal_nt) weak private external __ZTI11foobarclass

nm -m p3.32.o|grep ZTI
00000134 (__DATA,__datacoal_nt) weak external __ZTI11foobarclass

为什么arm64中的符号弱私有外部?这意味着dlsym()将无法在运行时找到它。这会破坏LibreOffice代码库中的某些低级内容。

2 个答案:

答案 0 :(得分:1)

我在相关的Apple Developer论坛中提出了同样的问题,并得到了有意的回复,以减少可执行文件中全局可见符号的数量。所以我将不得不忍受它。

答案 1 :(得分:-2)

将构建设置中的体系结构设置为标准体系结构(armv7,armv7s)

ARCHS = **armv7 armv7s**

VALID_ARCHS = **armv6 armv7 armv7s**

enter image description here

  

Xcode可以使用32位和64位二进制文​​件构建您的应用程序   包括在内。这个组合二进制文件需要最小的部署目标   iOS 7或更高版本。

     

注意:Xcode的未来版本将允许您创建一个应用程序   支持iOS 6及更高版本的32位运行时,并支持   iOS 7上的64位运行时。

  • Xcode可以为单个应用程序创建64位32位二进制文​​件,但是 部署目标应该是iOS7。
  • 他们说将来它将是iOS 6.0 32位二进制文​​件 在iPhone 5S(64位处理器)中正常工作。

<强>更新 在Xcode 5.0.1中,他们添加了为iOS 5.1.1开始创建64位二进制文​​件的支持。

  

Xcode 5.0.1可以使用32位和64位二进制文​​件构建您的应用程序   包括在内。这个组合二进制文件需要最小的部署目标   iOS 5.1.1或更高版本。 64位二进制文​​件仅在64位设备上运行   运行iOS 7.0.3及更高版本。