bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/29337] New: [readelf] CU/TU mixup in .gdb_index


From: vries at gcc dot gnu.org
Subject: [Bug binutils/29337] New: [readelf] CU/TU mixup in .gdb_index
Date: Fri, 08 Jul 2022 09:47:37 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29337

            Bug ID: 29337
           Summary: [readelf] CU/TU mixup in .gdb_index
           Product: binutils
           Version: 2.39 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider a hello.c (probably not relevant, just listing what I used):
...
$ cat hello.c
#include <stdio.h>

int
main (void)
{
  printf
("hello00000000000000000000000000000000000000000000000000000000000000000000\n");
  return 0;
}
...

We compile with gcc 7.5.0, and add a .debug_types section:
...
$ gcc hello.c -g -fdebug-types-section
...

And we add a .debug_index section:
...
$ gdb-add-index a.out
...

Let's print the index entries for a type and a variable:

With 2.37:
...
$ ~/binutils/install/bin/readelf -wg a.out | egrep "_IO_FILE|stdout"
[718] _IO_FILE: T0 [static, type]
[823] stdout: 3 [global, variable]
...

Well, that looks all right.

We have 6 CUs and 1 TU:
...
CU table:
[  0] 0x0 - 0x2d
[  1] 0x2e - 0x6c
[  2] 0x6d - 0x8e
[  3] 0x8f - 0x184
[  4] 0x185 - 0x33c
[  5] 0x33d - 0x35e

TU table:
[  0] 0x0 0x1d f4c23649b49166b7 
...
and indeed the _IO_FILE type is part of the .debug_types section, which
contains a single type unit:
...
Contents of the .debug_types section:

  Compilation Unit @ offset 0x0:
   Length:        0x22a (32-bit)
   Version:       4
   Abbrev Offset: 0x59
   Pointer Size:  8
   Signature:     0xf4c23649b49166b7
   Type Offset:   0x1d
 <0><17>: Abbrev Number: 1 (DW_TAG_type_unit)
    <18>   DW_AT_language    : 12       (ANSI C99)
    <19>   DW_AT_stmt_list   : 0xe8
 <1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1e>   DW_AT_name        : (indirect string, offset: 0x282): _IO_FILE
...
and the stdout variable is part of the CU at 0x8f:
...
  Compilation Unit @ offset 0x8f:
   Length:        0xf2 (32-bit)
   Version:       4
   Abbrev Offset: 0x59
   Pointer Size:  8
 <0><9a>: Abbrev Number: 13 (DW_TAG_compile_unit)
 ...
 <1><120>: Abbrev Number: 16 (DW_TAG_variable)
    <121>   DW_AT_name        : (indirect string, offset: 0x40d): stdout
...
which is listed with index 3 in the CU table.

Let's try again, with 2.38:
...
$ ~/binutils/install/bin/readelf -wg a.out | egrep "_IO_FILE|stdout"
[718] _IO_FILE: T0 [static, type]
[823] stdout: 3 [global, variable]
...

Still looking good.

Not let's try with master:
...
$ ~/binutils/install/bin/readelf -wg a.out | egrep "_IO_FILE|stdout"
[718] _IO_FILE: T3 [static, type]
[823] stdout: T0 [global, variable]
...

Both T3 and T0 look wrong.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]