|
1 | 1 | #!/bin/sh
|
2 | 2 |
|
3 |
| -# I need 4 different scenarios: |
| 3 | +# I need 5 different scenarios: |
4 | 4 | # 1 - A stripped binary with it's corresponding unstripped binary:
|
5 |
| -# 2 - A stripped binary with a corresponding -only-keep-debug symbols file |
| 5 | +# 2 - A stripped binary with a corresponding --only-keep-debug symbols file |
6 | 6 | # 3 - A split binary with it's corresponding DWP file
|
7 | 7 | # 4 - A stripped, split binary with an unstripped binary and a DWP file
|
| 8 | +# 5 - A stripped, split binary with an --only-keep-debug symbols file and a DWP file |
8 | 9 |
|
9 | 10 | mkdir -p gen
|
10 | 11 | mkdir -p run
|
11 | 12 |
|
12 |
| -# First, compile & link the binary itself |
13 |
| -${builddir}/bin/clang -g -o gen/main-full.o -O0 -c main.c |
14 |
| -ld -nostdlib gen/main-full.o --build-id=sha1 -o gen/main-full |
15 |
| -${builddir}/bin/clang -g -gsplit-dwarf -o gen/main-split.o -O0 -c main.c |
16 |
| -ld -nostdlib gen/main-split.o --build-id=sha1 -o gen/main-split |
17 |
| -${builddir}/bin/llvm-dwp -e gen/main-split -o gen/main-split.dwp |
18 |
| - |
19 |
| -# Scenario 1: main-strip -> main-full (both executable and debuginfo) |
20 |
| -${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-stripped |
21 |
| -${builddir}/bin/obj2yaml gen/main-full > main-full.yaml |
22 |
| -${builddir}/bin/obj2yaml gen/main-stripped > main-stripped.yaml |
23 |
| -# MAKE: ${builddir}/bin/yaml2obj main-full.yaml > run/main-full |
24 |
| -# MAKE: ${builddir}/bin/yaml2obj main-stripped.yaml > run/main-stripped |
25 |
| - |
26 |
| -# Scenario 2: main-nodbg -> main-dbg (debuginfo) |
27 |
| -${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-full gen/main-dbg |
28 |
| -${builddir}/bin/llvm-objcopy --strip-debug gen/main-full gen/main-nodbg |
29 |
| -${builddir}/bin/obj2yaml gen/main-nodbg > main-nodbg.yaml |
30 |
| -${builddir}/bin/obj2yaml gen/main-dbg > main-dbg.yaml |
31 |
| -# MAKE: ${builddir}/bin/yaml2obj main-nodbg.yaml > gen/main-nodbg.tmp |
32 |
| -# MAKE: ${builddir}/bin/yaml2obj main-dbg.yaml > run/main-dbg |
33 |
| -# MAKE: ${builddir}/bin/llvm-objcopy gen/main-nodbg.tmp --add-gnu-debuglink=run/main-dbg run/main-nodbg |
34 |
| - |
35 |
| -# Scenario 3: main-split, main-split.dwp (debuginfo) |
36 |
| -${builddir}/bin/obj2yaml gen/main-split > main-split.yaml |
37 |
| -${builddir}/bin/obj2yaml gen/main-split.dwp > main-dwp.yaml |
38 |
| -# MAKE: ${builddir}/bin/yaml2obj main-split.yaml > run/main-split |
39 |
| -# MAKE: ${builddir}/bin/yaml2obj main-dwp.yaml > run/main-split.dwp |
40 |
| - |
41 |
| -# Scenario 4: main-split-nodbg, main-split-dbg (executable), main-split.dwp (debuginfo) |
42 |
| -${builddir}/bin/llvm-objcopy --only-keep-debug gen/main-split gen/main-split-dbg |
43 |
| -${builddir}/bin/llvm-objcopy --strip-debug gen/main-split gen/main-split-nodbg |
44 |
| -${builddir}/bin/obj2yaml gen/main-split-nodbg > main-split-nodbg.yaml |
45 |
| -${builddir}/bin/obj2yaml gen/main-split-dbg > main-split-dbg.yaml |
46 |
| -# MAKE: ${builddir}/bin/yaml2obj main-split-nodbg.yaml > gen/main-split-nodbg.tmp |
47 |
| -# MAKE: ${builddir}/bin/yaml2obj main-split-dbg.yaml > run/main-split-dbg |
48 |
| -# MAKE: ${builddir}/bin/llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg |
49 |
| -# the main-dwp.yaml should be the same, I believe |
50 |
| - |
51 |
| -# MAKE: chmod a+x run/* |
| 13 | +# First, compile & link the binaries (normal and split) |
| 14 | + |
| 15 | +${builddir}/bin/clang -g -o gen/bin-normal.o -O0 -c main.c |
| 16 | +ld -nostdlib gen/bin-normal.o --build-id=sha1 -o gen/bin-normal |
| 17 | +${builddir}/bin/clang -g -gsplit-dwarf -o gen/bin-split.o -O0 -c main.c |
| 18 | +ld -nostdlib gen/bin-split.o --build-id=sha1 -o gen/bin-split |
| 19 | + |
| 20 | +# Next, create the file variations we need |
| 21 | + |
| 22 | +# Variation 1: -g, stripped |
| 23 | +${builddir}/bin/llvm-objcopy --strip-debug gen/bin-normal gen/bin-stripped |
| 24 | +# Variation 2: -g, stripped, --only-keep-debug symbols |
| 25 | +${builddir}/bin/llvm-objcopy --only-keep-debug gen/bin-normal gen/sym-stripped |
| 26 | +# Variation 3: -gsplit-dwarf: .dwp |
| 27 | +${builddir}/bin/llvm-dwp -e gen/bin-split -o gen/bin-split.dwp |
| 28 | +# Variation 4: -gsplit-dwarf: stripped, .dwp |
| 29 | +${builddir}/bin/llvm-objcopy --strip-debug gen/bin-split gen/bin-split-stripped |
| 30 | +# Variation 5: -gsplit-dwarf: stripped, --only-keep-debug + .dwp |
| 31 | +${builddir}/bin/llvm-objcopy --only-keep-debug gen/bin-split gen/sym-split |
| 32 | + |
| 33 | +# Finally, produce the .yaml files for testing |
| 34 | + |
| 35 | +# Scenario 1: |
| 36 | +# target: bin-stripped |
| 37 | +# Scenario 1a: |
| 38 | +# symbols: bin-normal (hosted as debuginfo) |
| 39 | +# Scenario 1b: |
| 40 | +# symbols: bin-normal (hosted as executable) |
| 41 | +${builddir}/bin/obj2yaml gen/bin-stripped -o bin-stripped.yaml |
| 42 | +${builddir}/bin/obj2yaml gen/bin-normal -o bin-normal.yaml |
| 43 | +# @ testing time: yaml2obj bin-stripped.yaml -o ${out}/bin-stripped |
| 44 | +# @ testing time: yaml2obj bin-normal.yaml -o ${out}/bin-normal |
| 45 | + |
| 46 | + |
| 47 | +# Scenario 2: |
| 48 | +# target: bin-stripped-okd |
| 49 | +# Scenario 2a: |
| 50 | +# symbols: sym-stripped (hosted as debuginfo) |
| 51 | +# Scenario 2b: |
| 52 | +# symbols: sym-stripped (hosted as executable) |
| 53 | +${builddir}/bin/obj2yaml gen/sym-stripped -o sym-stripped.yaml |
| 54 | +# To produce a correct .gnu.debuglink, you have to do it at test generation time. |
| 55 | +# The section includes a CRC that yaml2obj doesn't properly produce. |
| 56 | +# @ testing time: yaml2obj sym-stripped.yaml -o ${out}/sym-stripped |
| 57 | +# @ testing time: llvm-objcopy bin-stripped --add-gnu-debuglink=${out}/sym-stripped ${out}/bin-stripped-okd |
| 58 | + |
| 59 | +# Scenario 3: |
| 60 | +# target: bin-split |
| 61 | +# DWP: bin-split.dwp (hosted as debuginfo) |
| 62 | +${builddir}/bin/obj2yaml gen/bin-split -o bin-split.yaml |
| 63 | +${builddir}/bin/obj2yaml gen/bin-split.dwp -o bin-split-dwp.yaml |
| 64 | +# @ testing time: yaml2obj bin-split.yaml -o ${out}/bin-split |
| 65 | +# @ testing time: yaml2obj bin-split-dwp.yaml -o ${out}/bin-split.dwp |
| 66 | + |
| 67 | +# Scenario 4: |
| 68 | +# target: bin-split-stripped |
| 69 | +# symbols: bin-split (hosted as executable) |
| 70 | +# DWP bin-split.dwp (hosted as debuginfo) |
| 71 | +# This doesn't work from a file system "as is". |
| 72 | +# I believe you can set the symbol file manually to the bin-split file. |
| 73 | +# TODO: Need to check for the -no-locator test to see what the name of |
| 74 | +# the .dwp is expected to be. |
| 75 | +${builddir}/bin/obj2yaml gen/bin-split-stripped -o bin-split-stripped.yaml |
| 76 | +# bin-split and bin-split.dwp already generated in Scenario 3 |
| 77 | +# @ testing time: yaml2obj bin-split-stripped.yaml -o ${out}/bin-split-stripped |
| 78 | + |
| 79 | +# Scenario 5: |
| 80 | +# target: bin-split-stripped-okd |
| 81 | +# symbols: sym-split (hosted as executable) |
| 82 | +# DWP: bin-split.dwp (hosted as debuginfo) |
| 83 | +${builddir}/bin/obj2yaml gen/sym-split -o sym-split.yaml |
| 84 | +# @ testing time: yaml2obj main-split-nodbg.yaml -o gen/main-split-nodbg.tmp |
| 85 | +# @ testing time: yaml2obj main-split-dbg.yaml -o run/main-split-dbg |
| 86 | +# @ testing time: llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg |
0 commit comments