From bad0cbc72a9bf05c7c4884a1d6a7ecd09ef4f880 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 21 Apr 2022 19:23:51 +0800 Subject: [PATCH] Revert "Remove a test that doesn't work yet" This reverts commit bd65e0908f4a70fd32b1526479b98a1e628781f2 because --gdb-index should now work with DWARF5. --- test/elf/gdb-index-dwarf5.sh | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 test/elf/gdb-index-dwarf5.sh diff --git a/test/elf/gdb-index-dwarf5.sh b/test/elf/gdb-index-dwarf5.sh new file mode 100755 index 00000000..3e05cd9d --- /dev/null +++ b/test/elf/gdb-index-dwarf5.sh @@ -0,0 +1,57 @@ +#!/bin/bash +export LC_ALL=C +set -e +CC="${CC:-cc}" +CXX="${CXX:-c++}" +GCC="${GCC:-gcc}" +GXX="${GXX:-g++}" +OBJDUMP="${OBJDUMP:-objdump}" +MACHINE="${MACHINE:-$(uname -m)}" +testname=$(basename "$0" .sh) +echo -n "Testing $testname ... " +cd "$(dirname "$0")"/../.. +mold="$(pwd)/mold" +t=out/test/elf/$testname +mkdir -p $t + +[ $MACHINE = $(uname -m) ] || { echo skipped; exit; } + +which gdb >& /dev/null || { echo skipped; exit; } + +echo 'int main() {}' | $CC -o /dev/null -xc -gdwarf-5 -g - >& /dev/null || + { echo skipped; exit; } + +cat < $t/a.c +#include + +void hello() { + printf("Hello world\n"); +} + +void greet() { + hello(); +} +EOF + +$CC -o $t/b.o -c -ggnu-pubnames -gdwarf-5 -g $t/a.c +$CC -o $t/c.o -c -ggnu-pubnames -gdwarf-5 -g $t/a.c -gz + +cat <& /dev/null + +$CC -B. -o $t/exe2 $t/c.o $t/d.o -Wl,--gdb-index +$QEMU $t/exe2 | grep -q 'Hello world' +readelf -WS $t/exe2 | fgrep -q .gdb_index +DEBUGINFOD_URLS= gdb $t/exe2 -ex 'b main' -ex run -ex cont -ex quit >& /dev/null + +echo OK