aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNatarajan, Kavitha <Kavitha.Natarajan@amd.com>2022-05-25 16:10:38 +0100
committerNick Clifton <nickc@redhat.com>2022-05-25 16:10:38 +0100
commit3ac9da49378ccb061e3e33e4342c35949bf368a9 (patch)
tree173d88e8e612392b746047d59ac8797f170a2b13 /binutils
parentcce0ae568c7e30e0a7b8d1bd77f8c4b7d7b8ce7b (diff)
downloadgdb-3ac9da49378ccb061e3e33e4342c35949bf368a9.zip
gdb-3ac9da49378ccb061e3e33e4342c35949bf368a9.tar.gz
gdb-3ac9da49378ccb061e3e33e4342c35949bf368a9.tar.bz2
Add bionutils support for DWARF v5's DW_OP_addrx.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/dwarf.c17
-rw-r--r--binutils/testsuite/binutils-all/objdump.exp43
-rw-r--r--binutils/testsuite/binutils-all/readelf.exp22
3 files changed, 76 insertions, 6 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index a0dfd4d..caa3ce4 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1721,6 +1721,10 @@ decode_location_expression (unsigned char * data,
printf ("DW_OP_GNU_parameter_ref: <0x%s>",
dwarf_vmatoa ("x", cu_offset + uvalue));
break;
+ case DW_OP_addrx:
+ READ_ULEB (uvalue, data, end);
+ printf ("DW_OP_addrx <0x%s>", dwarf_vmatoa ("x", uvalue));
+ break;
case DW_OP_GNU_addr_index:
READ_ULEB (uvalue, data, end);
printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue));
@@ -2661,10 +2665,15 @@ read_and_display_attr_value (unsigned long attribute,
uvalue = check_uvalue (block_start, uvalue, end);
- if (do_loc)
- data = block_start + uvalue;
- else
- data = display_block (block_start, uvalue, end, delimiter);
+ data = block_start + uvalue;
+ if (!do_loc)
+ {
+ unsigned char op;
+
+ SAFE_BYTE_GET (op, block_start, sizeof (op), end);
+ if (op != DW_OP_addrx)
+ data = display_block (block_start, uvalue, end, delimiter);
+ }
break;
case DW_FORM_block1:
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index 0f160ae..fb09942 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -513,6 +513,47 @@ if { ![is_elf_format] } then {
}
}
+# Test objdump -Wi on a file containing dwarf-5 encodings information.
+
+if { ![is_elf_format] } then {
+ unsupported "objdump DW_OP_* test"
+} elseif { ![binutils_assemble $srcdir/$subdir/dw5-op.S tmpdir/dw5-op.${obj}] } then {
+ fail "objdump DW_OP_* test"
+} else {
+ if [is_remote host] {
+ set op_testfile [remote_download host tmpdir/dw5-op.${obj}]
+ } else {
+ set op_testfile tmpdir/dw5-op.${obj}
+ }
+
+ set got [remote_exec host "$OBJDUMP $OBJDUMPFLAGS -Wi $op_testfile" "" "/dev/null" "objdump.out"]
+
+ if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
+ fail "objdump -Wi (reason: unexpected output)"
+ send_log $got
+ send_log "\n"
+ }
+
+ set got [remote_exec host "tail -n +4 objdump.out" "" "/dev/null" "objdump.out"]
+ set output [remote_upload host objdump.out]
+
+ if ![file size $output] then {
+ # If the output file is empty, then this target does not
+ # generate dwarf2 output. This is not a failure.
+ verbose "No output from 'objdump -Wi'"
+ untested "objdump -Wi"
+ return
+ }
+
+ if { [regexp_diff objdump.out $srcdir/$subdir/dw5-op.W] } then {
+ fail "objdump -Wi for DW_OP_*"
+ } else {
+ pass "objdump -Wi for DW_OP_*"
+ }
+
+ file_on_host delete $output
+}
+
proc test_build_id_debuglink {} {
global srcdir
global subdir
@@ -817,7 +858,7 @@ proc test_objdump_S { } {
global OBJDUMP
global OBJDUMPFLAGS
global exe
-
+
set test "objdump -S"
if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog${exe} executable debug] != "" } {
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index 8ff756e..0f7a1f3 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -488,11 +488,12 @@ if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then {
readelf_test {--decompress --hex-dump .debug_loc} $tempfile readelf.z
}
+set hpux ""
+
# Skip the next test for the RISCV architectures because they
# do not support .ULEB128 pseudo-ops with non-constant values.
if ![istarget "riscv*-*-*"] then {
- set hpux ""
if [istarget "hppa*64*-*-hpux*"] {
set hpux "--defsym HPUX=1"
}
@@ -596,3 +597,22 @@ if ![is_remote host] {
readelf_test {--debug-dump=macro -wN} $tempfile pr26112.r
}
}
+
+# Check dwarf-5 support for DW_OP_addrx.
+if {![binutils_assemble_flags $srcdir/$subdir/dw5-op.S tmpdir/dw5-op.o $hpux]} then {
+ unsupported "readelf -wi dw5-op (failed to assemble)"
+} else {
+
+# Download it.
+if ![is_remote host] {
+ set tempfile tmpdir/dw5-op.o
+} else {
+ set tempfile [remote_download host tmpdir/dw5-op.o]
+}
+
+# First, determine the size, so specific output matchers can be used.
+readelf_find_size $tempfile 2
+
+# Make sure that readelf can decode the contents.
+readelf_test -wi $tempfile dw5-op.W
+}