From: Mark Wielaard Date: Fri, 15 Feb 2013 21:45:22 +0000 (+0100) Subject: libdw: Handle FORM_GNU_strp_alt for files with string data only in dwz file. X-Git-Tag: elfutils-0.156~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=443304efce95d66ac089d95807a0002cf8558d13;p=thirdparty%2Felfutils.git libdw: Handle FORM_GNU_strp_alt for files with string data only in dwz file. dwarf_formstring should check that the dbg file from which we want the strp data actually has a IDX_debug_str section. Reported-By: Tom Tromey Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 3cf303249..2900ef6c4 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2013-02-15 Mark Wielaard + + * dwarf_formstring.c (dwarf_formstring): Check dbg_ret->sectiondata, + not dbg->sectiondata. + 2013-01-07 Roland McGrath * memory-access.h diff --git a/libdw/dwarf_formstring.c b/libdw/dwarf_formstring.c index c66454e17..02b56d4a1 100644 --- a/libdw/dwarf_formstring.c +++ b/libdw/dwarf_formstring.c @@ -1,5 +1,5 @@ /* Return string associated with given attribute. - Copyright (C) 2003-2010 Red Hat, Inc. + Copyright (C) 2003-2010, 2013 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper , 2003. @@ -60,7 +60,7 @@ dwarf_formstring (attrp) if (unlikely (attrp->form != DW_FORM_strp && attrp->form != DW_FORM_GNU_strp_alt) - || dbg->sectiondata[IDX_debug_str] == NULL) + || dbg_ret->sectiondata[IDX_debug_str] == NULL) { __libdw_seterrno (DWARF_E_NO_STRING); return NULL; diff --git a/tests/ChangeLog b/tests/ChangeLog index 0a26e7ed9..c1e0ef96b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2013-02-15 Mark Wielaard + + * testfile-dwzstr.bz2: New testfile. + * testfile-dwzstr.multi.bz2: Likewise. + * run-readelf-dwz-multi.sh: Add readelf testfile-dwzstr test. + * Makefile.am (EXTRA_DIST): Add testfile-dwzstr.bz2 and + testfile-dwzstr.multi.bz2. + 2013-01-30 Mark Wielaard * testfileloc.bz2: New testfile. diff --git a/tests/Makefile.am b/tests/Makefile.am index a26e5c262..44b4e61bd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -154,6 +154,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-readelf-loc.sh testfileloc.bz2 \ run-readelf-dwz-multi.sh libtestfile_multi_shared.so.bz2 \ testfile_multi.dwz.bz2 testfile_multi_main.bz2 \ + testfile-dwzstr.bz2 testfile-dwzstr.multi.bz2 \ run-prelink-addr-test.sh \ testfile52-32.so.bz2 testfile52-32.so.debug.bz2 \ testfile52-32.prelink.so.bz2 testfile52-32.noshdrs.so.bz2 \ diff --git a/tests/run-readelf-dwz-multi.sh b/tests/run-readelf-dwz-multi.sh index aadbbbe11..20c00c5fb 100755 --- a/tests/run-readelf-dwz-multi.sh +++ b/tests/run-readelf-dwz-multi.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2012 Red Hat, Inc. +# Copyright (C) 2012, 2013 Red Hat, Inc. # This file is part of elfutils. # # This file is free software; you can redistribute it and/or modify @@ -56,7 +56,27 @@ # gcc -g -o testfile_multi_main -L. -ltestfile_multi_shared main.c -Wl,-rpath,. # dwz -m testfile_multi.dwz testfile_multi_main libtestfile_multi_shared.so +# main.c +# +# struct foobarbaz +# { +# int counter; +# char *bookstore; +# }; +# +# int +# main (int argc, char **argv) +# { +# struct foobarbaz fbb; +# return 0; +# } + +# gcc -g -o testfile-dwzstr main.c +# cp testfile-dwzstr testfile-dwzstr.alt +# dwz -m testfile-dwzstr.multi testfile-dwzstr testfile-dwzstr.alt + testfiles libtestfile_multi_shared.so testfile_multi_main testfile_multi.dwz +testfiles testfile-dwzstr testfile-dwzstr.multi testrun_compare ../src/readelf --debug-dump=info testfile_multi_main <<\EOF @@ -153,4 +173,55 @@ DWARF section [25] '.debug_info' at offset 0x106c: [ 0] fbreg -24 EOF +testrun_compare ../src/readelf --debug-dump=info testfile-dwzstr <<\EOF + +DWARF section [28] '.debug_info' at offset 0x1088: + [Offset] + Compilation unit at offset 0: + Version: 4, Abbreviation section offset: 0, Address size: 8, Offset size: 4 + [ b] compile_unit + producer (GNU_strp_alt) "GNU C 4.7.2 20121109 (Red Hat 4.7.2-8) -mtune=generic -march=x86-64 -g" + language (data1) C89 (1) + name (GNU_strp_alt) "main.c" + comp_dir (GNU_strp_alt) "/home/mark/src/tests" + low_pc (addr) 0x00000000004004ec
+ high_pc (udata) 18 + stmt_list (sec_offset) 0 + [ 26] imported_unit + import (GNU_ref_alt) [ b] + [ 2b] subprogram + external (flag_present) + name (GNU_strp_alt) "main" + decl_file (data1) 1 + decl_line (data1) 8 + prototyped (flag_present) + type (GNU_ref_alt) [ 30] + low_pc (addr) 0x00000000004004ec
+ high_pc (udata) 18 + frame_base (exprloc) + [ 0] call_frame_cfa + GNU_all_call_sites (flag_present) + [ 41] formal_parameter + name (GNU_strp_alt) "argc" + decl_file (data1) 1 + decl_line (data1) 8 + type (GNU_ref_alt) [ 30] + location (exprloc) + [ 0] fbreg -36 + [ 4f] formal_parameter + name (GNU_strp_alt) "argv" + decl_file (data1) 1 + decl_line (data1) 8 + type (GNU_ref_alt) [ 41] + location (exprloc) + [ 0] fbreg -48 + [ 5d] variable + name (string) "fbb" + decl_file (data1) 1 + decl_line (data1) 10 + type (GNU_ref_alt) [ 14] + location (exprloc) + [ 0] fbreg -32 +EOF + exit 0 diff --git a/tests/testfile-dwzstr.bz2 b/tests/testfile-dwzstr.bz2 new file mode 100755 index 000000000..8d2d326e0 Binary files /dev/null and b/tests/testfile-dwzstr.bz2 differ diff --git a/tests/testfile-dwzstr.multi.bz2 b/tests/testfile-dwzstr.multi.bz2 new file mode 100644 index 000000000..5e84991d4 Binary files /dev/null and b/tests/testfile-dwzstr.multi.bz2 differ