Handle DW_OP_GNU_implicit_pointer in dwarf assembler
authorYao Qi <yao.qi@linaro.org>
Wed, 25 Jan 2017 16:24:44 +0000 (16:24 +0000)
committerYao Qi <yao.qi@linaro.org>
Wed, 25 Jan 2017 16:24:44 +0000 (16:24 +0000)
DW_OP_GNU_implicit_pointer refers to a DIE with an offset of different
sizes in different dwarf versions.  In v2, the size is the pointer size,
while in v3 and above, it is the ref_addr size.  This patch fixes
dwarf assembler to emit the correct size of offset.  We've already fixed
this size issue in gdb,
https://sourceware.org/ml/gdb-patches/2011-09/msg00451.html

gdb/testsuite:

2017-01-25  Yao Qi  <yao.qi@linaro.org>

* lib/dwarf.exp (Dwarf::_location): Handle
DW_OP_GNU_implicit_pointer with proper size.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/dwarf.exp

index 4d197116132996e7f90ae915be1d781ea3121231..aa272e345deb2bb738ee717aa22847dd355ab71c 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-25  Yao Qi  <yao.qi@linaro.org>
+
+       * lib/dwarf.exp (Dwarf::_location): Handle
+       DW_OP_GNU_implicit_pointer with proper size.
+
 2017-01-20  Luis Machado  <lgustavo@codesourcery.com>
 
        * gdb.python/py-xmethods.exp: Fix test names starting with lowercase
index 9f5fa6ca09f1a31e0ad62d095caae36310c7a29f..03ae63746cb5198fa360684ccb3f4a8d01976954 100644 (file)
@@ -840,6 +840,7 @@ namespace eval Dwarf {
     proc _location {body} {
        variable _constants
        variable _cu_label
+       variable _cu_version
        variable _cu_addr_size
        variable _cu_offset_size
 
@@ -913,7 +914,11 @@ namespace eval Dwarf {
 
                    # Here label is a section offset.
                    set label [lindex $line 1]
-                   _op .${_cu_offset_size}byte $label
+                   if { $_cu_version == 2 } {
+                       _op .${_cu_addr_size}byte $label
+                   } else {
+                       _op .${_cu_offset_size}byte $label
+                   }
                    _op .sleb128 [lindex $line 2]
                }