]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/testsuite] Fix gdb.arch/amd64-entry-value-paramref.S
authorTom de Vries <tdevries@suse.de>
Wed, 8 May 2019 22:41:26 +0000 (00:41 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 8 May 2019 22:41:26 +0000 (00:41 +0200)
commit9cfd2b89bd3fe943a87d5425d0bb0f8b14c85eb6
tree7223f7a73a35912a21ddd1eba53aef126562315f
parent7a1021395e0ef7a92e1653533b753a2221396015
[gdb/testsuite] Fix gdb.arch/amd64-entry-value-paramref.S

The file gdb.arch/amd64-entry-value-paramref.S contains a DIE for function
bar:
...
DIE29:  .uleb128 0x2    # (DIE (0x29) DW_TAG_subprogram)
        .ascii "bar\0"  # DW_AT_name
        .byte   0x1     # DW_AT_decl_file (gdb.arch/amd64-entry-value-paramref.cc)
        .byte   0x15    # DW_AT_decl_line
        .long   DIE45   # DW_AT_type
        .byte   0x1     # DW_AT_inline
...
which refers to DIE45:
...
DIE45: .uleb128 0x4 # (DIE (0x45) DW_TAG_base_type)
.byte 0x4 # DW_AT_byte_size
.byte 0x5 # DW_AT_encoding
.ascii "int\0" # DW_AT_name
...
using a form DW_FORM_ref4:
...
.uleb128 0x2 # (abbrev code)
.uleb128 0x2e # (TAG: DW_TAG_subprogram)
.byte 0x1 # DW_children_yes
...
.uleb128 0x49 # (DW_AT_type)
.uleb128 0x13 # (DW_FORM_ref4)
...

However, the DW_FORM_ref4 is a CU-relative reference, while using a label for
the value will result in a section-relative value.

So, if linked in object files contain dwarf info and are placed in the
.debug_info section before the compilation units generated from
amd64-entry-value-paramref.S, then the referenced type is at 0x108:
...
 <1><108>: Abbrev Number: 4 (DW_TAG_base_type)
    <109>   DW_AT_byte_size   : 4
    <10a>   DW_AT_encoding    : 5       (signed)
    <10b>   DW_AT_name        : int
...
but the reference will point to a non-existing DIE at 0x1cf:
...
 <1><f0>: Abbrev Number: 2 (DW_TAG_subprogram)
    <f1>   DW_AT_name        : bar
    <f5>   DW_AT_decl_file   : 1
    <f6>   DW_AT_decl_line   : 21
    <f7>   DW_AT_type        : <0x1cf>
    <fb>   DW_AT_inline      : 1        (inlined)
...
which happens to cause a GDB internal error described in PR23270 - "GDB
internal error: dwarf2read.c:18656: internal-error: could not find partial
DIE 0x1b7 in cache".

Fix the invalid DWARF by making the reference value CU-relative:
...
-       .long   DIE45   # DW_AT_type
+       .long   DIE45 - .Ldebug_info0   # DW_AT_type
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-05-09  Tom de Vries  <tdevries@suse.de>

* gdb.arch/amd64-entry-value-paramref.S: Make DW_FORM_ref4 references
CU-relative.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.arch/amd64-entry-value-paramref.S