imports.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Disallow some imports into and exports from libobjc.A.dylib.
  3. To debug, re-run libobjc's link command with
  4. -Xlinker -dead_strip -Xlinker -why_live -Xlinker SYMBOL_NAME_HERE
  5. Disallowed imports (nm -u):
  6. ___cxa_guard_acquire (C++ function-scope static initializer)
  7. ___cxa_guard_release (C++ function-scope static initializer)
  8. ___cxa_atexit (C++ static destructor)
  9. weak external (any weak externals, including operators new and delete)
  10. Whitelisted imports:
  11. weak external ____chkstk_darwin (from libSystem)
  12. Disallowed exports (nm -U):
  13. __Z* (any C++-mangled export)
  14. weak external (any weak externals, including operators new and delete)
  15. fixme rdar://13354718 should disallow anything from libc++ (i.e. not libc++abi)
  16. */
  17. /*
  18. TEST_BUILD
  19. echo $C{XCRUN} nm -m -arch $C{ARCH} $C{TESTLIB}
  20. $C{XCRUN} nm -u -m -arch $C{ARCH} $C{TESTLIB} | grep -v 'weak external ____chkstk_darwin \(from libSystem\)' | egrep '(weak external| external (___cxa_atexit|___cxa_guard_acquire|___cxa_guard_release))' || true
  21. $C{XCRUN} nm -U -m -arch $C{ARCH} $C{TESTLIB} | egrep '(weak external| external __Z)' || true
  22. $C{COMPILE_C} $DIR/imports.c -o imports.exe
  23. END
  24. TEST_BUILD_OUTPUT
  25. .*libobjc.A.dylib
  26. END
  27. */
  28. #include "test.h"
  29. int main()
  30. {
  31. succeed(__FILE__);
  32. }