|
3 | 3 | # Run as: CLANG=bin/clang build_symbolizer.sh out.o
|
4 | 4 | # zlib can be downloaded from http://www.zlib.net.
|
5 | 5 | #
|
6 |
| -# Script compiles self-contained object file with symbolization code and injects |
7 |
| -# it into the given set of runtime libraries. Script updates only libraries |
8 |
| -# which has unresolved __sanitizer_symbolize_* symbols and matches architecture. |
9 |
| -# Object file is be compiled from LLVM sources with dependencies like libc++ and |
10 |
| -# zlib. Then it internalizes symbols in the file, so that it can be linked |
11 |
| -# into arbitrary programs, avoiding conflicts with the program own symbols and |
12 |
| -# avoiding dependencies on any program symbols. The only acceptable dependencies |
13 |
| -# are libc and __sanitizer::internal_* from sanitizer runtime. |
| 6 | +# Script compiles self-contained object file with symbolization code. |
14 | 7 | #
|
15 | 8 | # Symbols exported by the object file will be used by Sanitizer runtime
|
16 | 9 | # libraries to symbolize code/data in-process.
|
17 | 10 | #
|
18 |
| -# The script will modify the output directory which is given as the first |
19 |
| -# argument to the script. |
20 |
| -# |
21 | 11 | # FIXME: We should really be using a simpler approach to building this object
|
22 | 12 | # file, and it should be available as a regular cmake rule. Conceptually, we
|
23 | 13 | # want to be doing "ld -r" followed by "objcopy -G" to create a relocatable
|
24 | 14 | # object file with only our entry points exposed. However, this does not work at
|
25 |
| -# present, see PR30750. |
| 15 | +# present, see https://github.com/llvm/llvm-project/issues/30098. |
26 | 16 |
|
27 | 17 | set -x
|
28 | 18 | set -e
|
29 | 19 | set -u
|
30 | 20 |
|
31 | 21 | SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
32 | 22 | SRC_DIR=$(readlink -f $SCRIPT_DIR/..)
|
33 |
| -TARGE_DIR=$(readlink -f $1) |
| 23 | +OUTPUT=$(readlink -f $1) |
34 | 24 | COMPILER_RT_SRC=$(readlink -f ${SCRIPT_DIR}/../../../..)
|
35 | 25 | LLVM_SRC=${LLVM_SRC:-${COMPILER_RT_SRC}/../llvm}
|
36 | 26 | LLVM_SRC=$(readlink -f $LLVM_SRC)
|
@@ -186,20 +176,6 @@ nm -f posix -g symbolizer.o | cut -f 1,2 -d \ | LC_COLLATE=C sort -u > undefine
|
186 | 176 | (diff -u $SCRIPT_DIR/global_symbols.txt undefined.new | grep -E "^\+[^+]") && \
|
187 | 177 | (echo "Failed: unexpected symbols"; exit 1)
|
188 | 178 |
|
189 |
| -arch() { |
190 |
| - objdump -f $1 | grep -m1 -Po "(?<=file format ).*$" |
191 |
| -} |
192 |
| - |
193 |
| -SYMBOLIZER_FORMAT=$(arch symbolizer.o) |
194 |
| -echo "Injecting $SYMBOLIZER_FORMAT symbolizer..." |
195 |
| -for A in $TARGE_DIR/libclang_rt.*san*.a; do |
196 |
| - A_FORMAT=$(arch $A) |
197 |
| - if [[ "$A_FORMAT" != "$SYMBOLIZER_FORMAT" ]] ; then |
198 |
| - continue |
199 |
| - fi |
200 |
| - (nm -u $A 2>/dev/null | grep -E "__sanitizer_symbolize_code" >/dev/null) || continue |
201 |
| - echo "$A" |
202 |
| - $AR rcs $A symbolizer.o |
203 |
| -done |
| 179 | +cp -f symbolizer.o $OUTPUT |
204 | 180 |
|
205 | 181 | echo "Success!"
|
0 commit comments