]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blobdiff - libc/tools/check-symbols-glibc.py
Make the missing symbols script more useful.
[android-sdk/platform-bionic.git] / libc / tools / check-symbols-glibc.py
index ffff9649d25dc05859797cd71b30e02d65740b5a..153b840366add234c2305ccea422477e6bcece70 100755 (executable)
@@ -16,6 +16,14 @@ arch = re.sub(r'.*/linux-x86/([^/]+)/.*', r'\1', toolchain)
 if arch == 'aarch64':
   arch = 'arm64'
 
+def GetSymbolsFromTxt(txt_file):
+  symbols = set()
+  f = open(txt_file, 'r')
+  for line in f.read().splitlines():
+    symbols.add(line)
+  f.close()
+  return symbols
+
 def GetSymbolsFromSo(so_file):
   # Example readelf output:
   #   264: 0001623c     4 FUNC    GLOBAL DEFAULT    8 cabsf
@@ -70,13 +78,15 @@ glibc_to_bionic_names = {
   '__res_mkquery': 'res_mkquery',
   '__res_query': 'res_query',
   '__res_search': 'res_search',
+  '__xpg_basename': '__gnu_basename',
 }
 
-glibc = GetSymbolsFromSystemSo('libc.so.*', 'librt.so.*', 'libpthread.so.*', 'libresolv.so.*', 'libm.so.*')
+glibc = GetSymbolsFromSystemSo('libc.so.*', 'librt.so.*', 'libpthread.so.*', 'libresolv.so.*', 'libm.so.*', 'libutil.so.*')
 bionic = GetSymbolsFromAndroidSo('libc.so', 'libm.so')
+posix = GetSymbolsFromTxt(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'posix-2013.txt'))
 ndk_ignored = GetNdkIgnored()
 
-glibc = map(MangleGlibcNameToBionic, glibc)
+glibc = set(map(MangleGlibcNameToBionic, glibc))
 
 # bionic includes various BSD symbols to ease porting other BSD-licensed code.
 bsd_stuff = set([
@@ -172,24 +182,6 @@ libresolv_stuff = set([
   'dn_expand',
   'nsdispatch',
 ])
-# libstdc++ stuff we took over.
-libstdcxx_stuff = set([
-  # new, delete, nothrow
-  '_ZSt7nothrow',
-  '_ZdaPv',
-  '_ZdaPvRKSt9nothrow_t',
-  '_ZdlPv',
-  '_ZdlPvRKSt9nothrow_t',
-  '_Znam',
-  '_ZnamRKSt9nothrow_t',
-  '_Znwm',
-  '_ZnwmRKSt9nothrow_t',
-
-  '__cxa_guard_abort',
-  '__cxa_guard_acquire',
-  '__cxa_guard_release',
-  '__cxa_pure_virtual',
-])
 # Implementation details we know we export (and can't get away from).
 known = set([
   '_ctype_',
@@ -197,21 +189,30 @@ known = set([
 ])
 
 if not only_unwanted:
-  print 'glibc:'
-  for symbol in sorted(glibc):
+  #print 'glibc:'
+  #for symbol in sorted(glibc):
+  #  print symbol
+  #print
+
+  #print 'bionic:'
+  #for symbol in sorted(bionic):
+  #  print symbol
+  #print
+
+  print 'in glibc (but not posix) but not bionic:'
+  for symbol in sorted((glibc - posix).difference(bionic)):
     print symbol
-
   print
-  print 'bionic:'
-  for symbol in sorted(bionic):
-    print symbol
 
+  print 'in posix (and implemented in glibc) but not bionic:'
+  for symbol in sorted((posix.intersection(glibc)).difference(bionic)):
+    print symbol
   print
+
   print 'in bionic but not glibc:'
 
 allowed_stuff = (bsd_stuff | FORTIFY_stuff | linux_stuff | macro_stuff |
-                 std_stuff | weird_stuff | libresolv_stuff | libstdcxx_stuff |
-                 known)
+                 std_stuff | weird_stuff | libresolv_stuff | known)
 for symbol in sorted((bionic - allowed_stuff).difference(glibc)):
   if symbol in ndk_ignored:
     symbol += '*'