|
| 1 | +C_SOURCES := main.c |
| 2 | +CFLAGS_EXTRAS := -std=c99 |
| 3 | + |
| 4 | +MAKE_DWO := YES |
| 5 | +SPLIT_DEBUG_SYMBOLS := YES |
| 6 | +KEEP_FULL_DEBUG_BINARY := YES |
| 7 | +MERGE_DWOS := YES |
| 8 | + |
| 9 | +# From shell, I can do this stuff pretty easily: |
| 10 | +# OBJCOPY --dump-section .note.gnu.build-id=<output.36.bytes.bin> <input.bin> |
| 11 | +# hexdump -s 16 -e '"%02x"' output.bin |
| 12 | +# Or this in a single command: |
| 13 | +# objcopy --dump-section=.note.gnu.build-id=/dev/stdout adfinder.stripped | xxd -s 16 -g 0 -p |
| 14 | +# I think I need to add capabilities in the Makefile.rules to strip the binary (not an -OKD binary) |
| 15 | +# and to create a DWP file |
| 16 | + |
| 17 | +include Makefile.rules |
| 18 | + |
| 19 | + |
| 20 | +#!/bin/sh |
| 21 | + |
| 22 | +# Testing 5 different scenarios: |
| 23 | +# 1 - A stripped binary with it's corresponding unstripped binary: |
| 24 | +# 2 - A stripped binary with a corresponding --only-keep-debug symbols file |
| 25 | +# 3 - A split binary with it's corresponding DWP file |
| 26 | +# 4 - A stripped, split binary with an unstripped binary and a DWP file |
| 27 | +# 5 - A stripped, split binary with an --only-keep-debug symbols file and a DWP file |
| 28 | + |
| 29 | +##mkdir -p gen |
| 30 | +##mkdir -p run |
| 31 | + |
| 32 | +# First, compile & link the binaries (normal and split) |
| 33 | + |
| 34 | +##${builddir}/bin/clang -g -o gen/bin-normal.o -O0 -c main.c |
| 35 | +##ld -nostdlib gen/bin-normal.o --build-id=sha1 -o gen/bin-normal |
| 36 | +##${builddir}/bin/clang -g -gsplit-dwarf -o gen/bin-split.o -O0 -c main.c |
| 37 | +##ld -nostdlib gen/bin-split.o --build-id=sha1 -o gen/bin-split |
| 38 | + |
| 39 | +# Next, create the file variations we need |
| 40 | + |
| 41 | +# Variation 1: -g, stripped |
| 42 | +##${builddir}/bin/llvm-objcopy --strip-debug gen/bin-normal gen/bin-stripped |
| 43 | +# Variation 2: -g, stripped, --only-keep-debug symbols |
| 44 | +##${builddir}/bin/llvm-objcopy --only-keep-debug gen/bin-normal gen/sym-stripped |
| 45 | +# Variation 3: -gsplit-dwarf: .dwp |
| 46 | +##${builddir}/bin/llvm-dwp -e gen/bin-split -o gen/bin-split.dwp |
| 47 | +# Variation 4: -gsplit-dwarf: stripped, .dwp |
| 48 | +##${builddir}/bin/llvm-objcopy --strip-debug gen/bin-split gen/bin-split-stripped |
| 49 | +# Variation 5: -gsplit-dwarf: stripped, --only-keep-debug + .dwp |
| 50 | +##${builddir}/bin/llvm-objcopy --only-keep-debug gen/bin-split gen/sym-split |
| 51 | + |
| 52 | +# Finally, produce the .yaml files for testing |
| 53 | + |
| 54 | +# Scenario 1: |
| 55 | +# target: bin-stripped |
| 56 | +# Scenario 1a: |
| 57 | +# symbols: bin-normal (hosted as debuginfo) |
| 58 | +# Scenario 1b: |
| 59 | +# symbols: bin-normal (hosted as executable) |
| 60 | +##${builddir}/bin/obj2yaml gen/bin-stripped -o bin-stripped.yaml |
| 61 | +##${builddir}/bin/obj2yaml gen/bin-normal -o bin-normal.yaml |
| 62 | +# @ testing time: yaml2obj bin-stripped.yaml -o ${out}/bin-stripped |
| 63 | +# @ testing time: yaml2obj bin-normal.yaml -o ${out}/bin-normal |
| 64 | + |
| 65 | + |
| 66 | +# Scenario 2: |
| 67 | +# target: bin-stripped-okd |
| 68 | +# Scenario 2a: |
| 69 | +# symbols: sym-stripped (hosted as debuginfo) |
| 70 | +# Scenario 2b: |
| 71 | +# symbols: sym-stripped (hosted as executable) |
| 72 | +##${builddir}/bin/obj2yaml gen/sym-stripped -o sym-stripped.yaml |
| 73 | +# To produce a correct .gnu.debuglink, you have to do it at test generation time. |
| 74 | +# The section includes a CRC that yaml2obj doesn't properly produce. |
| 75 | +# @ testing time: yaml2obj sym-stripped.yaml -o ${out}/sym-stripped |
| 76 | +# @ testing time: llvm-objcopy bin-stripped --add-gnu-debuglink=${out}/sym-stripped ${out}/bin-stripped-okd |
| 77 | + |
| 78 | +# Scenario 3: |
| 79 | +# target: bin-split |
| 80 | +# DWP: bin-split.dwp (hosted as debuginfo) |
| 81 | +##${builddir}/bin/obj2yaml gen/bin-split -o bin-split.yaml |
| 82 | +##${builddir}/bin/obj2yaml gen/bin-split.dwp -o bin-split-dwp.yaml |
| 83 | +# @ testing time: yaml2obj bin-split.yaml -o ${out}/bin-split |
| 84 | +# @ testing time: yaml2obj bin-split-dwp.yaml -o ${out}/bin-split.dwp |
| 85 | + |
| 86 | +# Scenario 4: |
| 87 | +# target: bin-split-stripped |
| 88 | +# symbols: bin-split (hosted as executable) |
| 89 | +# DWP bin-split.dwp (hosted as debuginfo) |
| 90 | +# This doesn't work from a file system "as is". |
| 91 | +# I believe you can set the symbol file manually to the bin-split file. |
| 92 | +# TODO: Need to check for the -no-locator test to see what the name of |
| 93 | +# the .dwp is expected to be. |
| 94 | +##${builddir}/bin/obj2yaml gen/bin-split-stripped -o bin-split-stripped.yaml |
| 95 | +# bin-split and bin-split.dwp already generated in Scenario 3 |
| 96 | +# @ testing time: yaml2obj bin-split-stripped.yaml -o ${out}/bin-split-stripped |
| 97 | + |
| 98 | +# Scenario 5: |
| 99 | +# target: bin-split-stripped-okd |
| 100 | +# symbols: sym-split (hosted as executable) |
| 101 | +# DWP: bin-split.dwp (hosted as debuginfo) |
| 102 | +##${builddir}/bin/obj2yaml gen/sym-split -o sym-split.yaml |
| 103 | +# @ testing time: yaml2obj main-split-nodbg.yaml -o gen/main-split-nodbg.tmp |
| 104 | +# @ testing time: yaml2obj main-split-dbg.yaml -o run/main-split-dbg |
| 105 | +# @ testing time: llvm-objcopy gen/main-split-nodbg.tmp --add-gnu-debuglink=run/main-split-dbg run/main-split-nodbg |
0 commit comments