Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 515
tml Avatar asked Dec 23 '13 23:12

tml


1 Answers

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.

like image 182
tml Avatar answered Nov 18 '22 09:11

tml