Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,96 @@
#!/usr/bin/env python
#===- lib/dfsan/scripts/build-libc-list.py ---------------------------------===#
#
# The LLVM Compiler Infrastructure
#
# This file is distributed under the University of Illinois Open Source
# License. See LICENSE.TXT for details.
#
#===------------------------------------------------------------------------===#
# The purpose of this script is to identify every function symbol in a set of
# libraries (in this case, libc and libgcc) so that they can be marked as
# uninstrumented, thus allowing the instrumentation pass to treat calls to those
# functions correctly.
import os
import subprocess
import sys
from optparse import OptionParser
def defined_function_list(object):
functions = []
readelf_proc = subprocess.Popen(['readelf', '-s', '-W', object],
stdout=subprocess.PIPE)
readelf = readelf_proc.communicate()[0].split('\n')
if readelf_proc.returncode != 0:
raise subprocess.CalledProcessError(readelf_proc.returncode, 'readelf')
for line in readelf:
if (line[31:35] == 'FUNC' or line[31:36] == 'IFUNC') and \
line[39:44] != 'LOCAL' and \
line[55:58] != 'UND':
function_name = line[59:].split('@')[0]
functions.append(function_name)
return functions
p = OptionParser()
p.add_option('--libc-dso-path', metavar='PATH',
help='path to libc DSO directory',
default='/lib/x86_64-linux-gnu')
p.add_option('--libc-archive-path', metavar='PATH',
help='path to libc archive directory',
default='/usr/lib/x86_64-linux-gnu')
p.add_option('--libgcc-dso-path', metavar='PATH',
help='path to libgcc DSO directory',
default='/lib/x86_64-linux-gnu')
p.add_option('--libgcc-archive-path', metavar='PATH',
help='path to libgcc archive directory',
default='/usr/lib/gcc/x86_64-linux-gnu/4.6')
p.add_option('--with-libstdcxx', action='store_true',
dest='with_libstdcxx',
help='include libstdc++ in the list (inadvisable)')
p.add_option('--libstdcxx-dso-path', metavar='PATH',
help='path to libstdc++ DSO directory',
default='/usr/lib/x86_64-linux-gnu')
(options, args) = p.parse_args()
libs = [os.path.join(options.libc_dso_path, name) for name in
['ld-linux-x86-64.so.2',
'libanl.so.1',
'libBrokenLocale.so.1',
'libcidn.so.1',
'libcrypt.so.1',
'libc.so.6',
'libdl.so.2',
'libm.so.6',
'libnsl.so.1',
'libpthread.so.0',
'libresolv.so.2',
'librt.so.1',
'libthread_db.so.1',
'libutil.so.1']]
libs += [os.path.join(options.libc_archive_path, name) for name in
['libc_nonshared.a',
'libpthread_nonshared.a']]
libs.append(os.path.join(options.libgcc_dso_path, 'libgcc_s.so.1'))
libs.append(os.path.join(options.libgcc_archive_path, 'libgcc.a'))
if options.with_libstdcxx:
libs.append(os.path.join(options.libstdcxx_dso_path, 'libstdc++.so.6'))
functions = []
for l in libs:
if os.path.exists(l):
functions += defined_function_list(l)
else:
print >> sys.stderr, 'warning: library %s not found' % l
functions = list(set(functions))
functions.sort()
for f in functions:
print 'fun:%s=uninstrumented' % f

View File

@ -0,0 +1,52 @@
#!/bin/sh
DFSAN_DIR=$(dirname "$0")/../
DFSAN_CUSTOM_TESTS=${DFSAN_DIR}/../../test/dfsan/custom.cc
DFSAN_CUSTOM_WRAPPERS=${DFSAN_DIR}/dfsan_custom.cc
DFSAN_ABI_LIST=${DFSAN_DIR}/done_abilist.txt
DIFFOUT=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
ERRORLOG=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
DIFF_A=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
DIFF_B=$(mktemp -q /tmp/tmp.XXXXXXXXXX)
on_exit() {
rm -f ${DIFFOUT} 2> /dev/null
rm -f ${ERRORLOG} 2> /dev/null
rm -f ${DIFF_A} 2> /dev/null
rm -f ${DIFF_B} 2> /dev/null
}
# Ignore __sanitizer_cov_trace* because they are implemented elsewhere.
trap on_exit EXIT
grep -E "^fun:.*=custom" ${DFSAN_ABI_LIST} \
| grep -v "dfsan_get_label\|__sanitizer_cov_trace" \
| sed "s/^fun:\(.*\)=custom.*/\1/" | sort > $DIFF_A
grep -E "__dfsw.*\(" ${DFSAN_CUSTOM_WRAPPERS} \
| sed "s/.*__dfsw_\(.*\)(.*/\1/" | sort > $DIFF_B
diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
if [ $? -ne 0 ]
then
echo -n "The following differences between the ABI list and ">> ${ERRORLOG}
echo "the implemented custom wrappers have been found:" >> ${ERRORLOG}
cat ${DIFFOUT} >> ${ERRORLOG}
fi
grep -E __dfsw_ ${DFSAN_CUSTOM_WRAPPERS} \
| sed "s/.*__dfsw_\([^(]*\).*/\1/" | sort > $DIFF_A
grep -E "^[[:space:]]*test_.*\(\);" ${DFSAN_CUSTOM_TESTS} \
| sed "s/.*test_\(.*\)();/\1/" | sort > $DIFF_B
diff -u $DIFF_A $DIFF_B > ${DIFFOUT}
if [ $? -ne 0 ]
then
echo -n "The following differences between the implemented " >> ${ERRORLOG}
echo "custom wrappers and the tests have been found:" >> ${ERRORLOG}
cat ${DIFFOUT} >> ${ERRORLOG}
fi
if [ -s ${ERRORLOG} ]
then
cat ${ERRORLOG}
exit 1
fi