summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_begin_elf.c32
-rw-r--r--tests/ChangeLog14
-rw-r--r--tests/Makefile.am13
-rwxr-xr-xtests/run-varlocs-vars.sh93
-rw-r--r--tests/testfile-vars-clang-dwarf4-32.o.bz2bin0 -> 568 bytes
-rw-r--r--tests/testfile-vars-clang-dwarf4-64.o.bz2bin0 -> 605 bytes
-rw-r--r--tests/testfile-vars-clang-dwarf5-32.o.bz2bin0 -> 741 bytes
-rw-r--r--tests/testfile-vars-clang-dwarf5-64.o.bz2bin0 -> 761 bytes
-rw-r--r--tests/testfile-vars-gcc-dwarf4-32.o.bz2bin0 -> 660 bytes
-rw-r--r--tests/testfile-vars-gcc-dwarf4-64.o.bz2bin0 -> 691 bytes
-rw-r--r--tests/testfile-vars-gcc-dwarf5-32.o.bz2bin0 -> 728 bytes
-rw-r--r--tests/testfile-vars-gcc-dwarf5-64.o.bz2bin0 -> 768 bytes
13 files changed, 149 insertions, 8 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index b5462ef4..78a6bd39 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
12021-09-08 Mark Wielaard <mark@klomp.org>
2
3 * dwarf_begin_elf.c (valid_p): Identify ELF class and use this to set
4 address_size of the fake CUs. Also set offset_size and DWARF version.
5
12021-04-19 Martin Liska <mliska@suse.cz> 62021-04-19 Martin Liska <mliska@suse.cz>
2 7
3 * dwarf_begin_elf.c (check_section): Use startswith. 8 * dwarf_begin_elf.c (check_section): Use startswith.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 9e944b86..a368feb8 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -224,6 +224,23 @@ valid_p (Dwarf *result)
224 result = NULL; 224 result = NULL;
225 } 225 }
226 226
227 /* We are setting up some "fake" CUs, which need an address size.
228 Check the ELF class to come up with something reasonable. */
229 int elf_addr_size = 8;
230 if (result != NULL)
231 {
232 GElf_Ehdr ehdr;
233 if (gelf_getehdr (result->elf, &ehdr) == NULL)
234 {
235 Dwarf_Sig8_Hash_free (&result->sig8_hash);
236 __libdw_seterrno (DWARF_E_INVALID_ELF);
237 free (result);
238 result = NULL;
239 }
240 else if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
241 elf_addr_size = 4;
242 }
243
227 /* For dwarf_location_attr () we need a "fake" CU to indicate 244 /* For dwarf_location_attr () we need a "fake" CU to indicate
228 where the "fake" attribute data comes from. This is a block 245 where the "fake" attribute data comes from. This is a block
229 inside the .debug_loc or .debug_loclists section. */ 246 inside the .debug_loc or .debug_loclists section. */
@@ -247,8 +264,9 @@ valid_p (Dwarf *result)
247 = (result->sectiondata[IDX_debug_loc]->d_buf 264 = (result->sectiondata[IDX_debug_loc]->d_buf
248 + result->sectiondata[IDX_debug_loc]->d_size); 265 + result->sectiondata[IDX_debug_loc]->d_size);
249 result->fake_loc_cu->locs = NULL; 266 result->fake_loc_cu->locs = NULL;
250 result->fake_loc_cu->address_size = 0; 267 result->fake_loc_cu->address_size = elf_addr_size;
251 result->fake_loc_cu->version = 0; 268 result->fake_loc_cu->offset_size = 4;
269 result->fake_loc_cu->version = 4;
252 result->fake_loc_cu->split = NULL; 270 result->fake_loc_cu->split = NULL;
253 } 271 }
254 } 272 }
@@ -274,8 +292,9 @@ valid_p (Dwarf *result)
274 = (result->sectiondata[IDX_debug_loclists]->d_buf 292 = (result->sectiondata[IDX_debug_loclists]->d_buf
275 + result->sectiondata[IDX_debug_loclists]->d_size); 293 + result->sectiondata[IDX_debug_loclists]->d_size);
276 result->fake_loclists_cu->locs = NULL; 294 result->fake_loclists_cu->locs = NULL;
277 result->fake_loclists_cu->address_size = 0; 295 result->fake_loclists_cu->address_size = elf_addr_size;
278 result->fake_loclists_cu->version = 0; 296 result->fake_loclists_cu->offset_size = 4;
297 result->fake_loclists_cu->version = 5;
279 result->fake_loclists_cu->split = NULL; 298 result->fake_loclists_cu->split = NULL;
280 } 299 }
281 } 300 }
@@ -306,8 +325,9 @@ valid_p (Dwarf *result)
306 = (result->sectiondata[IDX_debug_addr]->d_buf 325 = (result->sectiondata[IDX_debug_addr]->d_buf
307 + result->sectiondata[IDX_debug_addr]->d_size); 326 + result->sectiondata[IDX_debug_addr]->d_size);
308 result->fake_addr_cu->locs = NULL; 327 result->fake_addr_cu->locs = NULL;
309 result->fake_addr_cu->address_size = 0; 328 result->fake_addr_cu->address_size = elf_addr_size;
310 result->fake_addr_cu->version = 0; 329 result->fake_addr_cu->offset_size = 4;
330 result->fake_addr_cu->version = 5;
311 result->fake_addr_cu->split = NULL; 331 result->fake_addr_cu->split = NULL;
312 } 332 }
313 } 333 }
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 42989d19..45762852 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,17 @@
12021-09-08 Mark Wielaard <mark@klomp.org>
2
3 * run-varlocs-vars.sh: New test.
4 * testfile-vars-clang-dwarf4-32.o.bz2: New test file.
5 * testfile-vars-clang-dwarf4-64.o.bz2: Likewise.
6 * testfile-vars-clang-dwarf5-32.o.bz2: Likewise.
7 * testfile-vars-clang-dwarf5-64.o.bz2: Likewise.
8 * testfile-vars-gcc-dwarf4-32.o.bz2: Likewise.
9 * testfile-vars-gcc-dwarf4-64.o.bz2: Likewise.
10 * testfile-vars-gcc-dwarf5-32.o.bz2: Likewise.
11 * testfile-vars-gcc-dwarf5-64.o.bz2: Likewise.
12 * Makefile.am (EXTRA_DIST): Add new test and test files.
13 (TESTS): Add run-varlocs-vars.sh.
14
12021-09-07 Mark Wielaard <mark@klomp.org> 152021-09-07 Mark Wielaard <mark@klomp.org>
2 16
3 * run-debuginfod-archive-groom.sh: Wait for initial scan and groom 17 * run-debuginfod-archive-groom.sh: Wait for initial scan and groom
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c586422e..22942733 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -143,7 +143,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
143 run-dwfl-report-elf-align.sh run-addr2line-test.sh \ 143 run-dwfl-report-elf-align.sh run-addr2line-test.sh \
144 run-addr2line-i-test.sh run-addr2line-i-lex-test.sh \ 144 run-addr2line-i-test.sh run-addr2line-i-lex-test.sh \
145 run-addr2line-i-demangle-test.sh run-addr2line-alt-debugpath.sh \ 145 run-addr2line-i-demangle-test.sh run-addr2line-alt-debugpath.sh \
146 run-varlocs.sh run-exprlocs.sh run-funcretval.sh \ 146 run-varlocs.sh run-exprlocs.sh run-varlocs-vars.sh run-funcretval.sh \
147 run-backtrace-native.sh run-backtrace-data.sh run-backtrace-dwarf.sh \ 147 run-backtrace-native.sh run-backtrace-data.sh run-backtrace-dwarf.sh \
148 run-backtrace-native-biarch.sh run-backtrace-native-core.sh \ 148 run-backtrace-native-biarch.sh run-backtrace-native-core.sh \
149 run-backtrace-native-core-biarch.sh run-backtrace-core-x86_64.sh \ 149 run-backtrace-native-core-biarch.sh run-backtrace-core-x86_64.sh \
@@ -399,7 +399,16 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
399 testfileppc32.bz2 testfileppc64.bz2 \ 399 testfileppc32.bz2 testfileppc64.bz2 \
400 testfiles390.bz2 testfiles390x.bz2 \ 400 testfiles390.bz2 testfiles390x.bz2 \
401 testfilearm.bz2 testfileaarch64.bz2 \ 401 testfilearm.bz2 testfileaarch64.bz2 \
402 run-varlocs.sh run-exprlocs.sh testfile-stridex.bz2 \ 402 run-varlocs.sh run-exprlocs.sh run-varlocs-vars.sh \
403 testfile-vars-clang-dwarf4-32.o.bz2 \
404 testfile-vars-clang-dwarf4-64.o.bz2 \
405 testfile-vars-clang-dwarf5-32.o.bz2 \
406 testfile-vars-clang-dwarf5-64.o.bz2 \
407 testfile-vars-gcc-dwarf4-32.o.bz2 \
408 testfile-vars-gcc-dwarf4-64.o.bz2 \
409 testfile-vars-gcc-dwarf5-32.o.bz2 \
410 testfile-vars-gcc-dwarf5-64.o.bz2 \
411 testfile-stridex.bz2 \
403 testfile_const_type.c testfile_const_type.bz2 \ 412 testfile_const_type.c testfile_const_type.bz2 \
404 testfile_implicit_pointer.c testfile_implicit_pointer.bz2 \ 413 testfile_implicit_pointer.c testfile_implicit_pointer.bz2 \
405 testfile_parameter_ref.c testfile_parameter_ref.bz2 \ 414 testfile_parameter_ref.c testfile_parameter_ref.bz2 \
diff --git a/tests/run-varlocs-vars.sh b/tests/run-varlocs-vars.sh
new file mode 100755
index 00000000..e7598bf0
--- /dev/null
+++ b/tests/run-varlocs-vars.sh
@@ -0,0 +1,93 @@
1#! /bin/sh
2# Copyright (C) 2013, 2021 Red Hat, Inc.
3# This file is part of elfutils.
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or
8# (at your option) any later version.
9#
10# elfutils is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18. $srcdir/test-subr.sh
19
20# Testfiles generated with:
21#
22# $ cat foo.c
23# int x = 1;
24# int y = 2;
25#
26# for cc in gcc clang; do
27# for v in 4 5; do
28# for w in 32 64; do
29# out="testfile-vars-$cc-dwarf$v-$w.o"
30# "$cc" -m"$w" -Wall -Wextra -gdwarf-"$v" -c foo.c -o "$out"
31# done
32# done
33# done
34
35testfiles testfile-vars-clang-dwarf4-32.o
36testfiles testfile-vars-clang-dwarf4-64.o
37testfiles testfile-vars-clang-dwarf5-32.o
38testfiles testfile-vars-clang-dwarf5-64.o
39testfiles testfile-vars-gcc-dwarf4-32.o
40testfiles testfile-vars-gcc-dwarf4-64.o
41testfiles testfile-vars-gcc-dwarf5-32.o
42testfiles testfile-vars-gcc-dwarf5-64.o
43
44tempfiles varlocs.out
45testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-clang-dwarf4-32.o | grep exprloc > varlocs.out
46diff -u varlocs.out - <<EOF
47 location (exprloc) {addr(0x0)}
48 location (exprloc) {addr(0x4)}
49EOF
50
51testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-clang-dwarf4-64.o | grep exprloc > varlocs.out
52diff -u varlocs.out - <<EOF
53 location (exprloc) {addr(0x0)}
54 location (exprloc) {addr(0x4)}
55EOF
56
57testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-clang-dwarf5-32.o | grep exprloc > varlocs.out
58diff -u varlocs.out - <<EOF
59 location (exprloc) {addr: 0x0}
60 location (exprloc) {addr: 0x4}
61EOF
62
63testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-clang-dwarf5-32.o | grep exprloc > varlocs.out
64diff -u varlocs.out - <<EOF
65 location (exprloc) {addr: 0x0}
66 location (exprloc) {addr: 0x4}
67EOF
68
69testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-gcc-dwarf4-32.o | grep exprloc > varlocs.out
70diff -u varlocs.out - <<EOF
71 location (exprloc) {addr(0x0)}
72 location (exprloc) {addr(0x4)}
73EOF
74
75testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-gcc-dwarf4-64.o | grep exprloc > varlocs.out
76diff -u varlocs.out - <<EOF
77 location (exprloc) {addr(0x0)}
78 location (exprloc) {addr(0x4)}
79EOF
80
81testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-gcc-dwarf5-32.o | grep exprloc > varlocs.out
82diff -u varlocs.out - <<EOF
83 location (exprloc) {addr(0x0)}
84 location (exprloc) {addr(0x4)}
85EOF
86
87testrun ${abs_top_builddir}/tests/varlocs --debug --exprlocs -e testfile-vars-gcc-dwarf5-64.o | grep exprloc > varlocs.out
88diff -u varlocs.out - <<EOF
89 location (exprloc) {addr(0x0)}
90 location (exprloc) {addr(0x4)}
91EOF
92
93exit 0
diff --git a/tests/testfile-vars-clang-dwarf4-32.o.bz2 b/tests/testfile-vars-clang-dwarf4-32.o.bz2
new file mode 100644
index 00000000..c1ddf81f
--- /dev/null
+++ b/tests/testfile-vars-clang-dwarf4-32.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-clang-dwarf4-64.o.bz2 b/tests/testfile-vars-clang-dwarf4-64.o.bz2
new file mode 100644
index 00000000..df33299f
--- /dev/null
+++ b/tests/testfile-vars-clang-dwarf4-64.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-clang-dwarf5-32.o.bz2 b/tests/testfile-vars-clang-dwarf5-32.o.bz2
new file mode 100644
index 00000000..b1d6b6c4
--- /dev/null
+++ b/tests/testfile-vars-clang-dwarf5-32.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-clang-dwarf5-64.o.bz2 b/tests/testfile-vars-clang-dwarf5-64.o.bz2
new file mode 100644
index 00000000..adf6c6a5
--- /dev/null
+++ b/tests/testfile-vars-clang-dwarf5-64.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-gcc-dwarf4-32.o.bz2 b/tests/testfile-vars-gcc-dwarf4-32.o.bz2
new file mode 100644
index 00000000..da9aac73
--- /dev/null
+++ b/tests/testfile-vars-gcc-dwarf4-32.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-gcc-dwarf4-64.o.bz2 b/tests/testfile-vars-gcc-dwarf4-64.o.bz2
new file mode 100644
index 00000000..26421644
--- /dev/null
+++ b/tests/testfile-vars-gcc-dwarf4-64.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-gcc-dwarf5-32.o.bz2 b/tests/testfile-vars-gcc-dwarf5-32.o.bz2
new file mode 100644
index 00000000..cb1c7054
--- /dev/null
+++ b/tests/testfile-vars-gcc-dwarf5-32.o.bz2
Binary files differ
diff --git a/tests/testfile-vars-gcc-dwarf5-64.o.bz2 b/tests/testfile-vars-gcc-dwarf5-64.o.bz2
new file mode 100644
index 00000000..e286f8f7
--- /dev/null
+++ b/tests/testfile-vars-gcc-dwarf5-64.o.bz2
Binary files differ