Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dtrace-prelink.sh « data - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cb6508f0cef76c8fe7ea9418342ceab15aaf0668 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
# 
# dtrace-prelink.sh: DTrace helper script for Mono
# 
# Authors:
#   Andreas Faerber <andreas.faerber@web.de>
# 

# Assume that PIC object files live in .libs/, non-PIC code in ./
PIC=no
if test "$1" = "--pic"; then
	PIC=yes
	shift
fi

OBJ="$1"
PROV="$2"

shift
shift

FILES="$*"

OBJS=
TMPDIR=.dtrace
mkdir -p "${TMPDIR}"

# Extract relevant object files to temporary directories
for FILE in ${FILES}; do
	if echo "${FILE}" | grep .la > /dev/null; then
		LIBDIR=`dirname ${FILE}`
		LIB=".libs/`basename ${FILE} .la`.a"
		DIR="${TMPDIR}/`basename ${FILE}`"
		mkdir -p ${DIR}
		(cd "${DIR}" && ${AR} x "../../${LIBDIR}/${LIB}")
		TMPOBJS=`ls -1 "${DIR}"`
		for TMPOBJ in ${TMPOBJS}; do
			LO=`basename "${TMPOBJ}" .o`.lo
			SRCOBJ="${TMPOBJ}"
			if test x${PIC} = xyes; then
				SRCOBJ=".libs/${SRCOBJ}"
			fi
			# Overwrite with original version
			cp "${LIBDIR}/${SRCOBJ}" "${DIR}/${TMPOBJ}" || cp "${LIBDIR}/${TMPOBJ}" "${DIR}/${TMPOBJ}" || exit
			# Add to list
			OBJS="${OBJS} ${DIR}/${TMPOBJ}"
		done
	fi
	if echo "${FILE}" | grep .lo > /dev/null; then
		DIR=`dirname ${FILE}`
		SRCOBJ=`basename ${FILE} .lo`.o
		if test x${PIC} = xyes; then
			SRCOBJ=".libs/${SRCOBJ}"
		fi
		OBJS="${OBJS} ${DIR}/${SRCOBJ}"
	fi
done

# Run dtrace -G over the temporary objects
${DTRACE} -G ${DTRACEFLAGS} -s "${PROV}" -o "${OBJ}" ${OBJS} || exit

# Update the archives with the temporary, modified object files so that they are linked in
for FILE in ${FILES}; do
	if echo "${FILE}" | grep .la > /dev/null; then
		LIBDIR=`dirname ${FILE}`
		LIB=".libs/`basename ${FILE} .la`.a"
		DIR="${TMPDIR}/`basename ${FILE}`"
		(cd "${DIR}" && ${AR} r "../../${LIBDIR}/${LIB}" *.o)
	fi
	# .lo files were modified in-place
done

rm -rf "${TMPDIR}"