Why does Apple's Clang (from Xcode 5) make typeinfos private_extern for arm64?

774 views Asked by At

If you compile this file p3.cxx:

class foobarclass
{
 public:
  int i0;
};

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

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

Like this:

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

and

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

and then check the symbol of the "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

Why is the symbol weak private external in the arm64 case? This means dlsym() won't find it at run-time. This breaks certain low-level stuff in the LibreOffice codebase.

3

There are 3 answers

0
tml On

I asked the same question in the relevant Apple Developer forum, and got the reply that this is intentional, to reduce the number of globally visible symbols in an executable. So I will just have to live with it.

2
Vishal Khatri On

Set the architecture in build setting to Standard architectures(armv7,armv7s)

ARCHS = **armv7 armv7s**

VALID_ARCHS = **armv6 armv7 armv7s**

enter image description here

Xcode can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 7 or later.

Note: A future version of Xcode will let you create a single app that supports the 32-bit runtime on iOS 6 and later, and that supports the 64-bit runtime on iOS 7.

  • Xcode can create both 64bit 32bit binaries for a single app but the deployment target should be iOS7.
  • They are saying in future it will be iOS 6.0 32 bit binary will work fine in iPhone 5S(64 bit processor).

Update In Xcode 5.0.1 they added the support to create 64 bit binary for iOS 5.1.1 onwards.

Xcode 5.0.1 can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 5.1.1 or later. The 64-bit binary runs only on 64-bit devices running iOS 7.0.3 and later.

0
phlipsy On

Preliminary remark: I asked myself the very same question the last days and almost posted a question on Stack overflow. At least I'm not alone with this matter.

As far as I can tell, on ARM systems they decided to implement operator == (const type_info &, const type_info &) in terms of a string comparison. This means two type_info objects from two separate modules can be equal even though they are not identical. The C++ runtimes on Windows and GNU/Linux do it the same way. And since the type_info objects don't need to be identical, they don't need to be published and thus can be defined private extern in object files. Those symbols will be coalesced during static linking but won't appear in the dynamic symbol table.