This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Ignore unknown extended opcode in dwarf2 debug line


According to DWARF standard, unknown extended opcode should be ignored.
The dwarf2 reader in bfd emits error for unknown extended opcode and fails
currently. With this patch, unknown extended opcode will be ignored

Testing ELF which has an unknown extended opcode in debug line program:
$ readelf -wl a.bin | grep "Line Number Statements:" -A5
 Line Number Statements:
  [0x00000027]  Extended opcode 2: set Address to 0x400566
  [0x00000032]  Extended opcode 10: UNKNOWN: length 1 [ 00]
  [0x00000036]  Advance PC by constant 17 to 0x400577
  [0x00000037]  Special opcode 34: advance Address by 2 to 0x400579 and
Line by 1 to 2
  [0x00000038]  Advance PC by constant 17 to 0x40058a
$ ~/binutils-gdb/builddir/binutils/addr2line 0x40058b -e a.bin # w/o fix
addr2line: Dwarf Error: mangled line number section.
$ ~/binutils-gdb/builddir/binutils/addr2line 0x40058b -e a.bin # w/ fix


2017-08-26  Jeff Liaw  <>

* dwarf2.c (decode_line_info): Ignore unknown extended opcode.
 bfd/dwarf2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 22d6d56..63ff8d4 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2347,9 +2347,9 @@ decode_line_info (struct comp_unit *unit, struct
dwarf2_debug *stash)
                  line_ptr += exop_len - 1;
-                 _bfd_error_handler
-                   (_("Dwarf Error: mangled line number section."));
-                 bfd_set_error (bfd_error_bad_value);
+                 /* Unknown extended opcode, ignore it.  */
+                 line_ptr += exop_len - 1;
+                 break;
                  if (filename != NULL)
                    free (filename);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]