]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw: Handle FORM_GNU_strp_alt for files with string data only in dwz file.
authorMark Wielaard <mjw@redhat.com>
Fri, 15 Feb 2013 21:45:22 +0000 (22:45 +0100)
committerMark Wielaard <mjw@redhat.com>
Fri, 15 Feb 2013 21:45:22 +0000 (22:45 +0100)
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 <tromey@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libdw/ChangeLog
libdw/dwarf_formstring.c
tests/ChangeLog
tests/Makefile.am
tests/run-readelf-dwz-multi.sh
tests/testfile-dwzstr.bz2 [new file with mode: 0755]
tests/testfile-dwzstr.multi.bz2 [new file with mode: 0644]

index 3cf303249c2e581cedf15fee05adbf8bddd6dee6..2900ef6c42fed246fa89e904b8a92baa01353be2 100644 (file)
@@ -1,3 +1,8 @@
+2013-02-15  Mark Wielaard  <mjw@redhat.com>
+
+       * dwarf_formstring.c (dwarf_formstring): Check dbg_ret->sectiondata,
+       not dbg->sectiondata.
+
 2013-01-07  Roland McGrath  <roland@hack.frob.com>
 
        * memory-access.h
index c66454e17d20807beb5a011a8cd6fc9342958f0d..02b56d4a13c5c8af0bf9911e17c1789fde09cadb 100644 (file)
@@ -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 <drepper@redhat.com>, 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;
index 0a26e7ed9a00eeb3ced77ed1c8192eedc7470417..c1e0ef96b601ffc4f8ec396dd81eef8184209b2d 100644 (file)
@@ -1,3 +1,11 @@
+2013-02-15  Mark Wielaard  <mjw@redhat.com>
+
+       * 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  <mjw@redhat.com>
 
        * testfileloc.bz2: New testfile.
index a26e5c262347d0356d64541f045bb3116100c225..44b4e61bdaba55d28a1ccb345a782c3058870868 100644 (file)
@@ -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 \
index aadbbbe11f452ed534ae845467d800ea86ce86ca..20c00c5fba818d16cab4bcd4b823072cb07ae208 100755 (executable)
@@ -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
 # 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 <main>
+           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 <main>
+             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 (executable)
index 0000000..8d2d326
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 (file)
index 0000000..5e84991
Binary files /dev/null and b/tests/testfile-dwzstr.multi.bz2 differ