summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-08-29 15:45:41 +0000
committerAlexey Samsonov <samsonov@google.com>2013-08-29 15:45:41 +0000
commit5ffab0959a59aebe656edf7f67e7c684cc723f9d (patch)
treed8063781937a7c48e530482cb93e369280749c18 /compiler-rt/lib
parent68cd396f828e385b69341f077a0a461e3caa6e12 (diff)
downloadbcm5719-llvm-5ffab0959a59aebe656edf7f67e7c684cc723f9d.tar.gz
bcm5719-llvm-5ffab0959a59aebe656edf7f67e7c684cc723f9d.zip
Minor updates to gen_dynamic_list script suggested by glider
llvm-svn: 189588
Diffstat (limited to 'compiler-rt/lib')
-rwxr-xr-xcompiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py91
1 files changed, 49 insertions, 42 deletions
diff --git a/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py b/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py
index 23b861eedbe..de8ea4d0f70 100755
--- a/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py
+++ b/compiler-rt/lib/sanitizer_common/scripts/gen_dynamic_list.py
@@ -14,14 +14,25 @@
# gen_dynamic_list.py libclang_rt.*san*.a [ files ... ]
#
#===------------------------------------------------------------------------===#
-import re
import os
+import re
import subprocess
import sys
+new_delete = set(['_ZdaPv', '_ZdaPvRKSt9nothrow_t',
+ '_ZdlPv', '_ZdlPvRKSt9nothrow_t',
+ '_Znam', '_ZnamRKSt9nothrow_t',
+ '_Znwm', '_ZnwmRKSt9nothrow_t'])
+
+versioned_functions = set(['memcpy', 'pthread_cond_broadcast',
+ 'pthread_cond_destroy', 'pthread_cond_signal',
+ 'pthread_cond_timedwait', 'pthread_cond_wait',
+ 'realpath', 'sched_getaffinity'])
+
def get_global_functions(library):
functions = []
- nm_proc = subprocess.Popen(['nm', library], stdout=subprocess.PIPE)
+ nm_proc = subprocess.Popen(['nm', library], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
nm_out = nm_proc.communicate()[0].split('\n')
if nm_proc.returncode != 0:
raise subprocess.CalledProcessError(nm_proc.returncode, 'nm')
@@ -31,46 +42,42 @@ def get_global_functions(library):
functions.append(cols[2])
return functions
-result = []
+def main(argv):
+ result = []
-library = sys.argv[1]
-all_functions = get_global_functions(library)
-function_set = set(all_functions)
-new_delete = set(['_ZdaPv', '_ZdaPvRKSt9nothrow_t',
- '_ZdlPv', '_ZdlPvRKSt9nothrow_t',
- '_Znam', '_ZnamRKSt9nothrow_t',
- '_Znwm', '_ZnwmRKSt9nothrow_t'])
-versioned_functions = set(['memcpy', 'pthread_cond_broadcast',
- 'pthread_cond_destroy', 'pthread_cond_signal',
- 'pthread_cond_timedwait', 'pthread_cond_wait',
- 'realpath', 'sched_getaffinity'])
-for func in all_functions:
- # Export new/delete operators.
- if func in new_delete:
- result.append(func)
- continue
- # Export interceptors.
- match = re.match('__interceptor_(.*)', func)
- if match:
- result.append(func)
- # We have to avoid exporting the interceptors for versioned library
- # functions due to gold internal error.
- orig_name = match.group(1)
- if orig_name in function_set and orig_name not in versioned_functions:
- result.append(orig_name)
- continue
- # Export sanitizer interface functions.
- if re.match('__sanitizer_(.*)', func):
- result.append(func)
+ library = argv[1]
+ all_functions = get_global_functions(library)
+ function_set = set(all_functions)
+ for func in all_functions:
+ # Export new/delete operators.
+ if func in new_delete:
+ result.append(func)
+ continue
+ # Export interceptors.
+ match = re.match('__interceptor_(.*)', func)
+ if match:
+ result.append(func)
+ # We have to avoid exporting the interceptors for versioned library
+ # functions due to gold internal error.
+ orig_name = match.group(1)
+ if orig_name in function_set and orig_name not in versioned_functions:
+ result.append(orig_name)
+ continue
+ # Export sanitizer interface functions.
+ if re.match('__sanitizer_(.*)', func):
+ result.append(func)
-# Additional exported functions from files.
-for fname in sys.argv[2:]:
- f = open(fname, 'r')
- for line in f:
- result.append(line.rstrip())
+ # Additional exported functions from files.
+ for fname in argv[2:]:
+ f = open(fname, 'r')
+ for line in f:
+ result.append(line.rstrip())
+ # Print the resulting list in the format recognized by ld.
+ print '{'
+ result.sort()
+ for f in result:
+ print ' ' + f + ';'
+ print '};'
-print '{'
-result.sort()
-for f in result:
- print ' ' + f + ';'
-print '};'
+if __name__ == '__main__':
+ main(sys.argv)
OpenPOWER on IntegriCloud