public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/6] DWARF attrs: add delimiter
@ 2017-02-15 22:58 Jan Kratochvil
  2017-02-15 22:58 ` [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
                   ` (6 more replies)
  0 siblings, 7 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-15 22:58 UTC (permalink / raw)
  To: binutils; +Cc: Victor Leschuk

Hi,

currently DWARF attributes are always prefixed by ' '.
But DWARF-5 file name table needs to prefix it by 't':
 The File name Table (offset 0x30):
  Entry Dir     Name
  0     0       (indirect line string, offset: 0x0): /home/jkratoch/t/classic.C
  1     1       (indirect line string, offset: 0x11): classic.C

Jan


2017-02-12  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (display_block): Add parameter delimiter.
	(decode_location_expression): Update display_block callers.
	(read_and_display_attr_value): Add parameter delimiter.
	(read_and_display_attr, display_debug_macro): Update
	read_and_display_attr_value caller.
---
 binutils/dwarf.c |   50 +++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 0184a7a..368c498 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -871,11 +871,11 @@ get_FORM_name (unsigned long form)
 static unsigned char *
 display_block (unsigned char *data,
 	       dwarf_vma length,
-	       const unsigned char * const end)
+	       const unsigned char * const end, char delimiter)
 {
   dwarf_vma maxlen;
 
-  printf (_(" %s byte block: "), dwarf_vmatoa ("u", length));
+  printf (_("%c%s byte block: "), delimiter, dwarf_vmatoa ("u", length));
   if (data > end)
     return (unsigned char *) end;
 
@@ -1268,7 +1268,7 @@ decode_location_expression (unsigned char * data,
 	  printf ("DW_OP_implicit_value");
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
-	  data = display_block (data, uvalue, end);
+	  data = display_block (data, uvalue, end, ' ');
 	  break;
 
 	  /* GNU extensions.  */
@@ -1337,7 +1337,7 @@ decode_location_expression (unsigned char * data,
 	  printf ("DW_OP_GNU_const_type: <0x%s> ",
 		  dwarf_vmatoa ("x", cu_offset + uvalue));
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  data = display_block (data, uvalue, end);
+	  data = display_block (data, uvalue, end, ' ');
 	  break;
 	case DW_OP_GNU_regval_type:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
@@ -1508,7 +1508,7 @@ read_and_display_attr_value (unsigned long attribute,
 			     debug_info * debug_info_p,
 			     int do_loc,
 			     struct dwarf_section * section,
-			     struct cu_tu_set * this_set)
+			     struct cu_tu_set * this_set, char delimiter)
 {
   dwarf_vma uvalue = 0;
   unsigned char *block_start = NULL;
@@ -1587,12 +1587,12 @@ read_and_display_attr_value (unsigned long attribute,
       form = read_uleb128 (data, & bytes_read, end);
       data += bytes_read;
       if (!do_loc)
-	printf (" %s", get_FORM_name (form));
+	printf ("%c%s", delimiter, get_FORM_name (form));
       return read_and_display_attr_value (attribute, form, data, end,
 					  cu_offset, pointer_size,
 					  offset_size, dwarf_version,
 					  debug_info_p, do_loc,
-					  section, this_set);
+					  section, this_set, delimiter);
     case DW_FORM_GNU_addr_index:
       uvalue = read_uleb128 (data, & bytes_read, end);
       data += bytes_read;
@@ -1603,12 +1603,12 @@ read_and_display_attr_value (unsigned long attribute,
     {
     case DW_FORM_ref_addr:
       if (!do_loc)
-	printf (" <0x%s>", dwarf_vmatoa ("x",uvalue));
+	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x",uvalue));
       break;
 
     case DW_FORM_GNU_ref_alt:
       if (!do_loc)
-	printf (" <alt 0x%s>", dwarf_vmatoa ("x",uvalue));
+	printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x",uvalue));
       break;
 
     case DW_FORM_ref1:
@@ -1616,14 +1616,14 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_FORM_ref4:
     case DW_FORM_ref_udata:
       if (!do_loc)
-	printf (" <0x%s>", dwarf_vmatoa ("x", uvalue + cu_offset));
+	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset));
       break;
 
     case DW_FORM_data4:
     case DW_FORM_addr:
     case DW_FORM_sec_offset:
       if (!do_loc)
-	printf (" 0x%s", dwarf_vmatoa ("x", uvalue));
+	printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", uvalue));
       break;
 
     case DW_FORM_flag_present:
@@ -1633,7 +1633,7 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_FORM_sdata:
     case DW_FORM_udata:
       if (!do_loc)
-	printf (" %s", dwarf_vmatoa ("d", uvalue));
+	printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue));
       break;
 
     case DW_FORM_ref8:
@@ -1648,7 +1648,7 @@ read_and_display_attr_value (unsigned long attribute,
 	  utmp = uvalue;
 	  if (form == DW_FORM_ref8)
 	    add64 (& high_bits, & utmp, cu_offset);
-	  printf (" 0x%s",
+	  printf ("%c0x%s", delimiter,
 		  dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf)));
 	}
 
@@ -1666,7 +1666,7 @@ read_and_display_attr_value (unsigned long attribute,
 
     case DW_FORM_string:
       if (!do_loc)
-	printf (" %.*s", (int) (end - data), data);
+	printf ("%c%.*s", delimiter, (int) (end - data), data);
       data += strnlen ((char *) data, end - data) + 1;
       break;
 
@@ -1693,7 +1693,7 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_block1:
@@ -1714,7 +1714,7 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_block2:
@@ -1735,7 +1735,7 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_block4:
@@ -1759,12 +1759,12 @@ read_and_display_attr_value (unsigned long attribute,
       if (do_loc)
 	data = block_start + uvalue;
       else
-	data = display_block (block_start, uvalue, end);
+	data = display_block (block_start, uvalue, end, delimiter);
       break;
 
     case DW_FORM_strp:
       if (!do_loc)
-	printf (_(" (indirect string, offset: 0x%s): %s"),
+	printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter,
 		dwarf_vmatoa ("x", uvalue),
 		fetch_indirect_string (uvalue));
       break;
@@ -1775,7 +1775,7 @@ read_and_display_attr_value (unsigned long attribute,
 	  const char *suffix = strrchr (section->name, '.');
 	  int dwo = (suffix && strcmp (suffix, ".dwo") == 0) ? 1 : 0;
 
-	  printf (_(" (indexed string: 0x%s): %s"),
+	  printf (_("%c(indexed string: 0x%s): %s"), delimiter,
 		  dwarf_vmatoa ("x", uvalue),
 		  fetch_indexed_string (uvalue, this_set, offset_size, dwo));
 	}
@@ -1783,7 +1783,7 @@ read_and_display_attr_value (unsigned long attribute,
 
     case DW_FORM_GNU_strp_alt:
       if (!do_loc)
-	printf (_(" (alt indirect string, offset: 0x%s)"),
+	printf (_("%c(alt indirect string, offset: 0x%s)"), delimiter,
 		dwarf_vmatoa ("x", uvalue));
       break;
 
@@ -1798,7 +1798,7 @@ read_and_display_attr_value (unsigned long attribute,
 	  char buf[64];
 
 	  SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end);
-	  printf (" signature: 0x%s",
+	  printf ("%csignature: 0x%s", delimiter,
 		  dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
 	}
       data += 8;
@@ -1806,7 +1806,7 @@ read_and_display_attr_value (unsigned long attribute,
 
     case DW_FORM_GNU_addr_index:
       if (!do_loc)
-	printf (_(" (addr_index: 0x%s): %s"),
+	printf (_("%c(addr_index: 0x%s): %s"), delimiter,
 		dwarf_vmatoa ("x", uvalue),
 		fetch_indexed_value (uvalue * pointer_size, pointer_size));
       break;
@@ -2233,7 +2233,7 @@ read_and_display_attr (unsigned long attribute,
   data = read_and_display_attr_value (attribute, form, data, end,
 				      cu_offset, pointer_size, offset_size,
 				      dwarf_version, debug_info_p,
-				      do_loc, section, this_set);
+				      do_loc, section, this_set, ' ');
   if (!do_loc)
     printf ("\n");
   return data;
@@ -4332,7 +4332,7 @@ display_debug_macro (struct dwarf_section *section,
 			= read_and_display_attr_value (0, val,
 						       curr, end, 0, 0, offset_size,
 						       version, NULL, 0, NULL,
-						       NULL);
+						       NULL, ' ');
 		      if (n != nargs - 1)
 			printf (",");
 		    }

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 4/6] DWARF-5: call sites
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
  2017-02-15 22:58 ` [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-15 22:58 ` Jan Kratochvil
  2017-02-22 11:49   ` Nick Clifton
  2017-02-15 22:58 ` [PATCH 2/6] Display user op byte Jan Kratochvil
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-15 22:58 UTC (permalink / raw)
  To: binutils; +Cc: Victor Leschuk

Hi,

this patch updates all call sites related DWARF-5 renames.

Jan


binutils/ChangeLog
2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer,
	DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert
	and DW_OP_reinterpret.
	(read_and_display_attr_value): Support DW_AT_call_value,
	DW_AT_call_data_value, DW_AT_call_target and
	DW_AT_call_target_clobbered.
---
 binutils/dwarf.c |   43 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index adb9c09..18c1eee 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1323,12 +1323,16 @@ decode_location_expression (unsigned char * data,
 	    print_dwarf_vma (addr, pointer_size);
 	  }
 	  break;
+	case DW_OP_implicit_pointer:
 	case DW_OP_GNU_implicit_pointer:
 	  /* XXX: Strictly speaking for 64-bit DWARF3 files
 	     this ought to be an 8-byte wide computation.  */
 	  if (dwarf_version == -1)
 	    {
-	      printf (_("(DW_OP_GNU_implicit_pointer in frame info)"));
+	      printf (_("(%s in frame info)"),
+		      (op == DW_OP_implicit_pointer
+		       ? "DW_OP_implicit_pointer"
+		       : "DW_OP_GNU_implicit_pointer"));
 	      /* No way to tell where the next op is, so just bail.  */
 	      return need_frame_base;
 	    }
@@ -1340,7 +1344,9 @@ decode_location_expression (unsigned char * data,
 	    {
 	      SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
 	    }
-	  printf ("DW_OP_GNU_implicit_pointer: <0x%s> %s",
+	  printf ("%s: <0x%s> %s",
+		  (op == DW_OP_implicit_pointer
+		   ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"),
 		  dwarf_vmatoa ("x", uvalue),
 		  dwarf_vmatoa ("d", read_sleb128 (data,
 						   &bytes_read, end)));
@@ -1364,40 +1370,55 @@ decode_location_expression (unsigned char * data,
 	  if (data > end)
 	    data = end;
 	  break;
+	case DW_OP_const_type:
 	case DW_OP_GNU_const_type:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
-	  printf ("DW_OP_GNU_const_type: <0x%s> ",
+	  printf ("%s: <0x%s> ",
+		  (op == DW_OP_const_type ? "DW_OP_const_type"
+					  : "DW_OP_GNU_const_type"),
 		  dwarf_vmatoa ("x", cu_offset + uvalue));
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
 	  data = display_block (data, uvalue, end, ' ');
 	  break;
+	case DW_OP_regval_type:
 	case DW_OP_GNU_regval_type:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
-	  printf ("DW_OP_GNU_regval_type: %s (%s)",
+	  printf ("%s: %s (%s)",
+		  (op == DW_OP_regval_type ? "DW_OP_regval_type"
+					   : "DW_OP_GNU_regval_type"),
 		  dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
 	  printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
 	  break;
+	case DW_OP_deref_type:
 	case DW_OP_GNU_deref_type:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  printf ("DW_OP_GNU_deref_type: %ld", (long) uvalue);
+	  printf ("%s: %ld",
+		  (op == DW_OP_deref_type ? "DW_OP_deref_type"
+					  : "DW_OP_GNU_deref_type"),
+		  (long) uvalue);
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
 	  printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
 	  break;
+	case DW_OP_convert:
 	case DW_OP_GNU_convert:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
-	  printf ("DW_OP_GNU_convert <0x%s>",
+	  printf ("%s <0x%s>",
+		  (op == DW_OP_convert ? "DW_OP_convert" : "DW_OP_GNU_convert"),
 		  dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
 	  break;
+	case DW_OP_reinterpret:
 	case DW_OP_GNU_reinterpret:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
-	  printf ("DW_OP_GNU_reinterpret <0x%s>",
+	  printf ("%s <0x%s>",
+		  (op == DW_OP_reinterpret ? "DW_OP_reinterpret"
+					   : "DW_OP_GNU_reinterpret"),
 		  dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
 	  break;
 	case DW_OP_GNU_parameter_ref:
@@ -1885,9 +1906,13 @@ read_and_display_attr_value (unsigned long attribute,
 	case DW_AT_segment:
 	case DW_AT_static_link:
 	case DW_AT_use_location:
+	case DW_AT_call_value:
 	case DW_AT_GNU_call_site_value:
+	case DW_AT_call_data_value:
 	case DW_AT_GNU_call_site_data_value:
+	case DW_AT_call_target:
 	case DW_AT_GNU_call_site_target:
+	case DW_AT_call_target_clobbered:
 	case DW_AT_GNU_call_site_target_clobbered:
 	  if ((dwarf_version < 4
 	       && (form == DW_FORM_data4 || form == DW_FORM_data8))
@@ -2161,9 +2186,13 @@ read_and_display_attr_value (unsigned long attribute,
     case DW_AT_segment:
     case DW_AT_static_link:
     case DW_AT_use_location:
+    case DW_AT_call_value:
     case DW_AT_GNU_call_site_value:
+    case DW_AT_call_data_value:
     case DW_AT_GNU_call_site_data_value:
+    case DW_AT_call_target:
     case DW_AT_GNU_call_site_target:
+    case DW_AT_call_target_clobbered:
     case DW_AT_GNU_call_site_target_clobbered:
       if ((dwarf_version < 4
 	   && (form == DW_FORM_data4 || form == DW_FORM_data8))

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 5/6] DWARF-5: Macros
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
                   ` (3 preceding siblings ...)
  2017-02-15 22:58 ` [PATCH 6/6] DWARF-5: DW_FORM_data16 Jan Kratochvil
@ 2017-02-15 22:58 ` Jan Kratochvil
  2017-02-22 11:50   ` Nick Clifton
  2017-02-16 10:59 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
  2017-02-22 11:48 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
  6 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-15 22:58 UTC (permalink / raw)
  To: binutils; +Cc: Victor Leschuk

Hi,

DWARF-5 renamed DW_MACRO_GNU_* to DW_MACRO_*.

Jan


binutils/ChangeLog
2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (display_debug_macro): Support DWARF-5.  Rename
	DW_MACRO_GNU_*.
---
 binutils/dwarf.c |   56 +++++++++++++++++++++++++++---------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 18c1eee..94b366b 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -4548,9 +4548,9 @@ display_debug_macro (struct dwarf_section *section,
       unsigned char **extended_ops = NULL;
 
       SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
-      if (version != 4)
+      if (version != 4 && version != 5)
 	{
-	  error (_("Only GNU extension to DWARF 4 of %s is currently supported.\n"),
+	  error (_("Only GNU extension to DWARF 4 or 5 of %s is currently supported.\n"),
 		 section->name);
 	  return 0;
 	}
@@ -4587,10 +4587,10 @@ display_debug_macro (struct dwarf_section *section,
 		  nargs = read_uleb128 (curr, &bytes_read, end);
 		  curr += bytes_read;
 		  if (nargs == 0)
-		    printf (_("    DW_MACRO_GNU_%02x has no arguments\n"), op);
+		    printf (_("    DW_MACRO_%02x has no arguments\n"), op);
 		  else
 		    {
-		      printf (_("    DW_MACRO_GNU_%02x arguments: "), op);
+		      printf (_("    DW_MACRO_%02x arguments: "), op);
 		      for (n = 0; n < nargs; n++)
 			{
 			  unsigned int form;
@@ -4643,7 +4643,7 @@ display_debug_macro (struct dwarf_section *section,
 
 	  switch (op)
 	    {
-	    case DW_MACRO_GNU_start_file:
+	    case DW_MACRO_start_file:
 	      {
 		unsigned int filenum;
 		unsigned char *file_name = NULL, *dir_name = NULL;
@@ -4654,87 +4654,87 @@ display_debug_macro (struct dwarf_section *section,
 		curr += bytes_read;
 
 		if ((flags & 2) == 0)
-		  error (_("DW_MACRO_GNU_start_file used, but no .debug_line offset provided.\n"));
+		  error (_("DW_MACRO_start_file used, but no .debug_line offset provided.\n"));
 		else
 		  file_name
 		    = get_line_filename_and_dirname (line_offset, filenum,
 						     &dir_name);
 		if (file_name == NULL)
-		  printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d\n"),
+		  printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d\n"),
 			  lineno, filenum);
 		else
-		  printf (_(" DW_MACRO_GNU_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
+		  printf (_(" DW_MACRO_start_file - lineno: %d filenum: %d filename: %s%s%s\n"),
 			  lineno, filenum,
 			  dir_name != NULL ? (const char *) dir_name : "",
 			  dir_name != NULL ? "/" : "", file_name);
 	      }
 	      break;
 
-	    case DW_MACRO_GNU_end_file:
-	      printf (_(" DW_MACRO_GNU_end_file\n"));
+	    case DW_MACRO_end_file:
+	      printf (_(" DW_MACRO_end_file\n"));
 	      break;
 
-	    case DW_MACRO_GNU_define:
+	    case DW_MACRO_define:
 	      lineno = read_uleb128 (curr, &bytes_read, end);
 	      curr += bytes_read;
 	      string = curr;
 	      curr += strnlen ((char *) string, end - string) + 1;
-	      printf (_(" DW_MACRO_GNU_define - lineno : %d macro : %s\n"),
+	      printf (_(" DW_MACRO_define - lineno : %d macro : %s\n"),
 		      lineno, string);
 	      break;
 
-	    case DW_MACRO_GNU_undef:
+	    case DW_MACRO_undef:
 	      lineno = read_uleb128 (curr, &bytes_read, end);
 	      curr += bytes_read;
 	      string = curr;
 	      curr += strnlen ((char *) string, end - string) + 1;
-	      printf (_(" DW_MACRO_GNU_undef - lineno : %d macro : %s\n"),
+	      printf (_(" DW_MACRO_undef - lineno : %d macro : %s\n"),
 		      lineno, string);
 	      break;
 
-	    case DW_MACRO_GNU_define_indirect:
+	    case DW_MACRO_define_strp:
 	      lineno = read_uleb128 (curr, &bytes_read, end);
 	      curr += bytes_read;
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
 	      string = fetch_indirect_string (offset);
-	      printf (_(" DW_MACRO_GNU_define_indirect - lineno : %d macro : %s\n"),
+	      printf (_(" DW_MACRO_define_strp - lineno : %d macro : %s\n"),
 		      lineno, string);
 	      break;
 
-	    case DW_MACRO_GNU_undef_indirect:
+	    case DW_MACRO_undef_strp:
 	      lineno = read_uleb128 (curr, &bytes_read, end);
 	      curr += bytes_read;
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
 	      string = fetch_indirect_string (offset);
-	      printf (_(" DW_MACRO_GNU_undef_indirect - lineno : %d macro : %s\n"),
+	      printf (_(" DW_MACRO_undef_strp - lineno : %d macro : %s\n"),
 		      lineno, string);
 	      break;
 
-	    case DW_MACRO_GNU_transparent_include:
+	    case DW_MACRO_import:
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_GNU_transparent_include - offset : 0x%lx\n"),
+	      printf (_(" DW_MACRO_import - offset : 0x%lx\n"),
 		      (unsigned long) offset);
 	      break;
 
-	    case DW_MACRO_GNU_define_indirect_alt:
+	    case DW_MACRO_define_sup:
 	      lineno = read_uleb128 (curr, &bytes_read, end);
 	      curr += bytes_read;
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_GNU_define_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
+	      printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"),
 		      lineno, (unsigned long) offset);
 	      break;
 
-	    case DW_MACRO_GNU_undef_indirect_alt:
+	    case DW_MACRO_undef_sup:
 	      lineno = read_uleb128 (curr, &bytes_read, end);
 	      curr += bytes_read;
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_GNU_undef_indirect_alt - lineno : %d macro offset : 0x%lx\n"),
+	      printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"),
 		      lineno, (unsigned long) offset);
 	      break;
 
-	    case DW_MACRO_GNU_transparent_include_alt:
+	    case DW_MACRO_import_sup:
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_GNU_transparent_include_alt - offset : 0x%lx\n"),
+	      printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"),
 		      (unsigned long) offset);
 	      break;
 
@@ -4753,10 +4753,10 @@ display_debug_macro (struct dwarf_section *section,
 		  desc += bytes_read;
 		  if (nargs == 0)
 		    {
-		      printf (_(" DW_MACRO_GNU_%02x\n"), op);
+		      printf (_(" DW_MACRO_%02x\n"), op);
 		      break;
 		    }
-		  printf (_(" DW_MACRO_GNU_%02x -"), op);
+		  printf (_(" DW_MACRO_%02x -"), op);
 		  for (n = 0; n < nargs; n++)
 		    {
 		      int val;

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 6/6] DWARF-5: DW_FORM_data16
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
                   ` (2 preceding siblings ...)
  2017-02-15 22:58 ` [PATCH 2/6] Display user op byte Jan Kratochvil
@ 2017-02-15 22:58 ` Jan Kratochvil
  2017-02-22 11:51   ` Nick Clifton
  2017-02-15 22:58 ` [PATCH 5/6] DWARF-5: Macros Jan Kratochvil
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-15 22:58 UTC (permalink / raw)
  To: binutils; +Cc: Victor Leschuk

Hi,

DWARF-5 has new form DW_FORM_data16.

Jan


binutils/ChangeLog
2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.
---
 binutils/dwarf.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 94b366b..b29ed10 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1730,6 +1730,32 @@ read_and_display_attr_value (unsigned long attribute,
       data += 8;
       break;
 
+    case DW_FORM_data16:
+      if (!do_loc)
+	{
+	  dwarf_vma left_high_bits, left_low_bits;
+	  dwarf_vma right_high_bits, right_low_bits;
+
+	  SAFE_BYTE_GET64 (data, &left_high_bits, &left_low_bits, end);
+	  SAFE_BYTE_GET64 (data + 8, &right_high_bits, &right_low_bits, end);
+	  if (byte_get == byte_get_little_endian)
+	    {
+	      /* Swap them.  */
+	      left_high_bits ^= right_high_bits;
+	      right_high_bits ^= left_high_bits;
+	      left_high_bits ^= right_high_bits;
+	      left_low_bits ^= right_low_bits;
+	      right_low_bits ^= left_low_bits;
+	      left_low_bits ^= right_low_bits;
+	    }
+	  printf (" 0x%08" DWARF_VMA_FMT "x%08" DWARF_VMA_FMT "x"
+		  "%08" DWARF_VMA_FMT "x%08" DWARF_VMA_FMT "x",
+		  left_high_bits, left_low_bits, right_high_bits,
+		  right_low_bits);
+	}
+      data += 16;
+      break;
+
     case DW_FORM_string:
       if (!do_loc)
 	printf ("%c%.*s", delimiter, (int) (end - data), data);

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 3/6] DWARF-5 basic functionality
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
@ 2017-02-15 22:58 ` Jan Kratochvil
  2017-02-22 11:36   ` Nick Clifton
  2017-02-22 11:47   ` Nick Clifton
  2017-02-15 22:58 ` [PATCH 4/6] DWARF-5: call sites Jan Kratochvil
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-15 22:58 UTC (permalink / raw)
  To: binutils; +Cc: Victor Leschuk

Hi,

this is a kitchen-sink patch for everything that did not fit into its own
patch.

DWO is not yet implemented.

Jan


binutils/ChangeLog
2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (fetch_indirect_line_string): New function.
	(abbrev_attr): New field implicit_const.
	(add_abbrev_attr): New parameter implicit_const.
	(process_abbrev_section): Support DW_FORM_implicit_const.
	(decode_location_expression): Support DW_OP_entry_value.
	(read_and_display_attr_value): Add parameter implicit_const.  Support
	DW_FORM_line_strp and DW_FORM_implicit_const.
	(read_and_display_attr): Add parameter implicit_const.
	(process_debug_info): Support line_str and DWARF-5.
	(read_debug_line_header): Support DWARF-5.
	(display_formatted_table): New function.
	(display_debug_lines_raw): New parameter file.  Support DWARF-5.
	(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
	(display_debug_lines): Pass file parameter.
	(display_debug_macro): Update read_and_display_attr_value caller.
	(display_debug_abbrev): Support DW_FORM_implicit_const.
	(display_loclists_list): New function.
	(display_loc_list): Support .debug_loclists.
	(display_debug_ranges_list): New function from display_debug_ranges.
	(display_debug_rnglists_list): New function.
	(display_debug_ranges): Support .debug_rnglists.
	(debug_displays): Add .debug_line_str, .debug_loclists and
	.debug_rnglists.
	* dwarf.h: Include dwarf2.h
	(DWARF2_Internal_LineInfo): Add li_offset_size.
	(DWARF2_Internal_CompUnit): Add cu_unit_type.
	(enum dwarf_section_display_enum): Add line_str.
	* readelf.c (process_section_headers): Add rnglists and loclists.
---
 binutils/dwarf.c   | 1159 +++++++++++++++++++++++++++++++++++++++++++---------
 binutils/dwarf.h   |    5 
 binutils/readelf.c |    2 
 3 files changed, 964 insertions(+), 202 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 9d9a657..adb9c09 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -612,6 +612,24 @@ fetch_indirect_string (dwarf_vma offset)
   return (const unsigned char *) section->start + offset;
 }
 
+static const unsigned char *
+fetch_indirect_line_string (dwarf_vma offset)
+{
+  struct dwarf_section *section = &debug_displays [line_str].section;
+
+  if (section->start == NULL)
+    return (const unsigned char *) _("<no .debug_line_str section>");
+
+  if (offset > section->size)
+    {
+      warn (_("DW_FORM_line_strp offset too big: %s\n"),
+	    dwarf_vmatoa ("x", offset));
+      return (const unsigned char *) _("<offset is too big>");
+    }
+
+  return (const unsigned char *) section->start + offset;
+}
+
 static const char *
 fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set,
 		      dwarf_vma offset_size, int dwo)
@@ -678,6 +696,7 @@ typedef struct abbrev_attr
 {
   unsigned long attribute;
   unsigned long form;
+  bfd_signed_vma implicit_const;
   struct abbrev_attr *next;
 }
 abbrev_attr;
@@ -747,7 +766,8 @@ add_abbrev (unsigned long number, unsigned long tag, int children)
 }
 
 static void
-add_abbrev_attr (unsigned long attribute, unsigned long form)
+add_abbrev_attr (unsigned long attribute, unsigned long form,
+		 bfd_signed_vma implicit_const)
 {
   abbrev_attr *attr;
 
@@ -758,6 +778,7 @@ add_abbrev_attr (unsigned long attribute, unsigned long form)
 
   attr->attribute = attribute;
   attr->form      = form;
+  attr->implicit_const = implicit_const;
   attr->next      = NULL;
 
   if (last_abbrev->first_attr == NULL)
@@ -810,6 +831,8 @@ process_abbrev_section (unsigned char *start, unsigned char *end)
       do
 	{
 	  unsigned long form;
+	  /* Initialize it due to a false compiler warning.  */
+	  bfd_signed_vma implicit_const = -1;
 
 	  attribute = read_uleb128 (start, & bytes_read, end);
 	  start += bytes_read;
@@ -821,7 +844,15 @@ process_abbrev_section (unsigned char *start, unsigned char *end)
 	  if (start == end)
 	    break;
 
-	  add_abbrev_attr (attribute, form);
+	  if (form == DW_FORM_implicit_const)
+	    {
+	      implicit_const = read_sleb128 (start, & bytes_read, end);
+	      start += bytes_read;
+	      if (start == end)
+		break;
+	    }
+
+	  add_abbrev_attr (attribute, form, implicit_const);
 	}
       while (attribute != 0);
     }
@@ -1315,13 +1346,15 @@ decode_location_expression (unsigned char * data,
 						   &bytes_read, end)));
 	  data += bytes_read;
 	  break;
+	case DW_OP_entry_value:
 	case DW_OP_GNU_entry_value:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
 	  /* PR 17531: file: 0cc9cd00.  */
 	  if (uvalue > (dwarf_vma) (end - data))
 	    uvalue = end - data;
-	  printf ("DW_OP_GNU_entry_value: (");
+	  printf ("%s: (", (op == DW_OP_entry_value ? "DW_OP_entry_value"
+						    : "DW_OP_GNU_entry_value"));
 	  if (decode_location_expression (data, pointer_size, offset_size,
 					  dwarf_version, uvalue,
 					  cu_offset, section))
@@ -1499,6 +1532,7 @@ add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc)
 static unsigned char *
 read_and_display_attr_value (unsigned long attribute,
 			     unsigned long form,
+			     dwarf_signed_vma implicit_const,
 			     unsigned char * data,
 			     unsigned char * end,
 			     dwarf_vma cu_offset,
@@ -1541,6 +1575,7 @@ read_and_display_attr_value (unsigned long attribute,
       break;
 
     case DW_FORM_strp:
+    case DW_FORM_line_strp:
     case DW_FORM_sec_offset:
     case DW_FORM_GNU_ref_alt:
     case DW_FORM_GNU_strp_alt:
@@ -1588,8 +1623,13 @@ read_and_display_attr_value (unsigned long attribute,
       data += bytes_read;
       if (!do_loc)
 	printf ("%c%s", delimiter, get_FORM_name (form));
-      return read_and_display_attr_value (attribute, form, data, end,
-					  cu_offset, pointer_size,
+      if (form == DW_FORM_implicit_const)
+	{
+	  implicit_const = read_sleb128 (data, & bytes_read, end);
+	  data += bytes_read;
+	}
+      return read_and_display_attr_value (attribute, form, implicit_const, data,
+					  end, cu_offset, pointer_size,
 					  offset_size, dwarf_version,
 					  debug_info_p, do_loc,
 					  section, this_set, delimiter);
@@ -1636,6 +1676,11 @@ read_and_display_attr_value (unsigned long attribute,
 	printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue));
       break;
 
+    case DW_FORM_implicit_const:
+      if (!do_loc)
+	printf ("%c%s", delimiter, dwarf_vmatoa ("d", implicit_const));
+      break;
+
     case DW_FORM_ref8:
     case DW_FORM_data8:
       if (!do_loc)
@@ -1769,6 +1814,13 @@ read_and_display_attr_value (unsigned long attribute,
 		fetch_indirect_string (uvalue));
       break;
 
+    case DW_FORM_line_strp:
+      if (!do_loc)
+	printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter,
+		dwarf_vmatoa ("x", uvalue),
+		fetch_indirect_line_string (uvalue));
+      break;
+
     case DW_FORM_GNU_str_index:
       if (!do_loc)
 	{
@@ -2217,6 +2269,7 @@ get_AT_name (unsigned long attribute)
 static unsigned char *
 read_and_display_attr (unsigned long attribute,
 		       unsigned long form,
+		       dwarf_signed_vma implicit_const,
 		       unsigned char * data,
 		       unsigned char * end,
 		       dwarf_vma cu_offset,
@@ -2230,7 +2283,7 @@ read_and_display_attr (unsigned long attribute,
 {
   if (!do_loc)
     printf ("   %-18s:", get_AT_name (attribute));
-  data = read_and_display_attr_value (attribute, form, data, end,
+  data = read_and_display_attr_value (attribute, form, implicit_const, data, end,
 				      cu_offset, pointer_size, offset_size,
 				      dwarf_version, debug_info_p,
 				      do_loc, section, this_set, ' ');
@@ -2329,6 +2382,7 @@ process_debug_info (struct dwarf_section *section,
 	printf (_("Contents of the %s section:\n\n"), section->name);
 
       load_debug_section (str, file);
+      load_debug_section (line_str, file);
       load_debug_section (str_dwo, file);
       load_debug_section (str_index, file);
       load_debug_section (str_index_dwo, file);
@@ -2381,6 +2435,21 @@ process_debug_info (struct dwarf_section *section,
 
       this_set = find_cu_tu_set_v2 (cu_offset, do_types);
 
+      if (compunit.cu_version < 5)
+	{
+	  compunit.cu_unit_type = DW_UT_compile;
+	  /* Initialize it due to a false compiler warning.  */
+	  compunit.cu_pointer_size = -1;
+	}
+      else
+	{
+	  SAFE_BYTE_GET_AND_INC (compunit.cu_unit_type, hdrptr, 1, end);
+	  if (compunit.cu_unit_type == DW_UT_type)
+	    do_types = 1;
+
+	  SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
+	}
+
       SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end);
 
       if (this_set == NULL)
@@ -2394,7 +2463,9 @@ process_debug_info (struct dwarf_section *section,
 	  abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
 	}
 
-      SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
+      if (compunit.cu_version < 5)
+	SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
+
       /* PR 17512: file: 001-108546-0.001:0.1.  */
       if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8)
 	{
@@ -2495,7 +2566,8 @@ process_debug_info (struct dwarf_section *section,
 
       if (compunit.cu_version != 2
 	  && compunit.cu_version != 3
-	  && compunit.cu_version != 4)
+	  && compunit.cu_version != 4
+	  && compunit.cu_version != 5)
 	{
 	  warn (_("CU at offset %s contains corrupt or "
 		  "unsupported version number: %d.\n"),
@@ -2503,6 +2575,15 @@ process_debug_info (struct dwarf_section *section,
 	  continue;
 	}
 
+      if (compunit.cu_unit_type != DW_UT_compile
+	  && compunit.cu_unit_type != DW_UT_type)
+	{
+	  warn (_("CU at offset %s contains corrupt or "
+		  "unsupported unit type: %d.\n"),
+		dwarf_vmatoa ("x", cu_offset), compunit.cu_unit_type);
+	  continue;
+	}
+
       free_abbrevs ();
 
       /* Process the abbrevs used by this compilation unit.  */
@@ -2656,6 +2737,7 @@ process_debug_info (struct dwarf_section *section,
 
 	      tags = read_and_display_attr (attr->attribute,
 					    attr->form,
+					    attr->implicit_const,
 					    tags,
 					    end,
 					    cu_offset,
@@ -2743,8 +2825,8 @@ read_debug_line_header (struct dwarf_section * section,
 			unsigned char ** end_of_sequence)
 {
   unsigned char *hdrptr;
-  unsigned int offset_size;
   unsigned int initial_length_size;
+  unsigned char address_size, segment_selector_size;
 
   /* Extract information from the Line Number Program Header.
      (section 6.2.4 in the Dwarf3 doc).  */
@@ -2757,12 +2839,12 @@ read_debug_line_header (struct dwarf_section * section,
     {
       /* This section is 64-bit DWARF 3.  */
       SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 8, end);
-      offset_size = 8;
+      linfo->li_offset_size = 8;
       initial_length_size = 12;
     }
   else
     {
-      offset_size = 4;
+      linfo->li_offset_size = 4;
       initial_length_size = 4;
     }
 
@@ -2774,7 +2856,7 @@ read_debug_line_header (struct dwarf_section * section,
 	 comprised of several different .debug_line.* sections, (some of
 	 which may be removed by linker garbage collection), and a relocation
 	 is used to compute the correct length once that is done.  */
-      if (reloc_at (section, (hdrptr - section->start) - offset_size))
+      if (reloc_at (section, (hdrptr - section->start) - linfo->li_offset_size))
 	{
 	  linfo->li_length = (end - data) - initial_length_size;
 	}
@@ -2791,13 +2873,30 @@ read_debug_line_header (struct dwarf_section * section,
 
   if (linfo->li_version != 2
       && linfo->li_version != 3
-      && linfo->li_version != 4)
+      && linfo->li_version != 4
+      && linfo->li_version != 5)
     {
-      warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
+      warn (_("Only DWARF version 2, 3, 4 and 5 line info "
+	      "is currently supported.\n"));
       return NULL;
     }
 
-  SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, offset_size, end);
+  if (linfo->li_version >= 5)
+    {
+      SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end);
+
+      SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end);
+      if (segment_selector_size != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported segment selector size: %d.\n"),
+		section->name, segment_selector_size);
+	  return 0;
+	}
+    }
+
+  SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr,
+			 linfo->li_offset_size, end);
   SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end);
 
   if (linfo->li_version >= 4)
@@ -2831,10 +2930,126 @@ read_debug_line_header (struct dwarf_section * section,
   return hdrptr;
 }
 
+static unsigned char *
+display_formatted_table (unsigned char *data,
+			 unsigned char *start, unsigned char *end,
+			 const DWARF2_Internal_LineInfo *linfo,
+			 struct dwarf_section *section, const char *what)
+{
+  unsigned char *format_start, format_count, *format, formati;
+  dwarf_vma data_count, datai;
+  unsigned int bytes_read, namepass, last_entry = 0;
+
+  SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
+  format_start = data;
+  for (formati = 0; formati < format_count; formati++)
+    {
+      read_uleb128 (data, & bytes_read, end);
+      data += bytes_read;
+      read_uleb128 (data, & bytes_read, end);
+      data += bytes_read;
+      if (data == end)
+	{
+	  warn (_("Corrupt %s entry format table entry\n"), what);
+	  return data;
+	}
+    }
+
+  data_count = read_uleb128 (data, & bytes_read, end);
+  data += bytes_read;
+  if (data == end)
+    {
+      warn (_("Corrupt %s list\n"), what);
+      return data;
+    }
+
+  if (data_count == 0)
+    {
+      printf (_("\n The %s Table is empty.\n"), what);
+      return data;
+    }
+
+  printf (_("\n The %s Table (offset 0x%lx):\n"), what,
+	  (long)(data - start));
+
+  printf (_("  Entry"));
+  /* Delay displaying name as the last entry for better screen layout.  */ 
+  for (namepass = 0; namepass < 2; namepass++)
+    {
+      format = format_start;
+      for (formati = 0; formati < format_count; formati++)
+	{
+	  dwarf_vma content_type;
+
+	  content_type = read_uleb128 (format, & bytes_read, end);
+	  format += bytes_read;
+	  if ((content_type == DW_LNCT_path) == (namepass == 1))
+	    switch (content_type)
+	      {
+	      case DW_LNCT_path:
+		printf (_("\tName"));
+		break;
+	      case DW_LNCT_directory_index:
+		printf (_("\tDir"));
+		break;
+	      case DW_LNCT_timestamp:
+		printf (_("\tTime"));
+		break;
+	      case DW_LNCT_size:
+		printf (_("\tSize"));
+		break;
+	      case DW_LNCT_MD5:
+		printf (_("\tMD5"));
+		break;
+	      default:
+		printf (_("\t(Unknown format content type %s)"),
+			dwarf_vmatoa ("u", content_type));
+	      }
+	  read_uleb128 (format, & bytes_read, end);
+	  format += bytes_read;
+	}
+    }
+  putchar ('\n');
+
+  for (datai = 0; datai < data_count; datai++)
+    {
+      unsigned char *datapass = data;
+
+      printf ("  %d", last_entry++);
+      /* Delay displaying name as the last entry for better screen layout.  */ 
+      for (namepass = 0; namepass < 2; namepass++)
+	{
+	  format = format_start;
+	  data = datapass;
+	  for (formati = 0; formati < format_count; formati++)
+	    {
+	      dwarf_vma content_type, form;
+
+	      content_type = read_uleb128 (format, & bytes_read, end);
+	      format += bytes_read;
+	      form = read_uleb128 (format, & bytes_read, end);
+	      format += bytes_read;
+	      data = read_and_display_attr_value (0, form, 0, data, end, 0, 0,
+						  linfo->li_offset_size,
+						  linfo->li_version, NULL,
+			    ((content_type == DW_LNCT_path) != (namepass == 1)),
+						  section, NULL, '\t');
+	    }
+	}
+      if (data == end)
+	{
+	  warn (_("Corrupt %s entries list\n"), what);
+	  return data;
+	}
+      putchar ('\n');
+    }
+  return data;
+}
+
 static int
 display_debug_lines_raw (struct dwarf_section *section,
 			 unsigned char *data,
-			 unsigned char *end)
+			 unsigned char *end, void *file)
 {
   unsigned char *start = section->start;
 
@@ -2847,7 +3062,6 @@ display_debug_lines_raw (struct dwarf_section *section,
       DWARF2_Internal_LineInfo linfo;
       unsigned char *standard_opcodes;
       unsigned char *end_of_sequence;
-      unsigned int last_dir_entry = 0;
       int i;
 
       if (const_strneq (section->name, ".debug_line.")
@@ -2923,67 +3137,82 @@ display_debug_lines_raw (struct dwarf_section *section,
 	  /* Display the contents of the Directory table.  */
 	  data = standard_opcodes + linfo.li_opcode_base - 1;
 
-	  if (*data == 0)
-	    printf (_("\n The Directory Table is empty.\n"));
-	  else
+	  if (linfo.li_version >= 5)
 	    {
-	      printf (_("\n The Directory Table (offset 0x%lx):\n"),
-		      (long)(data - start));
+	      load_debug_section (line_str, file);
 
-	      while (data < end && *data != 0)
+	      data = display_formatted_table (data, start, end, &linfo, section,
+					      _("Directory"));
+	      data = display_formatted_table (data, start, end, &linfo, section,
+					      _("File name"));
+	    }
+	  else
+	    {
+	      if (*data == 0)
+		printf (_("\n The Directory Table is empty.\n"));
+	      else
 		{
-		  printf ("  %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data);
-
-		  data += strnlen ((char *) data, end - data) + 1;
-		}
+		  unsigned int last_dir_entry = 0;
 
-	      /* PR 17512: file: 002-132094-0.004.  */
-	      if (data >= end - 1)
-		break;
-	    }
+		  printf (_("\n The Directory Table (offset 0x%lx):\n"),
+			  (long)(data - start));
 
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
+		  while (data < end && *data != 0)
+		    {
+		      printf ("  %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data);
 
-	  /* Display the contents of the File Name table.  */
-	  if (*data == 0)
-	    printf (_("\n The File Name Table is empty.\n"));
-	  else
-	    {
-	      printf (_("\n The File Name Table (offset 0x%lx):\n"),
-		      (long)(data - start));
-	      printf (_("  Entry\tDir\tTime\tSize\tName\n"));
+		      data += strnlen ((char *) data, end - data) + 1;
+		    }
 
-	      while (data < end && *data != 0)
-		{
-		  unsigned char *name;
-		  unsigned int bytes_read;
+		  /* PR 17512: file: 002-132094-0.004.  */
+		  if (data >= end - 1)
+		    break;
+		}
 
-		  printf ("  %d\t", ++state_machine_regs.last_file_entry);
-		  name = data;
-		  data += strnlen ((char *) data, end - data) + 1;
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
 
-		  printf ("%s\t",
-			  dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
-		  data += bytes_read;
-		  printf ("%s\t",
-			  dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
-		  data += bytes_read;
-		  printf ("%s\t",
-			  dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
-		  data += bytes_read;
-		  printf ("%.*s\n", (int)(end - name), name);
+	      /* Display the contents of the File Name table.  */
+	      if (*data == 0)
+		printf (_("\n The File Name Table is empty.\n"));
+	      else
+		{
+		  printf (_("\n The File Name Table (offset 0x%lx):\n"),
+			  (long)(data - start));
+		  printf (_("  Entry\tDir\tTime\tSize\tName\n"));
 
-		  if (data == end)
+		  while (data < end && *data != 0)
 		    {
-		      warn (_("Corrupt file name table entry\n"));
-		      break;
+		      unsigned char *name;
+		      unsigned int bytes_read;
+
+		      printf ("  %d\t", ++state_machine_regs.last_file_entry);
+		      name = data;
+		      data += strnlen ((char *) data, end - data) + 1;
+
+		      printf ("%s\t",
+			      dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
+		      data += bytes_read;
+		      printf ("%s\t",
+			      dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
+		      data += bytes_read;
+		      printf ("%s\t",
+			      dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
+		      data += bytes_read;
+		      printf ("%.*s\n", (int)(end - name), name);
+
+		      if (data == end)
+			{
+			  warn (_("Corrupt file name table entry\n"));
+			  break;
+			}
 		    }
 		}
+
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
 	    }
 
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
 	  putchar ('\n');
 	  saved_linfo = linfo;
 	}
@@ -3197,7 +3426,7 @@ typedef struct
 static int
 display_debug_lines_decoded (struct dwarf_section *section,
 			     unsigned char *data,
-			     unsigned char *end)
+			     unsigned char *end, void *fileptr)
 {
   static DWARF2_Internal_LineInfo saved_linfo;
 
@@ -3214,7 +3443,7 @@ display_debug_lines_decoded (struct dwarf_section *section,
       File_Entry *file_table = NULL;
       unsigned int n_files = 0;
       unsigned char **directory_table = NULL;
-      unsigned int n_directories = 0;
+      dwarf_vma n_directories = 0;
 
       if (const_strneq (section->name, ".debug_line.")
 	  /* Note: the following does not apply to .debug_line.dwo sections.
@@ -3262,129 +3491,304 @@ display_debug_lines_decoded (struct dwarf_section *section,
 	      return 0;
 	    }
 
-	  if (*data != 0)
+	  if (linfo.li_version >= 5)
 	    {
-	      unsigned char *ptr_directory_table = data;
+	      unsigned char *format_start, format_count, *format;
+	      dwarf_vma formati, entryi;
+	      unsigned int bytes_read;
 
-	      while (data < end && *data != 0)
+	      load_debug_section (line_str, fileptr);
+
+	      /* Skip directories format.  */
+	      SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
+	      format_start = data;
+	      for (formati = 0; formati < format_count; formati++)
 		{
-		  data += strnlen ((char *) data, end - data) + 1;
-		  n_directories++;
+		  read_uleb128 (data, & bytes_read, end);
+		  data += bytes_read;
+		  read_uleb128 (data, & bytes_read, end);
+		  data += bytes_read;
 		}
 
-	      /* PR 20440 */
-	      if (data >= end)
+	      n_directories = read_uleb128 (data, & bytes_read, end);
+	      data += bytes_read;
+	      if (data == end)
 		{
-		  warn (_("directory table ends unexpectedly\n"));
-		  n_directories = 0;
+		  warn (_("Corrupt directories list\n"));
 		  break;
 		}
 
-	      /* Go through the directory table again to save the directories.  */
 	      directory_table = (unsigned char **)
 		xmalloc (n_directories * sizeof (unsigned char *));
 
-	      i = 0;
-	      while (*ptr_directory_table != 0)
+	      for (entryi = 0; entryi < n_directories; entryi++)
 		{
-		  directory_table[i] = ptr_directory_table;
-		  ptr_directory_table += strnlen ((char *) ptr_directory_table,
-						  ptr_directory_table - end) + 1;
-		  i++;
-		}
-	    }
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
+		  unsigned char **pathp = &directory_table[entryi];
 
-	  /* Traverse the File Name table just to count the entries.  */
-	  if (data < end && *data != 0)
-	    {
-	      unsigned char *ptr_file_name_table = data;
+		  format = format_start;
+		  for (formati = 0; formati < format_count; formati++)
+		    {
+		      dwarf_vma content_type, form;
+		      dwarf_vma uvalue;
+
+		      content_type = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      form = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      if (data == end)
+			{
+			  warn (_("Corrupt directories list\n"));
+			  break;
+			}
+		      switch (content_type)
+			{
+			case DW_LNCT_path:
+			  switch (form)
+			    {
+			    case DW_FORM_string:
+			      *pathp = data;
+			      break;
+			    case DW_FORM_line_strp:
+			      SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size,
+					     end);
+			      /* Remove const by the cast.  */
+			      *pathp = (unsigned char *)
+				       fetch_indirect_line_string (uvalue);
+			      break;
+			    }
+			  break;
+			}
+		      data = read_and_display_attr_value (0, form, 0, data, end,
+		                                          0, 0,
+							  linfo.li_offset_size,
+							  linfo.li_version,
+							  NULL, 1, section,
+							  NULL, '\t');
+		    }
+		  if (data == end)
+		    {
+		      warn (_("Corrupt directories list\n"));
+		      break;
+		    }
+		}
 
-	      while (data < end && *data != 0)
+	      /* Skip files format.  */
+	      SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
+	      format_start = data;
+	      for (formati = 0; formati < format_count; formati++)
 		{
-		  unsigned int bytes_read;
-
-		  /* Skip Name, directory index, last modification time and length
-		     of file.  */
-		  data += strnlen ((char *) data, end - data) + 1;
-		  read_uleb128 (data, & bytes_read, end);
-		  data += bytes_read;
 		  read_uleb128 (data, & bytes_read, end);
 		  data += bytes_read;
 		  read_uleb128 (data, & bytes_read, end);
 		  data += bytes_read;
-
-		  n_files++;
 		}
 
-	      if (data >= end)
+	      n_files = read_uleb128 (data, & bytes_read, end);
+	      data += bytes_read;
+	      if (data == end)
 		{
-		  warn (_("file table ends unexpectedly\n"));
-		  n_files = 0;
+		  warn (_("Corrupt file name list\n"));
 		  break;
 		}
 
-	      /* Go through the file table again to save the strings.  */
-	      file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry));
+	      file_table = (File_Entry *) xcalloc (1, n_files
+						      * sizeof (File_Entry));
 
-	      i = 0;
-	      while (*ptr_file_name_table != 0)
+	      for (entryi = 0; entryi < n_files; entryi++)
 		{
-		  unsigned int bytes_read;
-
-		  file_table[i].name = ptr_file_name_table;
-		  ptr_file_name_table += strnlen ((char *) ptr_file_name_table,
-						  end - ptr_file_name_table) + 1;
-
-		  /* We are not interested in directory, time or size.  */
-		  file_table[i].directory_index = read_uleb128 (ptr_file_name_table,
-								& bytes_read, end);
-		  ptr_file_name_table += bytes_read;
-		  file_table[i].modification_date = read_uleb128 (ptr_file_name_table,
-								  & bytes_read, end);
-		  ptr_file_name_table += bytes_read;
-		  file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end);
-		  ptr_file_name_table += bytes_read;
-		  i++;
-		}
-	      i = 0;
+		  File_Entry *file = &file_table[entryi];
 
-	      /* Print the Compilation Unit's name and a header.  */
-	      if (directory_table == NULL)
+		  format = format_start;
+		  for (formati = 0; formati < format_count; formati++)
+		    {
+		      dwarf_vma content_type, form;
+		      dwarf_vma uvalue;
+
+		      content_type = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      form = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      if (data == end)
+			{
+			  warn (_("Corrupt file name list\n"));
+			  break;
+			}
+		      switch (content_type)
+			{
+			case DW_LNCT_path:
+			  switch (form)
+			    {
+			    case DW_FORM_string:
+			      file->name = data;
+			      break;
+			    case DW_FORM_line_strp:
+			      SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size,
+					     end);
+			      /* Remove const by the cast.  */
+			      file->name = (unsigned char *)
+					   fetch_indirect_line_string (uvalue);
+			      break;
+			    }
+			  break;
+			case DW_LNCT_directory_index:
+			  switch (form)
+			    {
+			    case DW_FORM_data1:
+			      SAFE_BYTE_GET (file->directory_index, data, 1,
+					     end);
+			      break;
+			    case DW_FORM_data2:
+			      SAFE_BYTE_GET (file->directory_index, data, 2,
+					     end);
+			      break;
+			    case DW_FORM_udata:
+			      file->directory_index = read_uleb128 (data, NULL,
+								    end);
+			      break;
+			    }
+			  break;
+			}
+		      data = read_and_display_attr_value (0, form, 0, data, end,
+							  0, 0,
+							  linfo.li_offset_size,
+							  linfo.li_version,
+							  NULL, 1, section,
+							  NULL, '\t');
+		    }
+		  if (data == end)
+		    {
+		      warn (_("Corrupt file name list\n"));
+		      break;
+		    }
+		}
+	    }
+	  else
+	    {
+	      if (*data != 0)
 		{
-		  printf (_("CU: %s:\n"), file_table[0].name);
-		  printf (_("File name                            Line number    Starting address\n"));
+		  unsigned char *ptr_directory_table = data;
+
+		  while (data < end && *data != 0)
+		    {
+		      data += strnlen ((char *) data, end - data) + 1;
+		      n_directories++;
+		    }
+
+		  /* PR 20440 */
+		  if (data >= end)
+		    {
+		      warn (_("directory table ends unexpectedly\n"));
+		      n_directories = 0;
+		      break;
+		    }
+
+		  /* Go through the directory table again to save the directories.  */
+		  directory_table = (unsigned char **)
+		    xmalloc (n_directories * sizeof (unsigned char *));
+
+		  i = 0;
+		  while (*ptr_directory_table != 0)
+		    {
+		      directory_table[i] = ptr_directory_table;
+		      ptr_directory_table += strnlen ((char *) ptr_directory_table,
+						      ptr_directory_table - end) + 1;
+		      i++;
+		    }
 		}
-	      else
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
+
+	      /* Traverse the File Name table just to count the entries.  */
+	      if (data < end && *data != 0)
 		{
-		  unsigned int ix = file_table[0].directory_index;
-		  const char *directory;
-
-		  if (ix == 0)
-		    directory = ".";
-		  /* PR 20439 */
-		  else if (n_directories == 0)
-		    directory = _("<unknown>");
-		  else if (ix > n_directories)
+		  unsigned char *ptr_file_name_table = data;
+
+		  while (data < end && *data != 0)
 		    {
-		      warn (_("directory index %u > number of directories %u\n"), ix, n_directories);
-		      directory = _("<corrupt>");
+		      unsigned int bytes_read;
+
+		      /* Skip Name, directory index, last modification time and length
+			 of file.  */
+		      data += strnlen ((char *) data, end - data) + 1;
+		      read_uleb128 (data, & bytes_read, end);
+		      data += bytes_read;
+		      read_uleb128 (data, & bytes_read, end);
+		      data += bytes_read;
+		      read_uleb128 (data, & bytes_read, end);
+		      data += bytes_read;
+
+		      n_files++;
 		    }
-		  else
-		    directory = (char *) directory_table[ix - 1];
 
-		  if (do_wide || strlen (directory) < 76)
-		    printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
-		  else
-		    printf ("%s:\n", file_table[0].name);
+		  if (data >= end)
+		    {
+		      warn (_("file table ends unexpectedly\n"));
+		      n_files = 0;
+		      break;
+		    }
+
+		  /* Go through the file table again to save the strings.  */
+		  file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry));
 
-		  printf (_("File name                            Line number    Starting address\n"));
+		  i = 0;
+		  while (*ptr_file_name_table != 0)
+		    {
+		      unsigned int bytes_read;
+
+		      file_table[i].name = ptr_file_name_table;
+		      ptr_file_name_table += strnlen ((char *) ptr_file_name_table,
+						      end - ptr_file_name_table) + 1;
+
+		      /* We are not interested in directory, time or size.  */
+		      file_table[i].directory_index = read_uleb128 (ptr_file_name_table,
+								    & bytes_read, end);
+		      ptr_file_name_table += bytes_read;
+		      file_table[i].modification_date = read_uleb128 (ptr_file_name_table,
+								      & bytes_read, end);
+		      ptr_file_name_table += bytes_read;
+		      file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end);
+		      ptr_file_name_table += bytes_read;
+		      i++;
+		    }
+		  i = 0;
 		}
+
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
 	    }
 
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
+	  /* Print the Compilation Unit's name and a header.  */
+	  if (directory_table == NULL)
+	    {
+	      printf (_("CU: %s:\n"), file_table[0].name);
+	      printf (_("File name                            Line number    Starting address\n"));
+	    }
+	  else
+	    {
+	      unsigned int ix = file_table[0].directory_index;
+	      const char *directory;
+
+	      if (ix == 0)
+		directory = ".";
+	      /* PR 20439 */
+	      else if (n_directories == 0)
+		directory = _("<unknown>");
+	      else if (ix > n_directories)
+		{
+		  warn (_("directory index %u > number of directories %s\n"),
+			ix, dwarf_vmatoa ("u", n_directories));
+		  directory = _("<corrupt>");
+		}
+	      else
+		directory = (char *) directory_table[ix - 1];
+
+	      if (do_wide || strlen (directory) < 76)
+		printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
+	      else
+		printf ("%s:\n", file_table[0].name);
+
+	      printf (_("File name                            Line number    Starting address\n"));
+	    }
 
 	  saved_linfo = linfo;
 	}
@@ -3551,7 +3955,8 @@ display_debug_lines_decoded (struct dwarf_section *section,
 		     /* PR 20439 */
 		     else if (dir > n_directories)
 		       {
-			 warn (_("directory index %u > number of directories %u\n"), dir, n_directories);
+			 warn (_("directory index %u > number of directories %s\n"),
+			       dir, dwarf_vmatoa ("u", n_directories));
 			 printf (_("\n <over large directory table entry %u>\n"), dir);
 		       }
 		     else
@@ -3723,7 +4128,7 @@ display_debug_lines_decoded (struct dwarf_section *section,
 }
 
 static int
-display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
+display_debug_lines (struct dwarf_section *section, void *file)
 {
   unsigned char *data = section->start;
   unsigned char *end = data + section->size;
@@ -3734,10 +4139,10 @@ display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
     do_debug_lines |= FLAG_DEBUG_LINES_RAW;
 
   if (do_debug_lines & FLAG_DEBUG_LINES_RAW)
-    retValRaw = display_debug_lines_raw (section, data, end);
+    retValRaw = display_debug_lines_raw (section, data, end, file);
 
   if (do_debug_lines & FLAG_DEBUG_LINES_DECODED)
-    retValDecoded = display_debug_lines_decoded (section, data, end);
+    retValDecoded = display_debug_lines_decoded (section, data, end, file);
 
   if (!retValRaw || !retValDecoded)
     return 0;
@@ -4327,9 +4732,10 @@ display_debug_macro (struct dwarf_section *section,
 		    {
 		      int val;
 
+		      /* DW_FORM_implicit_const is not expected here.  */
 		      SAFE_BYTE_GET_AND_INC (val, desc, 1, end);
 		      curr
-			= read_and_display_attr_value (0, val,
+			= read_and_display_attr_value (0, val, 0,
 						       curr, end, 0, 0, offset_size,
 						       version, NULL, 0, NULL,
 						       NULL, ' ');
@@ -4382,9 +4788,14 @@ display_debug_abbrev (struct dwarf_section *section,
 		  entry->children ? _("has children") : _("no children"));
 
 	  for (attr = entry->first_attr; attr; attr = attr->next)
-	    printf ("    %-18s %s\n",
-		    get_AT_name (attr->attribute),
-		    get_FORM_name (attr->form));
+	    {
+	      printf ("    %-18s %s",
+		      get_AT_name (attr->attribute),
+		      get_FORM_name (attr->form));
+	      if (attr->form == DW_FORM_implicit_const)
+		printf (": %" BFD_VMA_FMT "d", attr->implicit_const);
+	      putchar ('\n');
+	    }
 	}
     }
   while (start);
@@ -4532,6 +4943,129 @@ display_loc_list (struct dwarf_section *section,
   *start_ptr = start;
 }
 
+/* Display a location list from a normal (ie, non-dwo) .debug_loclists section.  */
+
+static void
+display_loclists_list (struct dwarf_section *section,
+		       unsigned char **start_ptr,
+		       unsigned int debug_info_entry,
+		       unsigned long offset,
+		       unsigned long base_address,
+		       int has_frame_base)
+{
+  unsigned char *start = *start_ptr;
+  unsigned char *section_end = section->start + section->size;
+  unsigned long cu_offset;
+  unsigned int pointer_size;
+  unsigned int offset_size;
+  int dwarf_version;
+  unsigned int bytes_read;
+
+  dwarf_vma begin;
+  dwarf_vma end;
+  dwarf_vma length;
+  int need_frame_base;
+
+  if (debug_info_entry >= num_debug_info_entries)
+    {
+      warn (_("No debug information available for "
+	      "loclists lists of entry: %u\n"),
+	    debug_info_entry);
+      return;
+    }
+
+  cu_offset = debug_information [debug_info_entry].cu_offset;
+  pointer_size = debug_information [debug_info_entry].pointer_size;
+  offset_size = debug_information [debug_info_entry].offset_size;
+  dwarf_version = debug_information [debug_info_entry].dwarf_version;
+
+  if (pointer_size < 2 || pointer_size > 8)
+    {
+      warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
+	    pointer_size, debug_info_entry);
+      return;
+    }
+
+  while (1)
+    {
+      unsigned long off = offset + (start - *start_ptr);
+      enum dwarf_location_list_entry_type llet;
+
+      if (start + 1 > section_end)
+	{
+	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
+		offset);
+	  break;
+	}
+
+      printf ("    %8.8lx ", off);
+
+      SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end);
+
+      switch (llet)
+	{
+	case DW_LLE_end_of_list:
+	  printf (_("<End of list>\n"));
+	  break;
+	case DW_LLE_offset_pair:
+	  begin = read_uleb128 (start, &bytes_read, section_end);
+	  start += bytes_read;
+	  end = read_uleb128 (start, &bytes_read, section_end);
+	  start += bytes_read;
+	  break;
+	case DW_LLE_base_address:
+	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size,
+				 section_end);
+	  print_dwarf_vma (base_address, pointer_size);
+	  printf (_("(base address)\n"));
+	  break;
+	default:
+	  error (_("Invalid location list entry type %d\n"), llet);
+	  return;
+	}
+      if (llet == DW_LLE_end_of_list)
+	break;
+      if (llet != DW_LLE_offset_pair)
+	continue;
+
+      if (start + 2 > section_end)
+	{
+	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
+		offset);
+	  break;
+	}
+
+      length = read_uleb128 (start, &bytes_read, section_end);
+      start += bytes_read;
+
+      print_dwarf_vma (begin + base_address, pointer_size);
+      print_dwarf_vma (end + base_address, pointer_size);
+
+      putchar ('(');
+      need_frame_base = decode_location_expression (start,
+						    pointer_size,
+						    offset_size,
+						    dwarf_version,
+						    length,
+						    cu_offset, section);
+      putchar (')');
+
+      if (need_frame_base && !has_frame_base)
+	printf (_(" [without DW_AT_frame_base]"));
+
+      if (begin == end)
+	fputs (_(" (start == end)"), stdout);
+      else if (begin > end)
+	fputs (_(" (start > end)"), stdout);
+
+      putchar ('\n');
+
+      start += length;
+    }
+
+  *start_ptr = start;
+}
+
 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
    right-adjusted in a field of length LEN, and followed by a space.  */
 
@@ -4702,6 +5236,8 @@ display_debug_loc (struct dwarf_section *section, void *file)
   unsigned int *array = NULL;
   const char *suffix = strrchr (section->name, '.');
   int is_dwo = 0;
+  int is_loclists = strstr (section->name, "debug_loclists") != NULL;
+  dwarf_vma expected_start = 0;
 
   if (suffix && strcmp (suffix, ".dwo") == 0)
     is_dwo = 1;
@@ -4714,6 +5250,51 @@ display_debug_loc (struct dwarf_section *section, void *file)
       return 0;
     }
 
+  if (is_loclists)
+    {
+      unsigned char *hdrptr = section_begin;
+      dwarf_vma ll_length;
+      unsigned short ll_version;
+      unsigned char *end = section_begin + section->size;
+      unsigned char address_size, segment_selector_size;
+      uint32_t offset_entry_count;
+
+      SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 4, end);
+      if (ll_length == 0xffffffff)
+	SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 8, end);
+
+      SAFE_BYTE_GET_AND_INC (ll_version, hdrptr, 2, end);
+      if (ll_version != 5)
+	{
+	  warn (_("The %s section contains corrupt or "
+		  "unsupported version number: %d.\n"),
+		section->name, ll_version);
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end);
+
+      SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end);
+      if (segment_selector_size != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported segment selector size: %d.\n"),
+		section->name, segment_selector_size);
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (offset_entry_count, hdrptr, 4, end);
+      if (offset_entry_count != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported offset entry count: %d.\n"),
+		section->name, offset_entry_count);
+	  return 0;
+	}
+
+      expected_start = hdrptr - section_begin;
+    }
+
   if (load_debug_info (file) == 0)
     {
       warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
@@ -4763,7 +5344,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
     error (_("No location lists in .debug_info section!\n"));
 
   if (debug_information [first].num_loc_offsets > 0
-      && debug_information [first].loc_offsets [0] != 0)
+      && debug_information [first].loc_offsets [0] != expected_start)
     warn (_("Location lists in %s section start at 0x%s\n"),
 	  section->name,
 	  dwarf_vmatoa ("x", debug_information [first].loc_offsets [0]));
@@ -4827,11 +5408,23 @@ display_debug_loc (struct dwarf_section *section, void *file)
 	      continue;
 	    }
 
-	  if (is_dwo)
-	    display_loc_list_dwo (section, &start, i, offset, has_frame_base);
+	  if (!is_loclists)
+	    {
+	      if (is_dwo)
+		display_loc_list_dwo (section, &start, i, offset,
+				      has_frame_base);
+	      else
+		display_loc_list (section, &start, i, offset, base_address,
+				  has_frame_base);
+	    }
 	  else
-	    display_loc_list (section, &start, i, offset, base_address,
-			      has_frame_base);
+	    {
+	      if (is_dwo)
+		warn (_("DWO is not yet supported.\n"));
+	      else
+		display_loclists_list (section, &start, i, offset, base_address,
+				       has_frame_base);
+	    }
 	}
     }
 
@@ -5173,6 +5766,125 @@ range_entry_compar (const void *ap, const void *bp)
   return (a > b) - (b > a);
 }
 
+static void
+display_debug_ranges_list (unsigned char *start, unsigned char *finish,
+			   unsigned int pointer_size, unsigned long offset,
+			   unsigned long base_address)
+{
+  while (start < finish)
+    {
+      dwarf_vma begin;
+      dwarf_vma end;
+
+      SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
+      if (start >= finish)
+	break;
+      SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
+
+      printf ("    %8.8lx ", offset);
+
+      if (begin == 0 && end == 0)
+	{
+	  printf (_("<End of list>\n"));
+	  break;
+	}
+
+      /* Check base address specifiers.  */
+      if (is_max_address (begin, pointer_size)
+	  && !is_max_address (end, pointer_size))
+	{
+	  base_address = end;
+	  print_dwarf_vma (begin, pointer_size);
+	  print_dwarf_vma (end, pointer_size);
+	  printf ("(base address)\n");
+	  continue;
+	}
+
+      print_dwarf_vma (begin + base_address, pointer_size);
+      print_dwarf_vma (end + base_address, pointer_size);
+
+      if (begin == end)
+	fputs (_("(start == end)"), stdout);
+      else if (begin > end)
+	fputs (_("(start > end)"), stdout);
+
+      putchar ('\n');
+    }
+}
+
+static void
+display_debug_rnglists_list (unsigned char *start, unsigned char *finish,
+			     unsigned int pointer_size, unsigned long offset,
+			     unsigned long base_address)
+{
+  unsigned char *next = start;
+
+  while (1)
+    {
+      unsigned long off = offset + (start - next);
+      enum dwarf_range_list_entry rlet;
+      dwarf_vma begin, length, end;
+      unsigned int bytes_read;
+
+      if (start + 1 > finish)
+	{
+	  warn (_("Range list starting at offset 0x%lx is not terminated.\n"),
+		offset);
+	  break;
+	}
+
+      printf ("    %8.8lx ", off);
+
+      SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish);
+
+      switch (rlet)
+	{
+	case DW_RLE_end_of_list:
+	  printf (_("<End of list>\n"));
+	  break;
+	case DW_RLE_base_address:
+	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish);
+	  print_dwarf_vma (base_address, pointer_size);
+	  printf (_("(base address)\n"));
+	  break;
+	case DW_RLE_start_length:
+	  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
+	  length = read_uleb128 (start, &bytes_read, finish);
+	  start += bytes_read;
+	  end = begin + length;
+	  break;
+	case DW_RLE_offset_pair:
+	  begin = read_uleb128 (start, &bytes_read, finish);
+	  start += bytes_read;
+	  end = read_uleb128 (start, &bytes_read, finish);
+	  start += bytes_read;
+	  break;
+	case DW_RLE_start_end:
+	  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
+	  SAFE_BYTE_GET_AND_INC (end, start, pointer_size, finish);
+	  break;
+	default:
+	  error (_("Invalid range list entry type %d\n"), rlet);
+	  rlet = DW_RLE_end_of_list;
+	  break;
+	}
+      if (rlet == DW_RLE_end_of_list)
+	break;
+      if (rlet == DW_RLE_base_address)
+	continue;
+
+      print_dwarf_vma (begin + base_address, pointer_size);
+      print_dwarf_vma (end + base_address, pointer_size);
+
+      if (begin == end)
+	fputs (_("(start == end)"), stdout);
+      else if (begin > end)
+	fputs (_("(start > end)"), stdout);
+
+      putchar ('\n');
+    }
+}
+
 static int
 display_debug_ranges (struct dwarf_section *section,
 		      void *file ATTRIBUTE_UNUSED)
@@ -5184,6 +5896,8 @@ display_debug_ranges (struct dwarf_section *section,
   unsigned char *finish = start + bytes;
   unsigned int num_range_list, i;
   struct range_entry *range_entries, *range_entry_fill;
+  int is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
+  unsigned char address_size;
 
   if (bytes == 0)
     {
@@ -5191,6 +5905,78 @@ display_debug_ranges (struct dwarf_section *section,
       return 0;
     }
 
+  if (is_rnglists)
+    {
+      dwarf_vma initial_length;
+      unsigned int initial_length_size;
+      unsigned char segment_selector_size;
+      unsigned int offset_size, offset_entry_count;
+      unsigned short version;
+
+      /* Get and check the length of the block.  */
+      SAFE_BYTE_GET_AND_INC (initial_length, start, 4, finish);
+
+      if (initial_length == 0xffffffff)
+	{
+	  /* This section is 64-bit DWARF 3.  */
+	  SAFE_BYTE_GET_AND_INC (initial_length, start, 8, finish);
+	  offset_size = 8;
+	  initial_length_size = 12;
+	}
+      else
+	{
+	  offset_size = 4;
+	  initial_length_size = 4;
+	}
+
+      if (initial_length + initial_length_size > section->size)
+	{
+	  /* If the length field has a relocation against it, then we should
+	     not complain if it is inaccurate (and probably negative).
+	     It is copied from .debug_line handling code.  */
+	  if (reloc_at (section, (start - section->start) - offset_size))
+	    {
+	      initial_length = (finish - start) - initial_length_size;
+	    }
+	  else
+	    {
+	      warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"),
+		    (long) initial_length);
+	      return 0;
+	    }
+	}
+
+      /* Get and check the version number.  */
+      SAFE_BYTE_GET_AND_INC (version, start, 2, finish);
+
+      if (version != 5)
+	{
+	  warn (_("Only DWARF version 5 debug_rnglists info "
+		  "is currently supported.\n"));
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (address_size, start, 1, finish);
+
+      SAFE_BYTE_GET_AND_INC (segment_selector_size, start, 1, finish);
+      if (segment_selector_size != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported segment selector size: %d.\n"),
+		section->name, segment_selector_size);
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (offset_entry_count, start, 4, finish);
+      if (offset_entry_count != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported offset entry count: %u.\n"),
+		section->name, offset_entry_count);
+	  return 0;
+	}
+    }
+
   if (load_debug_info (file) == 0)
     {
       warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
@@ -5246,7 +6032,7 @@ display_debug_ranges (struct dwarf_section *section,
       unsigned char *next;
       unsigned long base_address;
 
-      pointer_size = debug_info_p->pointer_size;
+      pointer_size = (is_rnglists ? address_size : debug_info_p->pointer_size);
       offset = range_entry->ranges_offset;
       next = section_begin + offset;
       base_address = debug_info_p->base_address;
@@ -5277,45 +6063,8 @@ display_debug_ranges (struct dwarf_section *section,
       start = next;
       last_start = next;
 
-      while (start < finish)
-	{
-	  dwarf_vma begin;
-	  dwarf_vma end;
-
-	  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
-	  if (start >= finish)
-	    break;
-	  SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
-
-	  printf ("    %8.8lx ", offset);
-
-	  if (begin == 0 && end == 0)
-	    {
-	      printf (_("<End of list>\n"));
-	      break;
-	    }
-
-	  /* Check base address specifiers.  */
-          if (is_max_address (begin, pointer_size)
-              && !is_max_address (end, pointer_size))
-	    {
-	      base_address = end;
-	      print_dwarf_vma (begin, pointer_size);
-	      print_dwarf_vma (end, pointer_size);
-	      printf ("(base address)\n");
-	      continue;
-	    }
-
-	  print_dwarf_vma (begin + base_address, pointer_size);
-	  print_dwarf_vma (end + base_address, pointer_size);
-
-	  if (begin == end)
-	    fputs (_("(start == end)"), stdout);
-	  else if (begin > end)
-	    fputs (_("(start > end)"), stdout);
-
-	  putchar ('\n');
-	}
+      (is_rnglists ? display_debug_rnglists_list : display_debug_ranges_list)
+	(start, finish, pointer_size, offset, base_address);
     }
   putchar ('\n');
 
@@ -7725,14 +8474,20 @@ struct dwarf_section_display debug_displays[] =
     display_debug_macro,    &do_debug_macinfo,	TRUE },
   { { ".debug_str",	    ".zdebug_str",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_str,	    &do_debug_str,	FALSE },
+  { { ".debug_line_str",    ".zdebug_line_str",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
+    display_debug_str,	    &do_debug_str,	FALSE },
   { { ".debug_loc",	    ".zdebug_loc",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_loc,	    &do_debug_loc,	TRUE },
+  { { ".debug_loclists",    ".zdebug_loclists",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
+    display_debug_loc,	    &do_debug_loc,	TRUE },
   { { ".debug_pubtypes",    ".zdebug_pubtypes",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_pubnames, &do_debug_pubtypes,	FALSE },
   { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_gnu_pubnames, &do_debug_pubtypes, FALSE },
   { { ".debug_ranges",	    ".zdebug_ranges",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_ranges,   &do_debug_ranges,	TRUE },
+  { { ".debug_rnglists",    ".zdebug_rnglists",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
+    display_debug_ranges,   &do_debug_ranges,	TRUE },
   { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_not_supported, NULL,		FALSE },
   { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0, 0, NULL, 0, NULL },
diff --git a/binutils/dwarf.h b/binutils/dwarf.h
index 30562be..cf9f331 100644
--- a/binutils/dwarf.h
+++ b/binutils/dwarf.h
@@ -18,6 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "dwarf2.h" /* for enum dwarf_unit_type */
+
 typedef unsigned HOST_WIDEST_INT  dwarf_vma;
 typedef HOST_WIDEST_INT           dwarf_signed_vma;
 typedef unsigned HOST_WIDEST_INT  dwarf_size_type;
@@ -34,6 +36,7 @@ typedef struct
   int            li_line_base;
   unsigned char  li_line_range;
   unsigned char  li_opcode_base;
+  unsigned int   li_offset_size;
 }
 DWARF2_Internal_LineInfo;
 
@@ -54,6 +57,7 @@ typedef struct
   unsigned short cu_version;
   dwarf_vma	 cu_abbrev_offset;
   unsigned char  cu_pointer_size;
+  enum dwarf_unit_type cu_unit_type;
 }
 DWARF2_Internal_CompUnit;
 
@@ -83,6 +87,7 @@ enum dwarf_section_display_enum
   macinfo,
   macro,
   str,
+  line_str,
   loc,
   pubtypes,
   gnu_pubtypes,
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 150b680..a136c3c 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5945,11 +5945,13 @@ process_section_headers (FILE * file)
 	      || (do_debug_pubtypes && const_strneq (name, "gnu_pubtypes"))
 	      || (do_debug_aranges  && const_strneq (name, "aranges"))
 	      || (do_debug_ranges   && const_strneq (name, "ranges"))
+	      || (do_debug_ranges   && const_strneq (name, "rnglists"))
 	      || (do_debug_frames   && const_strneq (name, "frame"))
 	      || (do_debug_macinfo  && const_strneq (name, "macinfo"))
 	      || (do_debug_macinfo  && const_strneq (name, "macro"))
 	      || (do_debug_str      && const_strneq (name, "str"))
 	      || (do_debug_loc      && const_strneq (name, "loc"))
+	      || (do_debug_loc      && const_strneq (name, "loclists"))
 	      || (do_debug_addr     && const_strneq (name, "addr"))
 	      || (do_debug_cu_index && const_strneq (name, "cu_index"))
 	      || (do_debug_cu_index && const_strneq (name, "tu_index"))

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 2/6] Display user op byte
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
  2017-02-15 22:58 ` [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
  2017-02-15 22:58 ` [PATCH 4/6] DWARF-5: call sites Jan Kratochvil
@ 2017-02-15 22:58 ` Jan Kratochvil
  2017-02-22 11:30   ` Nick Clifton
  2017-02-15 22:58 ` [PATCH 6/6] DWARF-5: DW_FORM_data16 Jan Kratochvil
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-15 22:58 UTC (permalink / raw)
  To: binutils; +Cc: Victor Leschuk

Hi,

I found this small patch useful when decrypting new DWARF.

Jan


binutils/ChangeLog
2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (decode_location_expression): Display also OP.
---
 binutils/dwarf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 368c498..9d9a657 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1421,9 +1421,9 @@ decode_location_expression (unsigned char * data,
 	default:
 	  if (op >= DW_OP_lo_user
 	      && op <= DW_OP_hi_user)
-	    printf (_("(User defined location op)"));
+	    printf (_("(User defined location op 0x%x)"), op);
 	  else
-	    printf (_("(Unknown location op)"));
+	    printf (_("(Unknown location op 0x%x)"), op);
 	  /* No way to tell where the next op is, so just bail.  */
 	  return need_frame_base;
 	}

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/6] DWARF attrs: add delimiter
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
                   ` (4 preceding siblings ...)
  2017-02-15 22:58 ` [PATCH 5/6] DWARF-5: Macros Jan Kratochvil
@ 2017-02-16 10:59 ` Nick Clifton
  2017-02-16 20:13   ` Jan Kratochvil
  2017-02-22 11:48 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
  6 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-16 10:59 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

> 2017-02-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (display_block): Add parameter delimiter.
> 	(decode_location_expression): Update display_block callers.
> 	(read_and_display_attr_value): Add parameter delimiter.
> 	(read_and_display_attr, display_debug_macro): Update
> 	read_and_display_attr_value caller.

The patch looks good to me.  But ... I would be happier if it included
a testcase to check the new functionality.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/6] DWARF attrs: add delimiter
  2017-02-16 10:59 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
@ 2017-02-16 20:13   ` Jan Kratochvil
  2017-02-17  8:37     ` Nick Clifton
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-16 20:13 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

Hi Nick,

On Thu, 16 Feb 2017 11:59:10 +0100, Nick Clifton wrote:
> The patch looks good to me.  But ... I would be happier if it included
> a testcase to check the new functionality.

before coding it - is it OK do use x86_64 specific .s (and output .d) files
where .s is built with?
	-gdwarf-5 -S -dA

I understand an arch-independent .s file would be better but that would need
a lot of hand coding IMO.


Thanks,
Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/6] DWARF attrs: add delimiter
  2017-02-16 20:13   ` Jan Kratochvil
@ 2017-02-17  8:37     ` Nick Clifton
  2017-02-18 19:47       ` [patch] DWARF-5: testcase [Re: [PATCH 1/6] DWARF attrs: add delimiter] Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-17  8:37 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: binutils, Victor Leschuk

Hi Jan,

> before coding it - is it OK do use x86_64 specific .s (and output .d) files
> where .s is built with?
> 	-gdwarf-5 -S -dA
> 
> I understand an arch-independent .s file would be better but that would need
> a lot of hand coding IMO.

Yes and no ... :-)

What I suggest is that you use "-gdwarf-5 -S -dA" to create the .s file.  Then
strip any x86_64 instructions from it, (replacing them with .dc.b directives or
something similar if you need to make sure that the region concerned has some
content), and then use this reduced, and hopefully target neutral, assembler 
source file as the input for the new test(s).

IE we really do want a test that will work across all, or at least most, architectures
unless you need to test architecture specific parts of the DWARF-5 standard.  (Are 
there any architecture specific parts of the new standard ?)  I do not mind if you
have to add XFAILs for a few architectures, as I know that some of them can be a bit
funny when it comes to generating DWARF information.  But ideally we should be sure
that the encoding and decoding works for as many architectures as possible.

Cheers
  Nick

PS.  If you a potential test case, but you do not want to spin up 200+ toolchains to
test all of the potential targets then feel free to send it to me.  I already have
the toolchains set up and I can quickly run the new test past them all...

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [patch] DWARF-5: testcase  [Re: [PATCH 1/6] DWARF attrs: add delimiter]
  2017-02-17  8:37     ` Nick Clifton
@ 2017-02-18 19:47       ` Jan Kratochvil
  2017-02-21  9:44         ` Nick Clifton
  0 siblings, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-18 19:47 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 867 bytes --]

Hi Nick,

On Fri, 17 Feb 2017 09:37:03 +0100, Nick Clifton wrote:
> > I understand an arch-independent .s file would be better but that would need
> > a lot of hand coding IMO.
> 
> Yes and no ... :-)
> 
> What I suggest is that you use "-gdwarf-5 -S -dA" to create the .s file.  Then
> strip any x86_64 instructions from it,

In the end it was not so much work but this is what I meant by that "a lot of
hand coding". :-)


> (Are there any architecture specific parts of the new standard ?)

No, I am not aware of any.


> PS.  If you a potential test case, but you do not want to spin up 200+ toolchains to
> test all of the potential targets then feel free to send it to me.  I already have
> the toolchains set up and I can quickly run the new test past them all...

Feel free to throw the results at me.  I have already tested non-x86 big-endian.


Thanks,
Jan

[-- Attachment #2: Type: message/rfc822, Size: 41163 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] DWARF-5: testcase Hi,
Date: Fri, 17 Feb 2017 23:01:50 +0100

this is a testcase.  Developed on Fedora 25 x86_64 and tested on RHEL-6.8 ppc64.

/root/jkratoch/redhat/gdb-git/binutils/testsuite/binutils-all/dw5.S:136: Error: unknown pseudo-op: `.value'
 - used .2byte

regexp_diff match failure
regexp "^    <cc>   DW_AT_location    : 9 byte block: 3 4 0 0 0 0 0 0 0         \(DW_OP_addr: 4\)$"
line   "    <cc>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 4  (DW_OP_addr: 4)"
regexp_diff match failure
regexp "^    <e0>   DW_AT_location    : 9 byte block: 3 8 0 0 0 0 0 0 0         \(DW_OP_addr: 8\)$"
line   "    <e0>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 8  (DW_OP_addr: 8)"
 - Made it accept both outputs.

regexp_diff match failure
regexp "^    <138>   DW_AT_location    : 1 byte block: 55       \(DW_OP_reg5 \(rdi\)\)$"
line   "    <138>   DW_AT_location    : 1 byte block: 55        (DW_OP_reg5 (r5))"
regexp_diff match failure
regexp "^    00000015 0000000000000000 0000000000000002 \(DW_OP_reg5 \(rdi\)\)$"
line   "    00000015 0000000000000000 0000000000000002 (DW_OP_reg5 (r5))"
regexp_diff match failure
regexp "^    0000001a 0000000000000002 0000000000000005 \(DW_OP_entry_value: \(DW_OP_reg5 \(rdi\)\); DW_OP_stack_value\)$"
line   "    0000001a 0000000000000002 0000000000000005 (DW_OP_entry_value: (DW_OP_reg5 (r5)); DW_OP_stack_value)"
regexp_diff match failure
regexp "^    0000002c 0000000000000000 0000000000000002 \(DW_OP_reg4 \(rsi\)\)$"
line   "    0000002c 0000000000000000 0000000000000002 (DW_OP_reg4 (r4))"
regexp_diff match failure
regexp "^    00000031 0000000000000002 0000000000000005 \(DW_OP_entry_value: \(DW_OP_reg4 \(rsi\)\); DW_OP_stack_value\)$"
line   "    00000031 0000000000000002 0000000000000005 (DW_OP_entry_value: (DW_OP_reg4 (r4)); DW_OP_stack_value)"
FAIL: readelf -wiaoRlL
 - Made it accept registers as: [^()]*


Jan
---
 binutils/testsuite/binutils-all/dw5.S       | 685 ++++++++++++++++++++++++++++
 binutils/testsuite/binutils-all/dw5.W       | 355 ++++++++++++++
 binutils/testsuite/binutils-all/readelf.exp |  19 +
 3 files changed, 1059 insertions(+)
 create mode 100644 binutils/testsuite/binutils-all/dw5.S
 create mode 100644 binutils/testsuite/binutils-all/dw5.W

diff --git a/binutils/testsuite/binutils-all/dw5.S b/binutils/testsuite/binutils-all/dw5.S
new file mode 100644
index 0000000..2ef9847
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw5.S
@@ -0,0 +1,685 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+	.file	"main.c"
+	.text
+.Ltext0:
+	.p2align 4,,15
+	.globl	func
+	.type	func, @function
+func:
+.LFB0:
+	/* main.c:5 */
+.LM1:
+	.cfi_startproc
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	/* main.c:5 */
+.LM2:
+	.dc.b 0
+/* SUCC: */
+	.dc.b 0
+	.cfi_endproc
+.LFE0:
+	.size	func, .-func
+	.section	.text.startup,"ax",@progbits
+	.p2align 4,,15
+	.globl	main
+	.type	main, @function
+main:
+.LFB1:
+	/* main.c:6 */
+.LM3:
+	.cfi_startproc
+.LVL0:
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	.dc.b 0
+	.cfi_def_cfa_offset 16
+	/* main.c:6 */
+.LM4:
+	.dc.b 0
+.LVL1:
+	.dc.b 0
+.LVL2:
+	.dc.b 0
+	.cfi_def_cfa_offset 8
+/* SUCC: EXIT [100.0%]  */
+	.dc.b 0
+	.cfi_endproc
+.LFE1:
+	.size	main, .-main
+	.comm	pvar,8,8
+	.comm	yvar,4,4
+	.globl	xvar
+	.data
+	.align 4
+	.type	xvar, @object
+	.size	xvar, 4
+xvar:
+	.long	42
+	.text
+.Letext0:
+	.section	.debug_info,"",@progbits
+.Ldebug_info0:
+	.long	0x160	/* Length of Compilation Unit Info */
+	.2byte	0x5	/* DWARF version number */
+	.byte	0x1	/* DW_UT_compile */
+	.byte	0x8	/* Pointer Size (in bytes) */
+	.long	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
+	.uleb128 0x6	/* (DIE (0xc) DW_TAG_compile_unit) */
+	.long	.LASF21	/* DW_AT_producer: "GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2" */
+	.byte	0x1d	/* DW_AT_language */
+	.long	.LASF0	/* DW_AT_name: "main.c" */
+	.long	.LASF1	/* DW_AT_comp_dir: "" */
+	.long	.LLRL2	/* DW_AT_ranges */
+	.quad	0	/* DW_AT_low_pc */
+	.long	.Ldebug_line0	/* DW_AT_stmt_list */
+	.uleb128 0x1	/* (DIE (0x2a) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x8	/* DW_AT_encoding */
+	.long	.LASF2	/* DW_AT_name: "unsigned char" */
+	.uleb128 0x1	/* (DIE (0x31) DW_TAG_base_type) */
+	.byte	0x2	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.long	.LASF3	/* DW_AT_name: "short unsigned int" */
+	.uleb128 0x1	/* (DIE (0x38) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.long	.LASF4	/* DW_AT_name: "unsigned int" */
+	.uleb128 0x1	/* (DIE (0x3f) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.long	.LASF5	/* DW_AT_name: "long unsigned int" */
+	.uleb128 0x1	/* (DIE (0x46) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x6	/* DW_AT_encoding */
+	.long	.LASF6	/* DW_AT_name: "signed char" */
+	.uleb128 0x1	/* (DIE (0x4d) DW_TAG_base_type) */
+	.byte	0x2	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.long	.LASF7	/* DW_AT_name: "short int" */
+	.uleb128 0x7	/* (DIE (0x54) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.ascii "int\0"	/* DW_AT_name */
+	.uleb128 0x1	/* (DIE (0x5b) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.long	.LASF8	/* DW_AT_name: "long int" */
+	.uleb128 0x1	/* (DIE (0x62) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.long	.LASF9	/* DW_AT_name: "sizetype" */
+	.uleb128 0x3	/* (DIE (0x69) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.long	0x6e	/* DW_AT_type */
+	.uleb128 0x1	/* (DIE (0x6e) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x6	/* DW_AT_encoding */
+	.long	.LASF10	/* DW_AT_name: "char" */
+	.uleb128 0x8	/* (DIE (0x75) DW_TAG_variable) */
+	.long	.LASF11	/* DW_AT_name: "__environ" */
+	.byte	0x2	/* DW_AT_decl_file (/usr/include/unistd.h) */
+	.2byte	0x222	/* DW_AT_decl_line */
+	.long	0x81	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x3	/* (DIE (0x81) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.long	0x69	/* DW_AT_type */
+	.uleb128 0x2	/* (DIE (0x86) DW_TAG_variable) */
+	.long	.LASF12	/* DW_AT_name: "optarg" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x39	/* DW_AT_decl_line */
+	.long	0x69	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0x90) DW_TAG_variable) */
+	.long	.LASF13	/* DW_AT_name: "optind" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x47	/* DW_AT_decl_line */
+	.long	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0x9a) DW_TAG_variable) */
+	.long	.LASF14	/* DW_AT_name: "opterr" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x4c	/* DW_AT_decl_line */
+	.long	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0xa4) DW_TAG_variable) */
+	.long	.LASF15	/* DW_AT_name: "optopt" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x50	/* DW_AT_decl_line */
+	.long	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x4	/* (DIE (0xae) DW_TAG_variable) */
+	.long	.LASF16	/* DW_AT_name: "xvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x2	/* DW_AT_decl_line */
+	.long	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.quad	xvar
+	.uleb128 0x4	/* (DIE (0xc2) DW_TAG_variable) */
+	.long	.LASF17	/* DW_AT_name: "yvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x3	/* DW_AT_decl_line */
+	.long	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.quad	yvar
+	.uleb128 0x4	/* (DIE (0xd6) DW_TAG_variable) */
+	.long	.LASF18	/* DW_AT_name: "pvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x4	/* DW_AT_decl_line */
+	.long	0xea	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.quad	pvar
+	.uleb128 0x3	/* (DIE (0xea) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.long	0x54	/* DW_AT_type */
+	.uleb128 0x9	/* (DIE (0xef) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.long	.LASF22	/* DW_AT_name: "main" */
+	.byte	0x1	/* DW_AT_decl_file (main.c) */
+	.byte	0x6	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.long	0x54	/* DW_AT_type */
+	.quad	.LFB1	/* DW_AT_low_pc */
+	.quad	.LFE1-.LFB1	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.long	0x13e	/* DW_AT_sibling */
+	.uleb128 0x5	/* (DIE (0x110) DW_TAG_formal_parameter) */
+	.long	.LASF19	/* DW_AT_name: "argc" */
+			/* DW_AT_decl_file (1, main.c) */
+			/* DW_AT_decl_line (0x6) */
+	.long	0x54	/* DW_AT_type */
+	.long	.LLST0	/* DW_AT_location */
+	.uleb128 0x5	/* (DIE (0x11d) DW_TAG_formal_parameter) */
+	.long	.LASF20	/* DW_AT_name: "argv" */
+			/* DW_AT_decl_file (1, main.c) */
+			/* DW_AT_decl_line (0x6) */
+	.long	0x81	/* DW_AT_type */
+	.long	.LLST1	/* DW_AT_location */
+	.uleb128 0xa	/* (DIE (0x12a) DW_TAG_call_site) */
+	.quad	.LVL2	/* DW_AT_call_return_pc */
+	.long	0x157	/* DW_AT_call_origin */
+	.uleb128 0xb	/* (DIE (0x137) DW_TAG_call_site_parameter) */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x1	/* DW_AT_call_value */
+	.byte	0x30	/* DW_OP_lit0 */
+	.byte	0	/* end of children of DIE 0x12a */
+	.byte	0	/* end of children of DIE 0xef */
+	.uleb128 0xc	/* (DIE (0x13e) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.long	.LASF23	/* DW_AT_name: "func" */
+	.byte	0x1	/* DW_AT_decl_file (main.c) */
+	.byte	0x5	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.quad	.LFB0	/* DW_AT_low_pc */
+	.quad	.LFE0-.LFB0	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.uleb128 0xd	/* (DIE (0x157) DW_TAG_subprogram) */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.long	.LASF24	/* DW_AT_linkage_name: "alarm" */
+	.long	.LASF24	/* DW_AT_name: "alarm" */
+	.byte	0x2	/* DW_AT_decl_file (/usr/include/unistd.h) */
+	.2byte	0x1b3	/* DW_AT_decl_line */
+	.byte	0	/* end of children of DIE 0xc */
+	.section	.debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+	.uleb128 0x1	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.byte	0
+	.byte	0
+	.uleb128 0x2	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 3	/* (/usr/include/getopt.h) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x3	/* (abbrev code) */
+	.uleb128 0xf	/* (TAG: DW_TAG_pointer_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 8
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x4	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (main.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x5	/* (abbrev code) */
+	.uleb128 0x5	/* (TAG: DW_TAG_formal_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (main.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 6
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0x6	/* (abbrev code) */
+	.uleb128 0x11	/* (TAG: DW_TAG_compile_unit) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x25	/* (DW_AT_producer) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x13	/* (DW_AT_language) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x1b	/* (DW_AT_comp_dir) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x55	/* (DW_AT_ranges) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x10	/* (DW_AT_stmt_list) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0x7	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.byte	0
+	.byte	0
+	.uleb128 0x8	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x5	/* (DW_FORM_data2) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x9	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xa	/* (abbrev code) */
+	.uleb128 0x48	/* (TAG: DW_TAG_call_site) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x7d	/* (DW_AT_call_return_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x7f	/* (DW_AT_call_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xb	/* (abbrev code) */
+	.uleb128 0x49	/* (TAG: DW_TAG_call_site_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7e	/* (DW_AT_call_value) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0xc	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0xd	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x6e	/* (DW_AT_linkage_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x5	/* (DW_FORM_data2) */
+	.byte	0
+	.byte	0
+	.byte	0
+	.section	.debug_loclists,"",@progbits
+	.long	.Ldebug_loc2-.Ldebug_loc1	/* Length of Location Lists */
+.Ldebug_loc1:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.long	0	/* Offset Entry Count */
+.Ldebug_loc0:
+.LLST0:
+	.byte	0x6	/* DW_LLE_base_address (*.LLST0) */
+	.quad	.LVL0	/* Base address (*.LLST0) */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST0) */
+	.uleb128 .LVL0-.LVL0	/* Location list begin address (*.LLST0) */
+	.uleb128 .LVL1-.LVL0	/* Location list end address (*.LLST0) */
+	.uleb128 0x1	/* Location expression size */
+	.byte	0x55	/* DW_OP_reg5 */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST0) */
+	.uleb128 .LVL1-.LVL0	/* Location list begin address (*.LLST0) */
+	.uleb128 .LFE1-.LVL0	/* Location list end address (*.LLST0) */
+	.uleb128 0x4	/* Location expression size */
+	.byte	0xa3	/* DW_OP_entry_value */
+	.uleb128 0x1
+	.byte	0x55	/* DW_OP_reg5 */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.byte	0	/* DW_LLE_end_of_list (*.LLST0) */
+.LLST1:
+	.byte	0x6	/* DW_LLE_base_address (*.LLST1) */
+	.quad	.LVL0	/* Base address (*.LLST1) */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST1) */
+	.uleb128 .LVL0-.LVL0	/* Location list begin address (*.LLST1) */
+	.uleb128 .LVL2-1-.LVL0	/* Location list end address (*.LLST1) */
+	.uleb128 0x1	/* Location expression size */
+	.byte	0x54	/* DW_OP_reg4 */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST1) */
+	.uleb128 .LVL2-1-.LVL0	/* Location list begin address (*.LLST1) */
+	.uleb128 .LFE1-.LVL0	/* Location list end address (*.LLST1) */
+	.uleb128 0x4	/* Location expression size */
+	.byte	0xa3	/* DW_OP_entry_value */
+	.uleb128 0x1
+	.byte	0x54	/* DW_OP_reg4 */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.byte	0	/* DW_LLE_end_of_list (*.LLST1) */
+.Ldebug_loc2:
+	.section	.debug_aranges,"",@progbits
+	.long	0x3c	/* Length of Address Ranges Info */
+	.2byte	0x2	/* DWARF Version */
+	.long	.Ldebug_info0	/* Offset of Compilation Unit Info */
+	.byte	0x8	/* Size of Address */
+	.byte	0	/* Size of Segment Descriptor */
+	.2byte	0	/* Pad to 16 byte boundary */
+	.2byte	0
+	.quad	.Ltext0	/* Address */
+	.quad	.Letext0-.Ltext0	/* Length */
+	.quad	.LFB1	/* Address */
+	.quad	.LFE1-.LFB1	/* Length */
+	.quad	0
+	.quad	0
+	.section	.debug_rnglists,"",@progbits
+.Ldebug_ranges0:
+	.long	.Ldebug_ranges3-.Ldebug_ranges2	/* Length of Range Lists */
+.Ldebug_ranges2:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.long	0	/* Offset Entry Count */
+.LLRL2:
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL2) */
+	.quad	.Ltext0	/* Range begin address (*.LLRL2) */
+	.uleb128 .Letext0-.Ltext0	/* Range length (*.LLRL2) */
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL2) */
+	.quad	.LFB1	/* Range begin address (*.LLRL2) */
+	.uleb128 .LFE1-.LFB1	/* Range length (*.LLRL2) */
+	.byte	0	/* DW_RLE_end_of_list (*.LLRL2) */
+.Ldebug_ranges3:
+	.section	.debug_line,"",@progbits
+.Ldebug_line0:
+	.long	.LELT0-.LSLT0	/* Length of Source Line Info */
+.LSLT0:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.long	.LELTP0-.LASLTP0	/* Prolog Length */
+.LASLTP0:
+	.byte	0x1	/* Minimum Instruction Length */
+	.byte	0x1	/* Maximum Operations Per Instruction */
+	.byte	0x1	/* Default is_stmt_start flag */
+	.byte	0xf6	/* Line Base Value (Special Opcodes) */
+	.byte	0xf2	/* Line Range Value (Special Opcodes) */
+	.byte	0xd	/* Special Opcode Base */
+	.byte	0	/* opcode: 0x1 has 0 args */
+	.byte	0x1	/* opcode: 0x2 has 1 args */
+	.byte	0x1	/* opcode: 0x3 has 1 args */
+	.byte	0x1	/* opcode: 0x4 has 1 args */
+	.byte	0x1	/* opcode: 0x5 has 1 args */
+	.byte	0	/* opcode: 0x6 has 0 args */
+	.byte	0	/* opcode: 0x7 has 0 args */
+	.byte	0	/* opcode: 0x8 has 0 args */
+	.byte	0x1	/* opcode: 0x9 has 1 args */
+	.byte	0	/* opcode: 0xa has 0 args */
+	.byte	0	/* opcode: 0xb has 0 args */
+	.byte	0x1	/* opcode: 0xc has 1 args */
+	.byte	0x1	/* Directory entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x3	/* Directories count */
+	.long	.LASF1	/* Directory Entry: 0: "" */
+	.long	.LASF25	/* Directory Entry: 0: "" */
+	.long	.LASF26	/* Directory Entry: 0: "/usr/include" */
+	.byte	0x2	/* File name entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x2	/* DW_LNCT_directory_index */
+	.uleb128 0xb	/* DW_FORM_data1 */
+	.uleb128 0x4	/* File names count */
+	.long	.LASF0	/* File Entry: 0: "main.c" */
+	.byte	0
+	.long	.LASF27	/* File Entry: 0: "main.c" */
+	.byte	0x1
+	.long	.LASF28	/* File Entry: 0: "unistd.h" */
+	.byte	0x2
+	.long	.LASF29	/* File Entry: 0: "getopt.h" */
+	.byte	0x2
+.LELTP0:
+	.byte	0	/* set address *.LM3 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM3
+	.byte	0x1c	/* line 6 */
+	.byte	0	/* set address *.LM4 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM4
+	.byte	0x1	/* copy line 6 */
+	.byte	0	/* set address *.LFE1 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LFE1
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+	.byte	0	/* set address *.LM1 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM1
+	.byte	0x1b	/* line 5 */
+	.byte	0	/* set address *.LM2 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.LM2
+	.byte	0x1	/* copy line 5 */
+	.byte	0	/* set address *.Letext0 */
+	.uleb128 0x9
+	.byte	0x2
+	.quad	.Letext0
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+.LELT0:
+	.section	.debug_str,"MS",@progbits,1
+.LASF4:
+	.string	"unsigned int"
+.LASF15:
+	.string	"optopt"
+.LASF22:
+	.string	"main"
+.LASF6:
+	.string	"signed char"
+.LASF16:
+	.string	"xvar"
+.LASF5:
+	.string	"long unsigned int"
+.LASF14:
+	.string	"opterr"
+.LASF21:
+	.string	"GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2"
+.LASF2:
+	.string	"unsigned char"
+.LASF10:
+	.string	"char"
+.LASF13:
+	.string	"optind"
+.LASF8:
+	.string	"long int"
+.LASF19:
+	.string	"argc"
+.LASF3:
+	.string	"short unsigned int"
+.LASF17:
+	.string	"yvar"
+.LASF18:
+	.string	"pvar"
+.LASF11:
+	.string	"__environ"
+.LASF23:
+	.string	"func"
+.LASF12:
+	.string	"optarg"
+.LASF7:
+	.string	"short int"
+.LASF24:
+	.string	"alarm"
+.LASF9:
+	.string	"sizetype"
+.LASF20:
+	.string	"argv"
+	.section	.debug_line_str,"MS",@progbits,1
+.LASF1:
+	.string	""
+.LASF25:
+	.string	""
+.LASF29:
+	.string	"getopt.h"
+.LASF28:
+	.string	"unistd.h"
+.LASF0:
+	.string	"main.c"
+.LASF27:
+	.string	"main.c"
+.LASF26:
+	.string	"/usr/include"
+	.ident	"GCC: (GNU) 7.0.1 20170218 (experimental)"
+	.section	.note.GNU-stack,"",@progbits
diff --git a/binutils/testsuite/binutils-all/dw5.W b/binutils/testsuite/binutils-all/dw5.W
new file mode 100644
index 0000000..93ed07b
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw5.W
@@ -0,0 +1,355 @@
+Contents of the .debug_info section:
+
+  Compilation Unit @ offset 0x0:
+   Length:        0x160 \(32-bit\)
+   Version:       5
+   Abbrev Offset: 0x0
+   Pointer Size:  8
+ <0><c>: Abbrev Number: 6 \(DW_TAG_compile_unit\)
+    <d>   DW_AT_producer    : \(indirect string, offset: 0x43\): GNU C11 7.0.1 20170218 \(experimental\) -mtune=generic -march=x86-64 -gdwarf-5 -O2
+    <11>   DW_AT_language    : 29	\(C11\)
+    <12>   DW_AT_name        : \(indirect line string, offset: 0x14\): main.c
+    <16>   DW_AT_comp_dir    : \(indirect line string, offset: 0x0\): 
+    <1a>   DW_AT_ranges      : 0xc
+    <1e>   DW_AT_low_pc      : 0x0
+    <26>   DW_AT_stmt_list   : 0x0
+ <1><2a>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <2b>   DW_AT_byte_size   : 1
+    <2c>   DW_AT_encoding    : 8	\(unsigned char\)
+    <2d>   DW_AT_name        : \(indirect string, offset: 0x94\): unsigned char
+ <1><31>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <32>   DW_AT_byte_size   : 2
+    <33>   DW_AT_encoding    : 7	\(unsigned\)
+    <34>   DW_AT_name        : \(indirect string, offset: 0xbc\): short unsigned int
+ <1><38>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <39>   DW_AT_byte_size   : 4
+    <3a>   DW_AT_encoding    : 7	\(unsigned\)
+    <3b>   DW_AT_name        : \(indirect string, offset: 0x0\): unsigned int
+ <1><3f>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <40>   DW_AT_byte_size   : 8
+    <41>   DW_AT_encoding    : 7	\(unsigned\)
+    <42>   DW_AT_name        : \(indirect string, offset: 0x2a\): long unsigned int
+ <1><46>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <47>   DW_AT_byte_size   : 1
+    <48>   DW_AT_encoding    : 6	\(signed char\)
+    <49>   DW_AT_name        : \(indirect string, offset: 0x19\): signed char
+ <1><4d>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <4e>   DW_AT_byte_size   : 2
+    <4f>   DW_AT_encoding    : 5	\(signed\)
+    <50>   DW_AT_name        : \(indirect string, offset: 0xef\): short int
+ <1><54>: Abbrev Number: 7 \(DW_TAG_base_type\)
+    <55>   DW_AT_byte_size   : 4
+    <56>   DW_AT_encoding    : 5	\(signed\)
+    <57>   DW_AT_name        : int
+ <1><5b>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <5c>   DW_AT_byte_size   : 8
+    <5d>   DW_AT_encoding    : 5	\(signed\)
+    <5e>   DW_AT_name        : \(indirect string, offset: 0xae\): long int
+ <1><62>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <63>   DW_AT_byte_size   : 8
+    <64>   DW_AT_encoding    : 7	\(unsigned\)
+    <65>   DW_AT_name        : \(indirect string, offset: 0xff\): sizetype
+ <1><69>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <6a>   DW_AT_byte_size   : 8
+    <6a>   DW_AT_type        : <0x6e>
+ <1><6e>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <6f>   DW_AT_byte_size   : 1
+    <70>   DW_AT_encoding    : 6	\(signed char\)
+    <71>   DW_AT_name        : \(indirect string, offset: 0xa2\): char
+ <1><75>: Abbrev Number: 8 \(DW_TAG_variable\)
+    <76>   DW_AT_name        : \(indirect string, offset: 0xd9\): __environ
+    <7a>   DW_AT_decl_file   : 2
+    <7b>   DW_AT_decl_line   : 546
+    <7d>   DW_AT_type        : <0x81>
+    <81>   DW_AT_external    : 1
+    <81>   DW_AT_declaration : 1
+ <1><81>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <82>   DW_AT_byte_size   : 8
+    <82>   DW_AT_type        : <0x69>
+ <1><86>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <87>   DW_AT_name        : \(indirect string, offset: 0xe8\): optarg
+    <8b>   DW_AT_decl_file   : 3
+    <8b>   DW_AT_decl_line   : 57
+    <8c>   DW_AT_type        : <0x69>
+    <90>   DW_AT_external    : 1
+    <90>   DW_AT_declaration : 1
+ <1><90>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <91>   DW_AT_name        : \(indirect string, offset: 0xa7\): optind
+    <95>   DW_AT_decl_file   : 3
+    <95>   DW_AT_decl_line   : 71
+    <96>   DW_AT_type        : <0x54>
+    <9a>   DW_AT_external    : 1
+    <9a>   DW_AT_declaration : 1
+ <1><9a>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <9b>   DW_AT_name        : \(indirect string, offset: 0x3c\): opterr
+    <9f>   DW_AT_decl_file   : 3
+    <9f>   DW_AT_decl_line   : 76
+    <a0>   DW_AT_type        : <0x54>
+    <a4>   DW_AT_external    : 1
+    <a4>   DW_AT_declaration : 1
+ <1><a4>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <a5>   DW_AT_name        : \(indirect string, offset: 0xd\): optopt
+    <a9>   DW_AT_decl_file   : 3
+    <a9>   DW_AT_decl_line   : 80
+    <aa>   DW_AT_type        : <0x54>
+    <ae>   DW_AT_external    : 1
+    <ae>   DW_AT_declaration : 1
+ <1><ae>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <af>   DW_AT_name        : \(indirect string, offset: 0x25\): xvar
+    <b3>   DW_AT_decl_file   : 1
+    <b3>   DW_AT_decl_line   : 2
+    <b4>   DW_AT_type        : <0x54>
+    <b8>   DW_AT_external    : 1
+    <b8>   DW_AT_location    : 9 byte block: 3 0 0 0 0 0 0 0 0 	\(DW_OP_addr: 0\)
+ <1><c2>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <c3>   DW_AT_name        : \(indirect string, offset: 0xcf\): yvar
+    <c7>   DW_AT_decl_file   : 1
+    <c7>   DW_AT_decl_line   : 3
+    <c8>   DW_AT_type        : <0x54>
+    <cc>   DW_AT_external    : 1
+    <cc>   DW_AT_location    : 9 byte block: 3 [40] 0 0 0 0 0 0 [04] 	\(DW_OP_addr: 4\)
+ <1><d6>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <d7>   DW_AT_name        : \(indirect string, offset: 0xd4\): pvar
+    <db>   DW_AT_decl_file   : 1
+    <db>   DW_AT_decl_line   : 4
+    <dc>   DW_AT_type        : <0xea>
+    <e0>   DW_AT_external    : 1
+    <e0>   DW_AT_location    : 9 byte block: 3 [80] 0 0 0 0 0 0 [08] 	\(DW_OP_addr: 8\)
+ <1><ea>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <eb>   DW_AT_byte_size   : 8
+    <eb>   DW_AT_type        : <0x54>
+ <1><ef>: Abbrev Number: 9 \(DW_TAG_subprogram\)
+    <f0>   DW_AT_external    : 1
+    <f0>   DW_AT_name        : \(indirect string, offset: 0x14\): main
+    <f4>   DW_AT_decl_file   : 1
+    <f5>   DW_AT_decl_line   : 6
+    <f6>   DW_AT_prototyped  : 1
+    <f6>   DW_AT_type        : <0x54>
+    <fa>   DW_AT_low_pc      : 0x0
+    <102>   DW_AT_high_pc     : 0x5
+    <10a>   DW_AT_frame_base  : 1 byte block: 9c 	\(DW_OP_call_frame_cfa\)
+    <10c>   DW_AT_call_all_calls: 1
+    <10c>   DW_AT_sibling     : <0x13e>
+ <2><110>: Abbrev Number: 5 \(DW_TAG_formal_parameter\)
+    <111>   DW_AT_name        : \(indirect string, offset: 0xb7\): argc
+    <115>   DW_AT_decl_file   : 1
+    <115>   DW_AT_decl_line   : 6
+    <115>   DW_AT_type        : <0x54>
+    <119>   DW_AT_location    : 0xc \(location list\)
+ <2><11d>: Abbrev Number: 5 \(DW_TAG_formal_parameter\)
+    <11e>   DW_AT_name        : \(indirect string, offset: 0x108\): argv
+    <122>   DW_AT_decl_file   : 1
+    <122>   DW_AT_decl_line   : 6
+    <122>   DW_AT_type        : <0x81>
+    <126>   DW_AT_location    : 0x23 \(location list\)
+ <2><12a>: Abbrev Number: 10 \(DW_TAG_call_site\)
+    <12b>   DW_AT_call_return_pc: 0x3
+    <133>   DW_AT_call_origin : <0x157>
+ <3><137>: Abbrev Number: 11 \(DW_TAG_call_site_parameter\)
+    <138>   DW_AT_location    : 1 byte block: 55 	\(DW_OP_reg5 \([^()]*\)\)
+    <13a>   DW_AT_call_value  : 1 byte block: 30 	\(DW_OP_lit0\)
+ <3><13c>: Abbrev Number: 0
+ <2><13d>: Abbrev Number: 0
+ <1><13e>: Abbrev Number: 12 \(DW_TAG_subprogram\)
+    <13f>   DW_AT_external    : 1
+    <13f>   DW_AT_name        : \(indirect string, offset: 0xe3\): func
+    <143>   DW_AT_decl_file   : 1
+    <144>   DW_AT_decl_line   : 5
+    <145>   DW_AT_prototyped  : 1
+    <145>   DW_AT_low_pc      : 0x0
+    <14d>   DW_AT_high_pc     : 0x2
+    <155>   DW_AT_frame_base  : 1 byte block: 9c 	\(DW_OP_call_frame_cfa\)
+    <157>   DW_AT_call_all_calls: 1
+ <1><157>: Abbrev Number: 13 \(DW_TAG_subprogram\)
+    <158>   DW_AT_external    : 1
+    <158>   DW_AT_declaration : 1
+    <158>   DW_AT_linkage_name: \(indirect string, offset: 0xf9\): alarm
+    <15c>   DW_AT_name        : \(indirect string, offset: 0xf9\): alarm
+    <160>   DW_AT_decl_file   : 2
+    <161>   DW_AT_decl_line   : 435
+ <1><163>: Abbrev Number: 0
+
+Contents of the .debug_abbrev section:
+
+  Number TAG \(0x0\)
+   1      DW_TAG_base_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_data1
+    DW_AT_encoding     DW_FORM_data1
+    DW_AT_name         DW_FORM_strp
+    DW_AT value: 0     DW_FORM value: 0
+   2      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 3
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   3      DW_TAG_pointer_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_implicit_const: 8
+    DW_AT_type         DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   4      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_location     DW_FORM_exprloc
+    DW_AT value: 0     DW_FORM value: 0
+   5      DW_TAG_formal_parameter    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 1
+    DW_AT_decl_line    DW_FORM_implicit_const: 6
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_location     DW_FORM_sec_offset
+    DW_AT value: 0     DW_FORM value: 0
+   6      DW_TAG_compile_unit    \[has children\]
+    DW_AT_producer     DW_FORM_strp
+    DW_AT_language     DW_FORM_data1
+    DW_AT_name         DW_FORM_line_strp
+    DW_AT_comp_dir     DW_FORM_line_strp
+    DW_AT_ranges       DW_FORM_sec_offset
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_stmt_list    DW_FORM_sec_offset
+    DW_AT value: 0     DW_FORM value: 0
+   7      DW_TAG_base_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_data1
+    DW_AT_encoding     DW_FORM_data1
+    DW_AT_name         DW_FORM_string
+    DW_AT value: 0     DW_FORM value: 0
+   8      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data2
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   9      DW_TAG_subprogram    \[has children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_prototyped   DW_FORM_flag_present
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_high_pc      DW_FORM_data8
+    DW_AT_frame_base   DW_FORM_exprloc
+    DW_AT_call_all_calls DW_FORM_flag_present
+    DW_AT_sibling      DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   10      DW_TAG_call_site    \[has children\]
+    DW_AT_call_return_pc DW_FORM_addr
+    DW_AT_call_origin  DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   11      DW_TAG_call_site_parameter    \[no children\]
+    DW_AT_location     DW_FORM_exprloc
+    DW_AT_call_value   DW_FORM_exprloc
+    DW_AT value: 0     DW_FORM value: 0
+   12      DW_TAG_subprogram    \[no children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_prototyped   DW_FORM_flag_present
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_high_pc      DW_FORM_data8
+    DW_AT_frame_base   DW_FORM_exprloc
+    DW_AT_call_all_calls DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   13      DW_TAG_subprogram    \[no children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT_linkage_name DW_FORM_strp
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data2
+    DW_AT value: 0     DW_FORM value: 0
+
+Contents of the .debug_loclists section:
+
+    Offset   Begin            End              Expression
+    0000000c 0000000000000000 \(base address\)
+    00000015 0000000000000000 0000000000000002 \(DW_OP_reg5 \([^()]*\)\)
+    0000001a 0000000000000002 0000000000000005 \(DW_OP_entry_value: \(DW_OP_reg5 \([^()]*\)\); DW_OP_stack_value\)
+    00000022 <End of list>
+    00000023 0000000000000000 \(base address\)
+    0000002c 0000000000000000 0000000000000002 \(DW_OP_reg4 \([^()]*\)\)
+    00000031 0000000000000002 0000000000000005 \(DW_OP_entry_value: \(DW_OP_reg4 \([^()]*\)\); DW_OP_stack_value\)
+    00000039 <End of list>
+
+Contents of the .debug_rnglists section:
+
+    Offset   Begin    End
+    0000000c 0000000000000000 0000000000000002 
+    00000016 0000000000000000 0000000000000005 
+    00000020 <End of list>
+
+Raw dump of debug contents of section .debug_line:
+
+  Offset:                      0x0
+  Length:                      144
+  DWARF Version:               5
+  Prologue Length:             60
+  Minimum Instruction Length:  1
+  Maximum Ops per Instruction: 1
+  Initial value of 'is_stmt':  1
+  Line Base:                   -10
+  Line Range:                  242
+  Opcode Base:                 13
+
+ Opcodes:
+  Opcode 1 has 0 args
+  Opcode 2 has 1 args
+  Opcode 3 has 1 args
+  Opcode 4 has 1 args
+  Opcode 5 has 1 args
+  Opcode 6 has 0 args
+  Opcode 7 has 0 args
+  Opcode 8 has 0 args
+  Opcode 9 has 1 args
+  Opcode 10 has 0 args
+  Opcode 11 has 0 args
+  Opcode 12 has 1 args
+
+ The Directory Table \(offset 0x22\):
+  Entry	Name
+  0	\(indirect line string, offset: 0x0\): 
+  1	\(indirect line string, offset: 0x1\): 
+  2	\(indirect line string, offset: 0x22\): /usr/include
+
+ The File name Table \(offset 0x34\):
+  Entry	Dir	Name
+  0	0	\(indirect line string, offset: 0x14\): main.c
+  1	1	\(indirect line string, offset: 0x1b\): main.c
+  2	2	\(indirect line string, offset: 0xb\): unistd.h
+  3	2	\(indirect line string, offset: 0x2\): getopt.h
+
+ Line Number Statements:
+  \[0x00000048\]  Extended opcode 2: set Address to 0x0
+  \[0x00000053\]  Special opcode 15: advance Address by 0 to 0x0 and Line by 5 to 6
+  \[0x00000054\]  Extended opcode 2: set Address to 0x1
+  \[0x0000005f\]  Copy
+  \[0x00000060\]  Extended opcode 2: set Address to 0x5
+  \[0x0000006b\]  Extended opcode 1: End of Sequence
+
+  \[0x0000006e\]  Extended opcode 2: set Address to 0x0
+  \[0x00000079\]  Special opcode 14: advance Address by 0 to 0x0 and Line by 4 to 5
+  \[0x0000007a\]  Extended opcode 2: set Address to 0x0
+  \[0x00000085\]  Copy
+  \[0x00000086\]  Extended opcode 2: set Address to 0x2
+  \[0x00000091\]  Extended opcode 1: End of Sequence
+
+
+Decoded dump of debug contents of section .debug_line:
+
+CU: ./main.c:
+File name                            Line number    Starting address
+main.c                                         6                   0
+main.c                                         6                 0x1
+
+main.c                                         5                   0
+main.c                                         5                   0
+
+
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index e442bdf..f31bf43 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -394,3 +394,22 @@ if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then {
 
     readelf_test {--decompress --hex-dump .debug_loc} $tempfile readelf.z  {}
 }
+
+# Assemble the DWARF-5 test file.
+if {![binutils_assemble $srcdir/$subdir/dw5.S tmpdir/dw5.o]} then {
+    perror "could not assemble dw5 test file"
+    unresolved "readelf - failed to assemble dw5"
+    return
+}
+
+if ![is_remote host] {
+    set tempfile tmpdir/dw5.o
+} else {
+    set tempfile [remote_download host tmpdir/dw5.o]
+}
+
+# First, determine the size, so specific output matchers can be used.
+readelf_find_size $tempfile
+
+# Run the tests.
+readelf_test -wiaoRlL $tempfile dw5.W {}
-- 
2.9.3

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [patch] DWARF-5: testcase [Re: [PATCH 1/6] DWARF attrs: add delimiter]
  2017-02-18 19:47       ` [patch] DWARF-5: testcase [Re: [PATCH 1/6] DWARF attrs: add delimiter] Jan Kratochvil
@ 2017-02-21  9:44         ` Nick Clifton
  2017-02-23 22:17           ` [commit] [patch] DWARF-5: testcase Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-21  9:44 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: binutils, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]

Hi Jan,

> In the end it was not so much work but this is what I meant by that "a lot of
> hand coding". :-)

:-)

When in doubt - do the right thing.

> Feel free to throw the results at me.  I have already tested non-x86 big-endian.

Attached is a revised test.

This version allows for:

  * Assembling on the ARM which uses the @ character as a line-comment character.
  * Assembling on targets which do not support CFi directives.
  * Assembling on the SH which does not support unaligned .long directives.
  * Assembling on various targets which do not support relocations for .quad values.
  * Testing on targets which generate extra text in the readelf output - because readelf does not support the relocations used (yet)

The patch also skips the test for RISCV targets as they currently do not support
non-constant LEB128 expressions.

The only targets which still fail this test are HPPA and HPPA64, which I believe
is due to a real bug somewhere in their backend code.  I have not tracked down the
actual bug yet, but I felt that it was better to leave the test as failing (rather
than xfailing it) as a reminder that it needs to be investigated.

Cheers
  Nick


[-- Attachment #2: dwarf5.test.patch --]
[-- Type: text/x-patch, Size: 39002 bytes --]

diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index e442bdf..10f2b7a 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -394,3 +394,28 @@ if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then {
 
     readelf_test {--decompress --hex-dump .debug_loc} $tempfile readelf.z  {}
 }
+
+# Skip the next test for the RISCV architectures because they do not
+# support .ULEB128 pseudo-ops with non-constant values.
+if ![istarget "riscv*-*-*"] then {
+
+    # Assemble the DWARF-5 test file.
+    if {![binutils_assemble $srcdir/$subdir/dw5.S tmpdir/dw5.o]} then {
+	perror "could not assemble dw5 test file"
+	unresolved "readelf - failed to assemble dw5"
+	return
+    }
+
+    # Download it.
+    if ![is_remote host] {
+	set tempfile tmpdir/dw5.o
+    } else {
+	set tempfile [remote_download host tmpdir/dw5.o]
+    }
+
+    # First, determine the size, so specific output matchers can be used.
+    readelf_find_size $tempfile
+
+    # Make sure that readelf can decode the contents.
+    readelf_test -wiaoRlL $tempfile dw5.W {}
+}
--- /dev/null	2017-02-21 08:01:49.237033818 +0000
+++ binutils/testsuite/binutils-all/dw5.S	2017-02-20 17:14:07.905230086 +0000
@@ -0,0 +1,679 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+	.file	"main.c"
+	.text
+.Ltext0:
+	.p2align 4,,15
+	.globl	func
+	.type	func, %function
+func:
+.LFB0:
+	/* main.c:5 */
+.LM1:
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	/* main.c:5 */
+.LM2:
+	.dc.b 0
+/* SUCC: */
+	.dc.b 0
+.LFE0:
+	.size	func, .-func
+	.section	.text.startup,"ax",%progbits
+	.p2align 4,,15
+	.globl	main
+	.type	main, %function
+main:
+.LFB1:
+	/* main.c:6 */
+.LM3:
+.LVL0:
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	.dc.b 0
+	/* main.c:6 */
+.LM4:
+	.dc.b 0
+.LVL1:
+	.dc.b 0
+.LVL2:
+	.dc.b 0
+/* SUCC: EXIT [100.0%]  */
+	.dc.b 0
+.LFE1:
+	.size	main, .-main
+	.comm	pvar,8,8
+	.comm	yvar,4,4
+	.globl	xvar
+	.data
+	.align 4
+	.type	xvar, %object
+	.size	xvar, 4
+xvar:
+	.4byte	42
+	.text
+.Letext0:
+	.section	.debug_info,"",%progbits
+.Ldebug_info0:
+	.4byte	0x160	/* Length of Compilation Unit Info */
+	.2byte	0x5	/* DWARF version number */
+	.byte	0x1	/* DW_UT_compile */
+	.byte	0x8	/* Pointer Size (in bytes) */
+	.4byte	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
+	.uleb128 0x6	/* (DIE (0xc) DW_TAG_compile_unit) */
+	.4byte	.LASF21	/* DW_AT_producer: "GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2" */
+	.byte	0x1d	/* DW_AT_language */
+	.4byte	.LASF0	/* DW_AT_name: "main.c" */
+	.4byte	.LASF1	/* DW_AT_comp_dir: "" */
+	.4byte	.LLRL2	/* DW_AT_ranges */
+	.8byte	0	/* DW_AT_low_pc */
+	.4byte	.Ldebug_line0	/* DW_AT_stmt_list */
+	.uleb128 0x1	/* (DIE (0x2a) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x8	/* DW_AT_encoding */
+	.4byte	.LASF2	/* DW_AT_name: "unsigned char" */
+	.uleb128 0x1	/* (DIE (0x31) DW_TAG_base_type) */
+	.byte	0x2	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF3	/* DW_AT_name: "short unsigned int" */
+	.uleb128 0x1	/* (DIE (0x38) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF4	/* DW_AT_name: "unsigned int" */
+	.uleb128 0x1	/* (DIE (0x3f) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF5	/* DW_AT_name: "long unsigned int" */
+	.uleb128 0x1	/* (DIE (0x46) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x6	/* DW_AT_encoding */
+	.4byte	.LASF6	/* DW_AT_name: "signed char" */
+	.uleb128 0x1	/* (DIE (0x4d) DW_TAG_base_type) */
+	.byte	0x2	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.4byte	.LASF7	/* DW_AT_name: "short int" */
+	.uleb128 0x7	/* (DIE (0x54) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.ascii "int\0"	/* DW_AT_name */
+	.uleb128 0x1	/* (DIE (0x5b) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.4byte	.LASF8	/* DW_AT_name: "long int" */
+	.uleb128 0x1	/* (DIE (0x62) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF9	/* DW_AT_name: "sizetype" */
+	.uleb128 0x3	/* (DIE (0x69) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.4byte	0x6e	/* DW_AT_type */
+	.uleb128 0x1	/* (DIE (0x6e) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x6	/* DW_AT_encoding */
+	.4byte	.LASF10	/* DW_AT_name: "char" */
+	.uleb128 0x8	/* (DIE (0x75) DW_TAG_variable) */
+	.4byte	.LASF11	/* DW_AT_name: "__environ" */
+	.byte	0x2	/* DW_AT_decl_file (/usr/include/unistd.h) */
+	.2byte	0x222	/* DW_AT_decl_line */
+	.4byte	0x81	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x3	/* (DIE (0x81) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.4byte	0x69	/* DW_AT_type */
+	.uleb128 0x2	/* (DIE (0x86) DW_TAG_variable) */
+	.4byte	.LASF12	/* DW_AT_name: "optarg" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x39	/* DW_AT_decl_line */
+	.4byte	0x69	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0x90) DW_TAG_variable) */
+	.4byte	.LASF13	/* DW_AT_name: "optind" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x47	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0x9a) DW_TAG_variable) */
+	.4byte	.LASF14	/* DW_AT_name: "opterr" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x4c	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0xa4) DW_TAG_variable) */
+	.4byte	.LASF15	/* DW_AT_name: "optopt" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x50	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x4	/* (DIE (0xae) DW_TAG_variable) */
+	.4byte	.LASF16	/* DW_AT_name: "xvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x2	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.8byte	0x1234
+	.uleb128 0x4	/* (DIE (0xc2) DW_TAG_variable) */
+	.4byte	.LASF17	/* DW_AT_name: "yvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x3	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.8byte	0x1234
+	.uleb128 0x4	/* (DIE (0xd6) DW_TAG_variable) */
+	.4byte	.LASF18	/* DW_AT_name: "pvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x4	/* DW_AT_decl_line */
+	.4byte	0xea	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.8byte	0x1234
+	.uleb128 0x3	/* (DIE (0xea) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.4byte	0x54	/* DW_AT_type */
+	.uleb128 0x9	/* (DIE (0xef) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.4byte	.LASF22	/* DW_AT_name: "main" */
+	.byte	0x1	/* DW_AT_decl_file (main.c) */
+	.byte	0x6	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.4byte	0x54	/* DW_AT_type */
+	.8byte	0x1234	/* DW_AT_low_pc */
+	.8byte	0x5678	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.4byte	0x13e	/* DW_AT_sibling */
+	.uleb128 0x5	/* (DIE (0x110) DW_TAG_formal_parameter) */
+	.4byte	.LASF19	/* DW_AT_name: "argc" */
+			/* DW_AT_decl_file (1, main.c) */
+			/* DW_AT_decl_line (0x6) */
+	.4byte	0x54	/* DW_AT_type */
+	.4byte	.LLST0	/* DW_AT_location */
+	.uleb128 0x5	/* (DIE (0x11d) DW_TAG_formal_parameter) */
+	.4byte	.LASF20	/* DW_AT_name: "argv" */
+			/* DW_AT_decl_file (1, main.c) */
+			/* DW_AT_decl_line (0x6) */
+	.4byte	0x81	/* DW_AT_type */
+	.4byte	.LLST1	/* DW_AT_location */
+	.uleb128 0xa	/* (DIE (0x12a) DW_TAG_call_site) */
+	.8byte	0x12345	/* DW_AT_call_return_pc */
+	.4byte	0x157	/* DW_AT_call_origin */
+	.uleb128 0xb	/* (DIE (0x137) DW_TAG_call_site_parameter) */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x1	/* DW_AT_call_value */
+	.byte	0x30	/* DW_OP_lit0 */
+	.byte	0	/* end of children of DIE 0x12a */
+	.byte	0	/* end of children of DIE 0xef */
+	.uleb128 0xc	/* (DIE (0x13e) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.4byte	.LASF23	/* DW_AT_name: "func" */
+	.byte	0x1	/* DW_AT_decl_file (main.c) */
+	.byte	0x5	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.8byte	0x1234	/* DW_AT_low_pc */
+	.8byte	0x5678	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.uleb128 0xd	/* (DIE (0x157) DW_TAG_subprogram) */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.4byte	.LASF24	/* DW_AT_linkage_name: "alarm" */
+	.4byte	.LASF24	/* DW_AT_name: "alarm" */
+	.byte	0x2	/* DW_AT_decl_file (/usr/include/unistd.h) */
+	.2byte	0x1b3	/* DW_AT_decl_line */
+	.byte	0	/* end of children of DIE 0xc */
+	.section	.debug_abbrev,"",%progbits
+.Ldebug_abbrev0:
+	.uleb128 0x1	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.byte	0
+	.byte	0
+	.uleb128 0x2	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 3	/* (/usr/include/getopt.h) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x3	/* (abbrev code) */
+	.uleb128 0xf	/* (TAG: DW_TAG_pointer_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 8
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x4	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (main.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x5	/* (abbrev code) */
+	.uleb128 0x5	/* (TAG: DW_TAG_formal_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (main.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 6
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0x6	/* (abbrev code) */
+	.uleb128 0x11	/* (TAG: DW_TAG_compile_unit) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x25	/* (DW_AT_producer) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x13	/* (DW_AT_language) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x1b	/* (DW_AT_comp_dir) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x55	/* (DW_AT_ranges) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x10	/* (DW_AT_stmt_list) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0x7	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.byte	0
+	.byte	0
+	.uleb128 0x8	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x5	/* (DW_FORM_data2) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x9	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xa	/* (abbrev code) */
+	.uleb128 0x48	/* (TAG: DW_TAG_call_site) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x7d	/* (DW_AT_call_return_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x7f	/* (DW_AT_call_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xb	/* (abbrev code) */
+	.uleb128 0x49	/* (TAG: DW_TAG_call_site_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7e	/* (DW_AT_call_value) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0xc	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0xd	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x6e	/* (DW_AT_linkage_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x5	/* (DW_FORM_data2) */
+	.byte	0
+	.byte	0
+	.byte	0
+	.section	.debug_loclists,"",%progbits
+	.4byte	.Ldebug_loc2-.Ldebug_loc1	/* Length of Location Lists */
+.Ldebug_loc1:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.4byte	0	/* Offset Entry Count */
+.Ldebug_loc0:
+.LLST0:
+	.byte	0x6	/* DW_LLE_base_address (*.LLST0) */
+	.8byte	0x1234	/* Base address (*.LLST0) */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST0) */
+	.uleb128 .LVL0-.LVL0	/* Location list begin address (*.LLST0) */
+	.uleb128 .LVL1-.LVL0	/* Location list end address (*.LLST0) */
+	.uleb128 0x1	/* Location expression size */
+	.byte	0x55	/* DW_OP_reg5 */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST0) */
+	.uleb128 .LVL1-.LVL0	/* Location list begin address (*.LLST0) */
+	.uleb128 .LFE1-.LVL0	/* Location list end address (*.LLST0) */
+	.uleb128 0x4	/* Location expression size */
+	.byte	0xa3	/* DW_OP_entry_value */
+	.uleb128 0x1
+	.byte	0x55	/* DW_OP_reg5 */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.byte	0	/* DW_LLE_end_of_list (*.LLST0) */
+.LLST1:
+	.byte	0x6	/* DW_LLE_base_address (*.LLST1) */
+	.8byte	0x1234	/* Base address (*.LLST1) */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST1) */
+	.uleb128 .LVL0-.LVL0	/* Location list begin address (*.LLST1) */
+	.uleb128 .LVL2-1-.LVL0	/* Location list end address (*.LLST1) */
+	.uleb128 0x1	/* Location expression size */
+	.byte	0x54	/* DW_OP_reg4 */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST1) */
+	.uleb128 .LVL2-1-.LVL0	/* Location list begin address (*.LLST1) */
+	.uleb128 .LFE1-.LVL0	/* Location list end address (*.LLST1) */
+	.uleb128 0x4	/* Location expression size */
+	.byte	0xa3	/* DW_OP_entry_value */
+	.uleb128 0x1
+	.byte	0x54	/* DW_OP_reg4 */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.byte	0	/* DW_LLE_end_of_list (*.LLST1) */
+.Ldebug_loc2:
+	.section	.debug_aranges,"",%progbits
+	.4byte	0x3c	/* Length of Address Ranges Info */
+	.2byte	0x2	/* DWARF Version */
+	.4byte	.Ldebug_info0	/* Offset of Compilation Unit Info */
+	.byte	0x8	/* Size of Address */
+	.byte	0	/* Size of Segment Descriptor */
+	.2byte	0	/* Pad to 16 byte boundary */
+	.2byte	0
+	.8byte	0x1234	/* Address */
+	.8byte	0x4567	/* Length */
+	.8byte	0x1234	/* Address */
+	.8byte	0x5678	/* Length */
+	.8byte	0
+	.8byte	0
+	.section	.debug_rnglists,"",%progbits
+.Ldebug_ranges0:
+	.4byte	.Ldebug_ranges3-.Ldebug_ranges2	/* Length of Range Lists */
+.Ldebug_ranges2:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.4byte	0	/* Offset Entry Count */
+.LLRL2:
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL2) */
+	.8byte	0x1234	/* Range begin address (*.LLRL2) */
+	.uleb128 .Letext0-.Ltext0	/* Range length (*.LLRL2) */
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL2) */
+	.8byte	0x1234	/* Range begin address (*.LLRL2) */
+	.uleb128 .LFE1-.LFB1	/* Range length (*.LLRL2) */
+	.byte	0	/* DW_RLE_end_of_list (*.LLRL2) */
+.Ldebug_ranges3:
+	.section	.debug_line,"",%progbits
+.Ldebug_line0:
+	.4byte	.LELT0-.LSLT0	/* Length of Source Line Info */
+.LSLT0:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.4byte	.LELTP0-.LASLTP0	/* Prolog Length */
+.LASLTP0:
+	.byte	0x1	/* Minimum Instruction Length */
+	.byte	0x1	/* Maximum Operations Per Instruction */
+	.byte	0x1	/* Default is_stmt_start flag */
+	.byte	0xf6	/* Line Base Value (Special Opcodes) */
+	.byte	0xf2	/* Line Range Value (Special Opcodes) */
+	.byte	0xd	/* Special Opcode Base */
+	.byte	0	/* opcode: 0x1 has 0 args */
+	.byte	0x1	/* opcode: 0x2 has 1 args */
+	.byte	0x1	/* opcode: 0x3 has 1 args */
+	.byte	0x1	/* opcode: 0x4 has 1 args */
+	.byte	0x1	/* opcode: 0x5 has 1 args */
+	.byte	0	/* opcode: 0x6 has 0 args */
+	.byte	0	/* opcode: 0x7 has 0 args */
+	.byte	0	/* opcode: 0x8 has 0 args */
+	.byte	0x1	/* opcode: 0x9 has 1 args */
+	.byte	0	/* opcode: 0xa has 0 args */
+	.byte	0	/* opcode: 0xb has 0 args */
+	.byte	0x1	/* opcode: 0xc has 1 args */
+	.byte	0x1	/* Directory entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x3	/* Directories count */
+	.4byte	.LASF1	/* Directory Entry: 0: "" */
+	.4byte	.LASF25	/* Directory Entry: 0: "" */
+	.4byte	.LASF26	/* Directory Entry: 0: "/usr/include" */
+	.byte	0x2	/* File name entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x2	/* DW_LNCT_directory_index */
+	.uleb128 0xb	/* DW_FORM_data1 */
+	.uleb128 0x4	/* File names count */
+	.4byte	.LASF0	/* File Entry: 0: "main.c" */
+	.byte	0
+	.4byte	.LASF27	/* File Entry: 0: "main.c" */
+	.byte	0x1
+	.4byte	.LASF28	/* File Entry: 0: "unistd.h" */
+	.byte	0x2
+	.4byte	.LASF29	/* File Entry: 0: "getopt.h" */
+	.byte	0x2
+.LELTP0:
+	.byte	0	/* set address *.LM3 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0x1c	/* line 6 */
+	.byte	0	/* set address *.LM4 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x12346
+	.byte	0x1	/* copy line 6 */
+	.byte	0	/* set address *.LFE1 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+	.byte	0	/* set address *.LM1 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0x1b	/* line 5 */
+	.byte	0	/* set address *.LM2 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0x1	/* copy line 5 */
+	.byte	0	/* set address *.Letext0 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+.LELT0:
+	.section	.debug_str,"MS",%progbits,1
+.LASF4:
+	.string	"unsigned int"
+.LASF15:
+	.string	"optopt"
+.LASF22:
+	.string	"main"
+.LASF6:
+	.string	"signed char"
+.LASF16:
+	.string	"xvar"
+.LASF5:
+	.string	"long unsigned int"
+.LASF14:
+	.string	"opterr"
+.LASF21:
+	.string	"GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2"
+.LASF2:
+	.string	"unsigned char"
+.LASF10:
+	.string	"char"
+.LASF13:
+	.string	"optind"
+.LASF8:
+	.string	"long int"
+.LASF19:
+	.string	"argc"
+.LASF3:
+	.string	"short unsigned int"
+.LASF17:
+	.string	"yvar"
+.LASF18:
+	.string	"pvar"
+.LASF11:
+	.string	"__environ"
+.LASF23:
+	.string	"func"
+.LASF12:
+	.string	"optarg"
+.LASF7:
+	.string	"short int"
+.LASF24:
+	.string	"alarm"
+.LASF9:
+	.string	"sizetype"
+.LASF20:
+	.string	"argv"
+	.section	.debug_line_str,"MS",%progbits,1
+.LASF1:
+	.string	""
+.LASF25:
+	.string	""
+.LASF29:
+	.string	"getopt.h"
+.LASF28:
+	.string	"unistd.h"
+.LASF0:
+	.string	"main.c"
+.LASF27:
+	.string	"main.c"
+.LASF26:
+	.string	"/usr/include"
+	.ident	"GCC: (GNU) 7.0.1 20170218 (experimental)"
+	.section	.note.GNU-stack,"",%progbits
--- /dev/null	2017-02-21 08:01:49.237033818 +0000
+++ binutils/testsuite/binutils-all/dw5.W	2017-02-20 17:30:32.275125132 +0000
@@ -0,0 +1,355 @@
+Contents of the .debug_info section:
+
+  Compilation Unit @ offset 0x0:
+   Length:        0x160 \(32-bit\)
+   Version:       5
+   Abbrev Offset: 0x0
+   Pointer Size:  8
+ <0><c>: Abbrev Number: 6 \(DW_TAG_compile_unit\)
+    <d>   DW_AT_producer    : \(indirect string, offset: 0x43\): GNU C11 7.0.1 20170218 \(experimental\) -mtune=generic -march=x86-64 -gdwarf-5 -O2
+    <11>   DW_AT_language    : 29	\(C11\)
+    <12>   DW_AT_name        : \(indirect line string, offset: 0x14\): main.c
+    <16>   DW_AT_comp_dir    : \(indirect line string, offset: 0x0\): 
+    <1a>   DW_AT_ranges      : 0xc
+    <1e>   DW_AT_low_pc      : 0x0
+    <26>   DW_AT_stmt_list   : 0x0
+ <1><2a>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <2b>   DW_AT_byte_size   : 1
+    <2c>   DW_AT_encoding    : 8	\(unsigned char\)
+    <2d>   DW_AT_name        : \(indirect string, offset: 0x94\): unsigned char
+ <1><31>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <32>   DW_AT_byte_size   : 2
+    <33>   DW_AT_encoding    : 7	\(unsigned\)
+    <34>   DW_AT_name        : \(indirect string, offset: 0xbc\): short unsigned int
+ <1><38>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <39>   DW_AT_byte_size   : 4
+    <3a>   DW_AT_encoding    : 7	\(unsigned\)
+    <3b>   DW_AT_name        : \(indirect string, offset: 0x0\): unsigned int
+ <1><3f>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <40>   DW_AT_byte_size   : 8
+    <41>   DW_AT_encoding    : 7	\(unsigned\)
+    <42>   DW_AT_name        : \(indirect string, offset: 0x2a\): long unsigned int
+ <1><46>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <47>   DW_AT_byte_size   : 1
+    <48>   DW_AT_encoding    : 6	\(signed char\)
+    <49>   DW_AT_name        : \(indirect string, offset: 0x19\): signed char
+ <1><4d>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <4e>   DW_AT_byte_size   : 2
+    <4f>   DW_AT_encoding    : 5	\(signed\)
+    <50>   DW_AT_name        : \(indirect string, offset: 0xef\): short int
+ <1><54>: Abbrev Number: 7 \(DW_TAG_base_type\)
+    <55>   DW_AT_byte_size   : 4
+    <56>   DW_AT_encoding    : 5	\(signed\)
+    <57>   DW_AT_name        : int
+ <1><5b>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <5c>   DW_AT_byte_size   : 8
+    <5d>   DW_AT_encoding    : 5	\(signed\)
+    <5e>   DW_AT_name        : \(indirect string, offset: 0xae\): long int
+ <1><62>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <63>   DW_AT_byte_size   : 8
+    <64>   DW_AT_encoding    : 7	\(unsigned\)
+    <65>   DW_AT_name        : \(indirect string, offset: 0xff\): sizetype
+ <1><69>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <6a>   DW_AT_byte_size   : 8
+    <6a>   DW_AT_type        : <0x6e>
+ <1><6e>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <6f>   DW_AT_byte_size   : 1
+    <70>   DW_AT_encoding    : 6	\(signed char\)
+    <71>   DW_AT_name        : \(indirect string, offset: 0xa2\): char
+ <1><75>: Abbrev Number: 8 \(DW_TAG_variable\)
+    <76>   DW_AT_name        : \(indirect string, offset: 0xd9\): __environ
+    <7a>   DW_AT_decl_file   : 2
+    <7b>   DW_AT_decl_line   : 546
+    <7d>   DW_AT_type        : <0x81>
+    <81>   DW_AT_external    : 1
+    <81>   DW_AT_declaration : 1
+ <1><81>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <82>   DW_AT_byte_size   : 8
+    <82>   DW_AT_type        : <0x69>
+ <1><86>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <87>   DW_AT_name        : \(indirect string, offset: 0xe8\): optarg
+    <8b>   DW_AT_decl_file   : 3
+    <8b>   DW_AT_decl_line   : 57
+    <8c>   DW_AT_type        : <0x69>
+    <90>   DW_AT_external    : 1
+    <90>   DW_AT_declaration : 1
+ <1><90>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <91>   DW_AT_name        : \(indirect string, offset: 0xa7\): optind
+    <95>   DW_AT_decl_file   : 3
+    <95>   DW_AT_decl_line   : 71
+    <96>   DW_AT_type        : <0x54>
+    <9a>   DW_AT_external    : 1
+    <9a>   DW_AT_declaration : 1
+ <1><9a>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <9b>   DW_AT_name        : \(indirect string, offset: 0x3c\): opterr
+    <9f>   DW_AT_decl_file   : 3
+    <9f>   DW_AT_decl_line   : 76
+    <a0>   DW_AT_type        : <0x54>
+    <a4>   DW_AT_external    : 1
+    <a4>   DW_AT_declaration : 1
+ <1><a4>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <a5>   DW_AT_name        : \(indirect string, offset: 0xd\): optopt
+    <a9>   DW_AT_decl_file   : 3
+    <a9>   DW_AT_decl_line   : 80
+    <aa>   DW_AT_type        : <0x54>
+    <ae>   DW_AT_external    : 1
+    <ae>   DW_AT_declaration : 1
+ <1><ae>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <af>   DW_AT_name        : \(indirect string, offset: 0x25\): xvar
+    <b3>   DW_AT_decl_file   : 1
+    <b3>   DW_AT_decl_line   : 2
+    <b4>   DW_AT_type        : <0x54>
+    <b8>   DW_AT_external    : 1
+    <b8>   DW_AT_location    : 9 byte block: 3 (0|34) (0|12) 0 0 0 0 (0|12) (0|34) 	\(DW_OP_addr: 1234\)
+ <1><c2>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <c3>   DW_AT_name        : \(indirect string, offset: 0xcf\): yvar
+    <c7>   DW_AT_decl_file   : 1
+    <c7>   DW_AT_decl_line   : 3
+    <c8>   DW_AT_type        : <0x54>
+    <cc>   DW_AT_external    : 1
+    <cc>   DW_AT_location    : 9 byte block: 3 (0|34) (0|12) 0 0 0 0 (0|12) (0|34) 	\(DW_OP_addr: 1234\)
+ <1><d6>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <d7>   DW_AT_name        : \(indirect string, offset: 0xd4\): pvar
+    <db>   DW_AT_decl_file   : 1
+    <db>   DW_AT_decl_line   : 4
+    <dc>   DW_AT_type        : <0xea>
+    <e0>   DW_AT_external    : 1
+    <e0>   DW_AT_location    : 9 byte block: 3 (0|34) (0|12) 0 0 0 0 (0|12) (0|34) 	\(DW_OP_addr: 1234\)
+ <1><ea>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <eb>   DW_AT_byte_size   : 8
+    <eb>   DW_AT_type        : <0x54>
+ <1><ef>: Abbrev Number: 9 \(DW_TAG_subprogram\)
+    <f0>   DW_AT_external    : 1
+    <f0>   DW_AT_name        : \(indirect string, offset: 0x14\): main
+    <f4>   DW_AT_decl_file   : 1
+    <f5>   DW_AT_decl_line   : 6
+    <f6>   DW_AT_prototyped  : 1
+    <f6>   DW_AT_type        : <0x54>
+    <fa>   DW_AT_low_pc      : 0x1234
+    <102>   DW_AT_high_pc     : 0x5678
+    <10a>   DW_AT_frame_base  : 1 byte block: 9c 	\(DW_OP_call_frame_cfa\)
+    <10c>   DW_AT_call_all_calls: 1
+    <10c>   DW_AT_sibling     : <0x13e>
+ <2><110>: Abbrev Number: 5 \(DW_TAG_formal_parameter\)
+    <111>   DW_AT_name        : \(indirect string, offset: 0xb7\): argc
+    <115>   DW_AT_decl_file   : 1
+    <115>   DW_AT_decl_line   : 6
+    <115>   DW_AT_type        : <0x54>
+    <119>   DW_AT_location    : 0xc \(location list\)
+ <2><11d>: Abbrev Number: 5 \(DW_TAG_formal_parameter\)
+    <11e>   DW_AT_name        : \(indirect string, offset: 0x108\): argv
+    <122>   DW_AT_decl_file   : 1
+    <122>   DW_AT_decl_line   : 6
+    <122>   DW_AT_type        : <0x81>
+    <126>   DW_AT_location    : 0x23 \(location list\)
+ <2><12a>: Abbrev Number: 10 \(DW_TAG_call_site\)
+    <12b>   DW_AT_call_return_pc: 0x12345
+    <133>   DW_AT_call_origin : <0x157>
+ <3><137>: Abbrev Number: 11 \(DW_TAG_call_site_parameter\)
+    <138>   DW_AT_location    : 1 byte block: 55 	\(DW_OP_reg5 \([^()]*\)\)
+    <13a>   DW_AT_call_value  : 1 byte block: 30 
+ <3><13c>: Abbrev Number: 0
+ <2><13d>: Abbrev Number: 0
+ <1><13e>: Abbrev Number: 12 \(DW_TAG_subprogram\)
+    <13f>   DW_AT_external    : 1
+    <13f>   DW_AT_name        : \(indirect string, offset: 0xe3\): func
+    <143>   DW_AT_decl_file   : 1
+    <144>   DW_AT_decl_line   : 5
+    <145>   DW_AT_prototyped  : 1
+    <145>   DW_AT_low_pc      : 0x1234
+    <14d>   DW_AT_high_pc     : 0x5678
+    <155>   DW_AT_frame_base  : 1 byte block: 9c 	\(DW_OP_call_frame_cfa\)
+    <157>   DW_AT_call_all_calls: 1
+ <1><157>: Abbrev Number: 13 \(DW_TAG_subprogram\)
+    <158>   DW_AT_external    : 1
+    <158>   DW_AT_declaration : 1
+    <158>   DW_AT_linkage_name: \(indirect string, offset: 0xf9\): alarm
+    <15c>   DW_AT_name        : \(indirect string, offset: 0xf9\): alarm
+    <160>   DW_AT_decl_file   : 2
+    <161>   DW_AT_decl_line   : 435
+ <1><163>: Abbrev Number: 0
+
+Contents of the .debug_abbrev section:
+
+  Number TAG \(0x0\)
+   1      DW_TAG_base_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_data1
+    DW_AT_encoding     DW_FORM_data1
+    DW_AT_name         DW_FORM_strp
+    DW_AT value: 0     DW_FORM value: 0
+   2      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 3
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   3      DW_TAG_pointer_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_implicit_const: 8
+    DW_AT_type         DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   4      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_location     DW_FORM_exprloc
+    DW_AT value: 0     DW_FORM value: 0
+   5      DW_TAG_formal_parameter    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 1
+    DW_AT_decl_line    DW_FORM_implicit_const: 6
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_location     DW_FORM_sec_offset
+    DW_AT value: 0     DW_FORM value: 0
+   6      DW_TAG_compile_unit    \[has children\]
+    DW_AT_producer     DW_FORM_strp
+    DW_AT_language     DW_FORM_data1
+    DW_AT_name         DW_FORM_line_strp
+    DW_AT_comp_dir     DW_FORM_line_strp
+    DW_AT_ranges       DW_FORM_sec_offset
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_stmt_list    DW_FORM_sec_offset
+    DW_AT value: 0     DW_FORM value: 0
+   7      DW_TAG_base_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_data1
+    DW_AT_encoding     DW_FORM_data1
+    DW_AT_name         DW_FORM_string
+    DW_AT value: 0     DW_FORM value: 0
+   8      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data2
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   9      DW_TAG_subprogram    \[has children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_prototyped   DW_FORM_flag_present
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_high_pc      DW_FORM_data8
+    DW_AT_frame_base   DW_FORM_exprloc
+    DW_AT_call_all_calls DW_FORM_flag_present
+    DW_AT_sibling      DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   10      DW_TAG_call_site    \[has children\]
+    DW_AT_call_return_pc DW_FORM_addr
+    DW_AT_call_origin  DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   11      DW_TAG_call_site_parameter    \[no children\]
+    DW_AT_location     DW_FORM_exprloc
+    DW_AT_call_value   DW_FORM_exprloc
+    DW_AT value: 0     DW_FORM value: 0
+   12      DW_TAG_subprogram    \[no children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_prototyped   DW_FORM_flag_present
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_high_pc      DW_FORM_data8
+    DW_AT_frame_base   DW_FORM_exprloc
+    DW_AT_call_all_calls DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   13      DW_TAG_subprogram    \[no children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT_linkage_name DW_FORM_strp
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data2
+    DW_AT value: 0     DW_FORM value: 0
+#...
+Contents of the .debug_loclists section:
+#...
+    Offset   Begin            End              Expression
+    0000000c 0000000000001234 \(base address\)
+    00000015 0000000000001234 0000000000001236 \(DW_OP_reg5 \([^()]*\)\)
+    0000001a 0000000000001236 0000000000001239 \(DW_OP_entry_value: \(DW_OP_reg5 \([^()]*\)\); DW_OP_stack_value\)
+    00000022 <End of list>
+    00000023 0000000000001234 \(base address\)
+    0000002c 0000000000001234 0000000000001236 \(DW_OP_reg4 \([^()]*\)\)
+    00000031 0000000000001236 0000000000001239 \(DW_OP_entry_value: \(DW_OP_reg4 \([^()]*\)\); DW_OP_stack_value\)
+    00000039 <End of list>
+
+Contents of the .debug_rnglists section:
+
+    Offset   Begin    End
+    0000000c 0000000000001234 0000000000001236 
+    00000016 0000000000001234 0000000000001239 
+    00000020 <End of list>
+
+Raw dump of debug contents of section .debug_line:
+
+  Offset:                      0x0
+  Length:                      144
+  DWARF Version:               5
+  Prologue Length:             60
+  Minimum Instruction Length:  1
+  Maximum Ops per Instruction: 1
+  Initial value of 'is_stmt':  1
+  Line Base:                   -10
+  Line Range:                  242
+  Opcode Base:                 13
+
+ Opcodes:
+  Opcode 1 has 0 args
+  Opcode 2 has 1 args
+  Opcode 3 has 1 args
+  Opcode 4 has 1 args
+  Opcode 5 has 1 args
+  Opcode 6 has 0 args
+  Opcode 7 has 0 args
+  Opcode 8 has 0 args
+  Opcode 9 has 1 args
+  Opcode 10 has 0 args
+  Opcode 11 has 0 args
+  Opcode 12 has 1 args
+
+ The Directory Table \(offset 0x22\):
+  Entry	Name
+  0	\(indirect line string, offset: 0x0\): 
+  1	\(indirect line string, offset: 0x1\): 
+  2	\(indirect line string, offset: 0x22\): /usr/include
+
+ The File name Table \(offset 0x34\):
+  Entry	Dir	Name
+  0	0	\(indirect line string, offset: 0x14\): main.c
+  1	1	\(indirect line string, offset: 0x1b\): main.c
+  2	2	\(indirect line string, offset: 0xb\): unistd.h
+  3	2	\(indirect line string, offset: 0x2\): getopt.h
+
+ Line Number Statements:
+  \[0x00000048\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000053\]  Special opcode 15: advance Address by 0 to 0x1234 and Line by 5 to 6
+  \[0x00000054\]  Extended opcode 2: set Address to 0x12346
+  \[0x0000005f\]  Copy
+  \[0x00000060\]  Extended opcode 2: set Address to 0x1234
+  \[0x0000006b\]  Extended opcode 1: End of Sequence
+
+  \[0x0000006e\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000079\]  Special opcode 14: advance Address by 0 to 0x1234 and Line by 4 to 5
+  \[0x0000007a\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000085\]  Copy
+  \[0x00000086\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000091\]  Extended opcode 1: End of Sequence
+
+
+Decoded dump of debug contents of section .debug_line:
+
+CU: ./main.c:
+File name                            Line number    Starting address
+main.c                                         6              0x1234
+main.c                                         6             0x12346
+
+main.c                                         5              0x1234
+main.c                                         5              0x1234
+
+

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/6] Display user op byte
  2017-02-15 22:58 ` [PATCH 2/6] Display user op byte Jan Kratochvil
@ 2017-02-22 11:30   ` Nick Clifton
  2017-02-22 19:24     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:30 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

> binutils/ChangeLog
> 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (decode_location_expression): Display also OP.

Approved - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 3/6] DWARF-5 basic functionality
  2017-02-15 22:58 ` [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-22 11:36   ` Nick Clifton
  2017-02-22 18:42     ` Jan Kratochvil
  2017-02-22 11:47   ` Nick Clifton
  1 sibling, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:36 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

> binutils/ChangeLog
> 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (fetch_indirect_line_string): New function.
> 	(abbrev_attr): New field implicit_const.
> 	(add_abbrev_attr): New parameter implicit_const.
> 	(process_abbrev_section): Support DW_FORM_implicit_const.
> 	(decode_location_expression): Support DW_OP_entry_value.
> 	(read_and_display_attr_value): Add parameter implicit_const.  Support
> 	DW_FORM_line_strp and DW_FORM_implicit_const.
> 	(read_and_display_attr): Add parameter implicit_const.
> 	(process_debug_info): Support line_str and DWARF-5.
> 	(read_debug_line_header): Support DWARF-5.
> 	(display_formatted_table): New function.
> 	(display_debug_lines_raw): New parameter file.  Support DWARF-5.
> 	(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
> 	(display_debug_lines): Pass file parameter.
> 	(display_debug_macro): Update read_and_display_attr_value caller.
> 	(display_debug_abbrev): Support DW_FORM_implicit_const.
> 	(display_loclists_list): New function.
> 	(display_loc_list): Support .debug_loclists.
> 	(display_debug_ranges_list): New function from display_debug_ranges.
> 	(display_debug_rnglists_list): New function.
> 	(display_debug_ranges): Support .debug_rnglists.
> 	(debug_displays): Add .debug_line_str, .debug_loclists and
> 	.debug_rnglists.
> 	* dwarf.h: Include dwarf2.h
> 	(DWARF2_Internal_LineInfo): Add li_offset_size.
> 	(DWARF2_Internal_CompUnit): Add cu_unit_type.
> 	(enum dwarf_section_display_enum): Add line_str.
> 	* readelf.c (process_section_headers): Add rnglists and loclists.

Approved - please apply.

Just a quick thought though:

>        if (compunit.cu_version != 2
>  	  && compunit.cu_version != 3
> -	  && compunit.cu_version != 4)
> +	  && compunit.cu_version != 4
> +	  && compunit.cu_version != 5)

There are going to be lots of these range checks in readelf now.  You might 
as well add a macro, eg IN_RANGE(LOW,HIGH), and use that to make the code
shorter.

Cheers
  Nick

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 3/6] DWARF-5 basic functionality
  2017-02-15 22:58 ` [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
  2017-02-22 11:36   ` Nick Clifton
@ 2017-02-22 11:47   ` Nick Clifton
  2017-02-22 19:13     ` [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
  2017-02-23 22:12     ` [commit] [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
  1 sibling, 2 replies; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:47 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

  Oops - I forgot - I found a bug in this patch whilst running your testcase:
 
> +static void
> +display_loclists_list (struct dwarf_section *section,
> +		       unsigned char **start_ptr,
> +		       unsigned int debug_info_entry,
> +		       unsigned long offset,
> +		       unsigned long base_address,
> +		       int has_frame_base)
> +{
 
> +	case DW_LLE_base_address:
> +	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size,
> +				 section_end);
> +	  print_dwarf_vma (base_address, pointer_size);
> +	  printf (_("(base address)\n"));
> +	  break;

The SAFE_BYTE_GET_AND_INC macro will trigger a runtime abort if this
code is compiled for a 32-bit host (where sizeof base_address == 4) and
run on DWARF5 information created for a 64-bit target (where 
pointer_size == 8).

I used a local patch which read the new base address into a bfd_vma 
variable and then assigned it to the real base_address afterwards, but
it occurred to me afterwards that this was wrong and that really the
base_address parameter should be a bfd_vma.  Probably offset should be
one too.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/6] DWARF attrs: add delimiter
  2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
                   ` (5 preceding siblings ...)
  2017-02-16 10:59 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
@ 2017-02-22 11:48 ` Nick Clifton
  2017-02-23 22:08   ` [commit] " Jan Kratochvil
  6 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:48 UTC (permalink / raw)
  To: binutils

Hi Jan,

> 2017-02-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (display_block): Add parameter delimiter.
> 	(decode_location_expression): Update display_block callers.
> 	(read_and_display_attr_value): Add parameter delimiter.
> 	(read_and_display_attr, display_debug_macro): Update
> 	read_and_display_attr_value caller.

Approved - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 4/6] DWARF-5: call sites
  2017-02-15 22:58 ` [PATCH 4/6] DWARF-5: call sites Jan Kratochvil
@ 2017-02-22 11:49   ` Nick Clifton
  2017-02-23 22:12     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:49 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

> binutils/ChangeLog
> 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer,
> 	DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert
> 	and DW_OP_reinterpret.
> 	(read_and_display_attr_value): Support DW_AT_call_value,
> 	DW_AT_call_data_value, DW_AT_call_target and
> 	DW_AT_call_target_clobbered.

Approved - please apply.

Cheers
  Nick

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 5/6] DWARF-5: Macros
  2017-02-15 22:58 ` [PATCH 5/6] DWARF-5: Macros Jan Kratochvil
@ 2017-02-22 11:50   ` Nick Clifton
  2017-02-23 22:13     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:50 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

> binutils/ChangeLog
> 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (display_debug_macro): Support DWARF-5.  Rename
> 	DW_MACRO_GNU_*.

Approved - please apply.

Cheers
  Nick

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 6/6] DWARF-5: DW_FORM_data16
  2017-02-15 22:58 ` [PATCH 6/6] DWARF-5: DW_FORM_data16 Jan Kratochvil
@ 2017-02-22 11:51   ` Nick Clifton
  2017-02-23 22:13     ` [commit] " Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-22 11:51 UTC (permalink / raw)
  To: Jan Kratochvil, binutils; +Cc: Victor Leschuk

Hi Jan,

> binutils/ChangeLog
> 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.

Approved - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 3/6] DWARF-5 basic functionality
  2017-02-22 11:36   ` Nick Clifton
@ 2017-02-22 18:42     ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-22 18:42 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

On Wed, 22 Feb 2017 12:36:18 +0100, Nick Clifton wrote:
> >        if (compunit.cu_version != 2
> >  	  && compunit.cu_version != 3
> > -	  && compunit.cu_version != 4)
> > +	  && compunit.cu_version != 4
> > +	  && compunit.cu_version != 5)
> 
> There are going to be lots of these range checks in readelf now.  You might 
> as well add a macro, eg IN_RANGE(LOW,HIGH), and use that to make the code
> shorter.

As you made it optional I have used:

-      if (compunit.cu_version != 2
-         && compunit.cu_version != 3
-         && compunit.cu_version != 4)
+      if (compunit.cu_version < 2 || compunit.cu_version > 5)


Thanks,
Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [patch] dwarf.c: Use more dwarf_vma  [Re: [PATCH 3/6] DWARF-5 basic functionality]
  2017-02-22 11:47   ` Nick Clifton
@ 2017-02-22 19:13     ` Jan Kratochvil
  2017-02-23 16:34       ` Nick Clifton
  2017-02-23 16:35       ` Nick Clifton
  2017-02-23 22:12     ` [commit] [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
  1 sibling, 2 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-22 19:13 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 502 bytes --]

Hi Nick,

On Wed, 22 Feb 2017 12:47:00 +0100, Nick Clifton wrote:
> I used a local patch which read the new base address into a bfd_vma 
> variable and then assigned it to the real base_address afterwards, but
> it occurred to me afterwards that this was wrong and that really the
> base_address parameter should be a bfd_vma.  Probably offset should be
> one too.

is this pre-requisite patch OK?  It does not solve printf of dwarf_vma on
32-bit archs but I do not see how to solve that easily.


Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 6062 bytes --]

binutils/
2017-02-22  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (display_loc_list): Use dwarf_vma for offset, base_address
	and off.
	(display_loc_list_dwo): Use dwarf_vma for offset.
	(display_debug_loc): Use dwarf_vma for offset, base_address.
	(struct range_entry, range_entry_compar): Use dwarf_vma for
	ranges_offset.
	(display_debug_ranges): Use dwarf_vma for ranges_offset, offset and
	base_address.

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 6d879c9b61..330f6b70b8 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -4409,8 +4409,8 @@ static void
 display_loc_list (struct dwarf_section *section,
 		  unsigned char **start_ptr,
 		  unsigned int debug_info_entry,
-		  unsigned long offset,
-		  unsigned long base_address,
+		  dwarf_vma offset,
+		  dwarf_vma base_address,
 		  int has_frame_base)
 {
   unsigned char *start = *start_ptr;
@@ -4446,16 +4446,16 @@ display_loc_list (struct dwarf_section *section,
 
   while (1)
     {
-      unsigned long off = offset + (start - *start_ptr);
+      dwarf_vma off = offset + (start - *start_ptr);
 
       if (start + 2 * pointer_size > section_end)
 	{
 	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		offset);
+		(unsigned long) offset);
 	  break;
 	}
 
-      printf ("    %8.8lx ", off);
+      printf ("    %8.8lx ", (unsigned long) off);
 
       SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);
       SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end);
@@ -4490,7 +4490,7 @@ display_loc_list (struct dwarf_section *section,
       if (start + 2 > section_end)
 	{
 	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		offset);
+		(unsigned long) offset);
 	  break;
 	}
 
@@ -4499,7 +4499,7 @@ display_loc_list (struct dwarf_section *section,
       if (start + length > section_end)
 	{
 	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		offset);
+		(unsigned long) offset);
 	  break;
 	}
 
@@ -4550,7 +4550,7 @@ static void
 display_loc_list_dwo (struct dwarf_section *section,
 		      unsigned char **start_ptr,
 		      unsigned int debug_info_entry,
-		      unsigned long offset,
+		      dwarf_vma offset,
 		      int has_frame_base)
 {
   unsigned char *start = *start_ptr;
@@ -4586,12 +4586,12 @@ display_loc_list_dwo (struct dwarf_section *section,
 
   while (1)
     {
-      printf ("    %8.8lx ", offset + (start - *start_ptr));
+      printf ("    %8.8lx ", (unsigned long) (offset + (start - *start_ptr)));
 
       if (start >= section_end)
 	{
 	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		offset);
+		(unsigned long) offset);
 	  break;
 	}
 
@@ -4639,7 +4639,7 @@ display_loc_list_dwo (struct dwarf_section *section,
       if (start + 2 > section_end)
 	{
 	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		offset);
+		(unsigned long) offset);
 	  break;
 	}
 
@@ -4647,7 +4647,7 @@ display_loc_list_dwo (struct dwarf_section *section,
       if (start + length > section_end)
 	{
 	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		offset);
+		(unsigned long) offset);
 	  break;
 	}
 
@@ -4777,8 +4777,8 @@ display_debug_loc (struct dwarf_section *section, void *file)
   seen_first_offset = 0;
   for (i = first; i < num_debug_info_entries; i++)
     {
-      unsigned long offset;
-      unsigned long base_address;
+      dwarf_vma offset;
+      dwarf_vma base_address;
       unsigned int k;
       int has_frame_base;
 
@@ -4822,7 +4822,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
 	  if (offset >= bytes)
 	    {
 	      warn (_("Offset 0x%lx is bigger than .debug_loc section size.\n"),
-		    offset);
+		    (unsigned long) offset);
 	      continue;
 	    }
 
@@ -5153,7 +5153,7 @@ display_debug_str_offsets (struct dwarf_section *section,
 struct range_entry
 {
   /* The debug_information[x].range_lists[y] value.  */
-  unsigned long ranges_offset;
+  dwarf_vma ranges_offset;
 
   /* Original debug_information to find parameters of the data.  */
   debug_info *debug_info_p;
@@ -5166,8 +5166,8 @@ range_entry_compar (const void *ap, const void *bp)
 {
   const struct range_entry *a_re = (const struct range_entry *) ap;
   const struct range_entry *b_re = (const struct range_entry *) bp;
-  const unsigned long a = a_re->ranges_offset;
-  const unsigned long b = b_re->ranges_offset;
+  const dwarf_vma a = a_re->ranges_offset;
+  const dwarf_vma b = b_re->ranges_offset;
 
   return (a > b) - (b > a);
 }
@@ -5231,7 +5231,7 @@ display_debug_ranges (struct dwarf_section *section,
 
   if (dwarf_check != 0 && range_entries[0].ranges_offset != 0)
     warn (_("Range lists in %s section start at 0x%lx\n"),
-	  section->name, range_entries[0].ranges_offset);
+	  section->name, (unsigned long) range_entries[0].ranges_offset);
 
   printf (_("Contents of the %s section:\n\n"), section->name);
   printf (_("    Offset   Begin    End\n"));
@@ -5241,9 +5241,9 @@ display_debug_ranges (struct dwarf_section *section,
       struct range_entry *range_entry = &range_entries[i];
       debug_info *debug_info_p = range_entry->debug_info_p;
       unsigned int pointer_size;
-      unsigned long offset;
+      dwarf_vma offset;
       unsigned char *next;
-      unsigned long base_address;
+      dwarf_vma base_address;
 
       pointer_size = debug_info_p->pointer_size;
       offset = range_entry->ranges_offset;
@@ -5254,7 +5254,7 @@ display_debug_ranges (struct dwarf_section *section,
       if (pointer_size < 2 || pointer_size > 8)
 	{
 	  warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
-		pointer_size, offset);
+		pointer_size, (unsigned long) offset);
 	  continue;
 	}
 
@@ -5286,7 +5286,7 @@ display_debug_ranges (struct dwarf_section *section,
 	    break;
 	  SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
 
-	  printf ("    %8.8lx ", offset);
+	  printf ("    %8.8lx ", (unsigned long) offset);
 
 	  if (begin == 0 && end == 0)
 	    {

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [PATCH 2/6] Display user op byte
  2017-02-22 11:30   ` Nick Clifton
@ 2017-02-22 19:24     ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-22 19:24 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

On Wed, 22 Feb 2017 12:30:19 +0100, Nick Clifton wrote:
> > binutils/ChangeLog
> > 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* dwarf.c (decode_location_expression): Display also OP.
> 
> Approved - please apply.

0502a2b49c5a5c1f6de203c08e4d45509cd6a9fa


Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality]
  2017-02-22 19:13     ` [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
@ 2017-02-23 16:34       ` Nick Clifton
  2017-02-23 16:35       ` Nick Clifton
  1 sibling, 0 replies; 32+ messages in thread
From: Nick Clifton @ 2017-02-23 16:34 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: binutils, Victor Leschuk

Hi Jan,

> is this pre-requisite patch OK?  It does not solve printf of dwarf_vma on
> 32-bit archs but I do not see how to solve that easily.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality]
  2017-02-22 19:13     ` [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
  2017-02-23 16:34       ` Nick Clifton
@ 2017-02-23 16:35       ` Nick Clifton
  2017-02-23 20:38         ` [commit] " Jan Kratochvil
  1 sibling, 1 reply; 32+ messages in thread
From: Nick Clifton @ 2017-02-23 16:35 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: binutils, Victor Leschuk

Hi Jan,

> is this pre-requisite patch OK?  It does not solve printf of dwarf_vma on
> 32-bit archs but I do not see how to solve that easily.

[aargh - hit send by mistake]

  Fair enough - the patch is OK - please apply.

Cheers
  Nick


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality]
  2017-02-23 16:35       ` Nick Clifton
@ 2017-02-23 20:38         ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 20:38 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

Hi Nick,

On Thu, 23 Feb 2017 17:35:22 +0100, Nick Clifton wrote:
>   Fair enough - the patch is OK - please apply.

359ca075e7fe20a5106d5c068193dad0c53af480


Thanks,
Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [PATCH 1/6] DWARF attrs: add delimiter
  2017-02-22 11:48 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
@ 2017-02-23 22:08   ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 22:08 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hi Nick,

On Wed, 22 Feb 2017 12:47:55 +0100, Nick Clifton wrote:
> > 2017-02-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* dwarf.c (display_block): Add parameter delimiter.
> > 	(decode_location_expression): Update display_block callers.
> > 	(read_and_display_attr_value): Add parameter delimiter.
> > 	(read_and_display_attr, display_debug_macro): Update
> > 	read_and_display_attr_value caller.
> 
> Approved - please apply.

ef0b5f1c694601782db9aa90cf0ed7f3f3513c53


Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [PATCH 3/6] DWARF-5 basic functionality
  2017-02-22 11:47   ` Nick Clifton
  2017-02-22 19:13     ` [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
@ 2017-02-23 22:12     ` Jan Kratochvil
  2017-02-27 21:58       ` Maciej W. Rozycki
  1 sibling, 1 reply; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 22:12 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

Hi Nick,

On Wed, 22 Feb 2017 12:47:00 +0100, Nick Clifton wrote:
> The SAFE_BYTE_GET_AND_INC macro will trigger a runtime abort if this
> code is compiled for a 32-bit host (where sizeof base_address == 4) and
> run on DWARF5 information created for a 64-bit target (where 
> pointer_size == 8).

So this is now fixed by checked-in:
	[patch] dwarf.c: Use more dwarf_vma

Checked in as: 77145576fadc4dd2879adf5242b610ebbe30ec30

Fixed there one bug - DWARF-5 DW_UT_type CU did force DW_UT_type (and not
DW_UT_compile) decoding for all the following CUs:
+         if (compunit.cu_unit_type == DW_UT_type)
+           do_types = 1;
->
+         do_types = (compunit.cu_unit_type == DW_UT_type);


Jan

[-- Attachment #2: Type: message/rfc822, Size: 54925 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH 1/5] DWARF-5 basic functionality
Date: Thu, 23 Feb 2017 22:54:01 +0100

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf.c (fetch_indirect_line_string): New function.
	(abbrev_attr): New field implicit_const.
	(add_abbrev_attr): New parameter implicit_const.
	(process_abbrev_section): Support DW_FORM_implicit_const.
	(decode_location_expression): Support DW_OP_entry_value.
	(read_and_display_attr_value): Add parameter implicit_const.  Support
	DW_FORM_line_strp and DW_FORM_implicit_const.
	(read_and_display_attr): Add parameter implicit_const.
	(process_debug_info): Support line_str and DWARF-5.
	(read_debug_line_header): Support DWARF-5.
	(display_formatted_table): New function.
	(display_debug_lines_raw): New parameter file.  Support DWARF-5.
	(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
	(display_debug_lines): Pass file parameter.
	(display_debug_macro): Update read_and_display_attr_value caller.
	(display_debug_abbrev): Support DW_FORM_implicit_const.
	(display_loclists_list): New function.
	(display_loc_list): Support .debug_loclists.
	(display_debug_ranges_list): New function from display_debug_ranges.
	(display_debug_rnglists_list): New function.
	(display_debug_ranges): Support .debug_rnglists.
	(debug_displays): Add .debug_line_str, .debug_loclists and
	.debug_rnglists.
	* dwarf.h: Include dwarf2.h
	(DWARF2_Internal_LineInfo): Add li_offset_size.
	(DWARF2_Internal_CompUnit): Add cu_unit_type.
	(enum dwarf_section_display_enum): Add line_str.
	* readelf.c (process_section_headers): Add rnglists and loclists.
---
 binutils/ChangeLog |   31 ++
 binutils/dwarf.c   | 1160 +++++++++++++++++++++++++++++++++++++++++++---------
 binutils/dwarf.h   |    5 +
 binutils/readelf.c |    2 +
 4 files changed, 994 insertions(+), 204 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 11464e5..c39385c 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,36 @@
 2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	* dwarf.c (fetch_indirect_line_string): New function.
+	(abbrev_attr): New field implicit_const.
+	(add_abbrev_attr): New parameter implicit_const.
+	(process_abbrev_section): Support DW_FORM_implicit_const.
+	(decode_location_expression): Support DW_OP_entry_value.
+	(read_and_display_attr_value): Add parameter implicit_const.  Support
+	DW_FORM_line_strp and DW_FORM_implicit_const.
+	(read_and_display_attr): Add parameter implicit_const.
+	(process_debug_info): Support line_str and DWARF-5.
+	(read_debug_line_header): Support DWARF-5.
+	(display_formatted_table): New function.
+	(display_debug_lines_raw): New parameter file.  Support DWARF-5.
+	(display_debug_lines_decoded): New parameter fileptr.  Support DWARF-5.
+	(display_debug_lines): Pass file parameter.
+	(display_debug_macro): Update read_and_display_attr_value caller.
+	(display_debug_abbrev): Support DW_FORM_implicit_const.
+	(display_loclists_list): New function.
+	(display_loc_list): Support .debug_loclists.
+	(display_debug_ranges_list): New function from display_debug_ranges.
+	(display_debug_rnglists_list): New function.
+	(display_debug_ranges): Support .debug_rnglists.
+	(debug_displays): Add .debug_line_str, .debug_loclists and
+	.debug_rnglists.
+	* dwarf.h: Include dwarf2.h
+	(DWARF2_Internal_LineInfo): Add li_offset_size.
+	(DWARF2_Internal_CompUnit): Add cu_unit_type.
+	(enum dwarf_section_display_enum): Add line_str.
+	* readelf.c (process_section_headers): Add rnglists and loclists.
+
+2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* dwarf.c (display_block): Add parameter delimiter.
 	(decode_location_expression): Update display_block callers.
 	(read_and_display_attr_value): Add parameter delimiter.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index d27313f..420ae5d 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -611,6 +611,24 @@ fetch_indirect_string (dwarf_vma offset)
   return (const unsigned char *) section->start + offset;
 }
 
+static const unsigned char *
+fetch_indirect_line_string (dwarf_vma offset)
+{
+  struct dwarf_section *section = &debug_displays [line_str].section;
+
+  if (section->start == NULL)
+    return (const unsigned char *) _("<no .debug_line_str section>");
+
+  if (offset > section->size)
+    {
+      warn (_("DW_FORM_line_strp offset too big: %s\n"),
+	    dwarf_vmatoa ("x", offset));
+      return (const unsigned char *) _("<offset is too big>");
+    }
+
+  return (const unsigned char *) section->start + offset;
+}
+
 static const char *
 fetch_indexed_string (dwarf_vma idx, struct cu_tu_set *this_set,
 		      dwarf_vma offset_size, int dwo)
@@ -677,6 +695,7 @@ typedef struct abbrev_attr
 {
   unsigned long attribute;
   unsigned long form;
+  bfd_signed_vma implicit_const;
   struct abbrev_attr *next;
 }
 abbrev_attr;
@@ -746,7 +765,8 @@ add_abbrev (unsigned long number, unsigned long tag, int children)
 }
 
 static void
-add_abbrev_attr (unsigned long attribute, unsigned long form)
+add_abbrev_attr (unsigned long attribute, unsigned long form,
+		 bfd_signed_vma implicit_const)
 {
   abbrev_attr *attr;
 
@@ -757,6 +777,7 @@ add_abbrev_attr (unsigned long attribute, unsigned long form)
 
   attr->attribute = attribute;
   attr->form      = form;
+  attr->implicit_const = implicit_const;
   attr->next      = NULL;
 
   if (last_abbrev->first_attr == NULL)
@@ -809,6 +830,8 @@ process_abbrev_section (unsigned char *start, unsigned char *end)
       do
 	{
 	  unsigned long form;
+	  /* Initialize it due to a false compiler warning.  */
+	  bfd_signed_vma implicit_const = -1;
 
 	  attribute = read_uleb128 (start, & bytes_read, end);
 	  start += bytes_read;
@@ -820,7 +843,15 @@ process_abbrev_section (unsigned char *start, unsigned char *end)
 	  if (start == end)
 	    break;
 
-	  add_abbrev_attr (attribute, form);
+	  if (form == DW_FORM_implicit_const)
+	    {
+	      implicit_const = read_sleb128 (start, & bytes_read, end);
+	      start += bytes_read;
+	      if (start == end)
+		break;
+	    }
+
+	  add_abbrev_attr (attribute, form, implicit_const);
 	}
       while (attribute != 0);
     }
@@ -1314,13 +1345,15 @@ decode_location_expression (unsigned char * data,
 						   &bytes_read, end)));
 	  data += bytes_read;
 	  break;
+	case DW_OP_entry_value:
 	case DW_OP_GNU_entry_value:
 	  uvalue = read_uleb128 (data, &bytes_read, end);
 	  data += bytes_read;
 	  /* PR 17531: file: 0cc9cd00.  */
 	  if (uvalue > (dwarf_vma) (end - data))
 	    uvalue = end - data;
-	  printf ("DW_OP_GNU_entry_value: (");
+	  printf ("%s: (", (op == DW_OP_entry_value ? "DW_OP_entry_value"
+						    : "DW_OP_GNU_entry_value"));
 	  if (decode_location_expression (data, pointer_size, offset_size,
 					  dwarf_version, uvalue,
 					  cu_offset, section))
@@ -1498,6 +1531,7 @@ add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc)
 static unsigned char *
 read_and_display_attr_value (unsigned long attribute,
 			     unsigned long form,
+			     dwarf_signed_vma implicit_const,
 			     unsigned char * data,
 			     unsigned char * end,
 			     dwarf_vma cu_offset,
@@ -1540,6 +1574,7 @@ read_and_display_attr_value (unsigned long attribute,
       break;
 
     case DW_FORM_strp:
+    case DW_FORM_line_strp:
     case DW_FORM_sec_offset:
     case DW_FORM_GNU_ref_alt:
     case DW_FORM_GNU_strp_alt:
@@ -1587,8 +1622,13 @@ read_and_display_attr_value (unsigned long attribute,
       data += bytes_read;
       if (!do_loc)
 	printf ("%c%s", delimiter, get_FORM_name (form));
-      return read_and_display_attr_value (attribute, form, data, end,
-					  cu_offset, pointer_size,
+      if (form == DW_FORM_implicit_const)
+	{
+	  implicit_const = read_sleb128 (data, & bytes_read, end);
+	  data += bytes_read;
+	}
+      return read_and_display_attr_value (attribute, form, implicit_const, data,
+					  end, cu_offset, pointer_size,
 					  offset_size, dwarf_version,
 					  debug_info_p, do_loc,
 					  section, this_set, delimiter);
@@ -1635,6 +1675,11 @@ read_and_display_attr_value (unsigned long attribute,
 	printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue));
       break;
 
+    case DW_FORM_implicit_const:
+      if (!do_loc)
+	printf ("%c%s", delimiter, dwarf_vmatoa ("d", implicit_const));
+      break;
+
     case DW_FORM_ref8:
     case DW_FORM_data8:
       if (!do_loc)
@@ -1768,6 +1813,13 @@ read_and_display_attr_value (unsigned long attribute,
 		fetch_indirect_string (uvalue));
       break;
 
+    case DW_FORM_line_strp:
+      if (!do_loc)
+	printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter,
+		dwarf_vmatoa ("x", uvalue),
+		fetch_indirect_line_string (uvalue));
+      break;
+
     case DW_FORM_GNU_str_index:
       if (!do_loc)
 	{
@@ -2216,6 +2268,7 @@ get_AT_name (unsigned long attribute)
 static unsigned char *
 read_and_display_attr (unsigned long attribute,
 		       unsigned long form,
+		       dwarf_signed_vma implicit_const,
 		       unsigned char * data,
 		       unsigned char * end,
 		       dwarf_vma cu_offset,
@@ -2229,7 +2282,7 @@ read_and_display_attr (unsigned long attribute,
 {
   if (!do_loc)
     printf ("   %-18s:", get_AT_name (attribute));
-  data = read_and_display_attr_value (attribute, form, data, end,
+  data = read_and_display_attr_value (attribute, form, implicit_const, data, end,
 				      cu_offset, pointer_size, offset_size,
 				      dwarf_version, debug_info_p,
 				      do_loc, section, this_set, ' ');
@@ -2328,6 +2381,7 @@ process_debug_info (struct dwarf_section *section,
 	printf (_("Contents of the %s section:\n\n"), section->name);
 
       load_debug_section (str, file);
+      load_debug_section (line_str, file);
       load_debug_section (str_dwo, file);
       load_debug_section (str_index, file);
       load_debug_section (str_index_dwo, file);
@@ -2380,6 +2434,20 @@ process_debug_info (struct dwarf_section *section,
 
       this_set = find_cu_tu_set_v2 (cu_offset, do_types);
 
+      if (compunit.cu_version < 5)
+	{
+	  compunit.cu_unit_type = DW_UT_compile;
+	  /* Initialize it due to a false compiler warning.  */
+	  compunit.cu_pointer_size = -1;
+	}
+      else
+	{
+	  SAFE_BYTE_GET_AND_INC (compunit.cu_unit_type, hdrptr, 1, end);
+	  do_types = (compunit.cu_unit_type == DW_UT_type);
+
+	  SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
+	}
+
       SAFE_BYTE_GET_AND_INC (compunit.cu_abbrev_offset, hdrptr, offset_size, end);
 
       if (this_set == NULL)
@@ -2393,7 +2461,9 @@ process_debug_info (struct dwarf_section *section,
 	  abbrev_size = this_set->section_sizes [DW_SECT_ABBREV];
 	}
 
-      SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
+      if (compunit.cu_version < 5)
+	SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
+
       /* PR 17512: file: 001-108546-0.001:0.1.  */
       if (compunit.cu_pointer_size < 2 || compunit.cu_pointer_size > 8)
 	{
@@ -2492,9 +2562,7 @@ process_debug_info (struct dwarf_section *section,
 	  start = end;
 	}
 
-      if (compunit.cu_version != 2
-	  && compunit.cu_version != 3
-	  && compunit.cu_version != 4)
+      if (compunit.cu_version < 2 || compunit.cu_version > 5)
 	{
 	  warn (_("CU at offset %s contains corrupt or "
 		  "unsupported version number: %d.\n"),
@@ -2502,6 +2570,15 @@ process_debug_info (struct dwarf_section *section,
 	  continue;
 	}
 
+      if (compunit.cu_unit_type != DW_UT_compile
+	  && compunit.cu_unit_type != DW_UT_type)
+	{
+	  warn (_("CU at offset %s contains corrupt or "
+		  "unsupported unit type: %d.\n"),
+		dwarf_vmatoa ("x", cu_offset), compunit.cu_unit_type);
+	  continue;
+	}
+
       free_abbrevs ();
 
       /* Process the abbrevs used by this compilation unit.  */
@@ -2655,6 +2732,7 @@ process_debug_info (struct dwarf_section *section,
 
 	      tags = read_and_display_attr (attr->attribute,
 					    attr->form,
+					    attr->implicit_const,
 					    tags,
 					    end,
 					    cu_offset,
@@ -2742,8 +2820,8 @@ read_debug_line_header (struct dwarf_section * section,
 			unsigned char ** end_of_sequence)
 {
   unsigned char *hdrptr;
-  unsigned int offset_size;
   unsigned int initial_length_size;
+  unsigned char address_size, segment_selector_size;
 
   /* Extract information from the Line Number Program Header.
      (section 6.2.4 in the Dwarf3 doc).  */
@@ -2756,12 +2834,12 @@ read_debug_line_header (struct dwarf_section * section,
     {
       /* This section is 64-bit DWARF 3.  */
       SAFE_BYTE_GET_AND_INC (linfo->li_length, hdrptr, 8, end);
-      offset_size = 8;
+      linfo->li_offset_size = 8;
       initial_length_size = 12;
     }
   else
     {
-      offset_size = 4;
+      linfo->li_offset_size = 4;
       initial_length_size = 4;
     }
 
@@ -2773,7 +2851,7 @@ read_debug_line_header (struct dwarf_section * section,
 	 comprised of several different .debug_line.* sections, (some of
 	 which may be removed by linker garbage collection), and a relocation
 	 is used to compute the correct length once that is done.  */
-      if (reloc_at (section, (hdrptr - section->start) - offset_size))
+      if (reloc_at (section, (hdrptr - section->start) - linfo->li_offset_size))
 	{
 	  linfo->li_length = (end - data) - initial_length_size;
 	}
@@ -2790,13 +2868,30 @@ read_debug_line_header (struct dwarf_section * section,
 
   if (linfo->li_version != 2
       && linfo->li_version != 3
-      && linfo->li_version != 4)
+      && linfo->li_version != 4
+      && linfo->li_version != 5)
     {
-      warn (_("Only DWARF version 2, 3 and 4 line info is currently supported.\n"));
+      warn (_("Only DWARF version 2, 3, 4 and 5 line info "
+	      "is currently supported.\n"));
       return NULL;
     }
 
-  SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr, offset_size, end);
+  if (linfo->li_version >= 5)
+    {
+      SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end);
+
+      SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end);
+      if (segment_selector_size != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported segment selector size: %d.\n"),
+		section->name, segment_selector_size);
+	  return 0;
+	}
+    }
+
+  SAFE_BYTE_GET_AND_INC (linfo->li_prologue_length, hdrptr,
+			 linfo->li_offset_size, end);
   SAFE_BYTE_GET_AND_INC (linfo->li_min_insn_length, hdrptr, 1, end);
 
   if (linfo->li_version >= 4)
@@ -2830,10 +2925,126 @@ read_debug_line_header (struct dwarf_section * section,
   return hdrptr;
 }
 
+static unsigned char *
+display_formatted_table (unsigned char *data,
+			 unsigned char *start, unsigned char *end,
+			 const DWARF2_Internal_LineInfo *linfo,
+			 struct dwarf_section *section, const char *what)
+{
+  unsigned char *format_start, format_count, *format, formati;
+  dwarf_vma data_count, datai;
+  unsigned int bytes_read, namepass, last_entry = 0;
+
+  SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
+  format_start = data;
+  for (formati = 0; formati < format_count; formati++)
+    {
+      read_uleb128 (data, & bytes_read, end);
+      data += bytes_read;
+      read_uleb128 (data, & bytes_read, end);
+      data += bytes_read;
+      if (data == end)
+	{
+	  warn (_("Corrupt %s entry format table entry\n"), what);
+	  return data;
+	}
+    }
+
+  data_count = read_uleb128 (data, & bytes_read, end);
+  data += bytes_read;
+  if (data == end)
+    {
+      warn (_("Corrupt %s list\n"), what);
+      return data;
+    }
+
+  if (data_count == 0)
+    {
+      printf (_("\n The %s Table is empty.\n"), what);
+      return data;
+    }
+
+  printf (_("\n The %s Table (offset 0x%lx):\n"), what,
+	  (long)(data - start));
+
+  printf (_("  Entry"));
+  /* Delay displaying name as the last entry for better screen layout.  */ 
+  for (namepass = 0; namepass < 2; namepass++)
+    {
+      format = format_start;
+      for (formati = 0; formati < format_count; formati++)
+	{
+	  dwarf_vma content_type;
+
+	  content_type = read_uleb128 (format, & bytes_read, end);
+	  format += bytes_read;
+	  if ((content_type == DW_LNCT_path) == (namepass == 1))
+	    switch (content_type)
+	      {
+	      case DW_LNCT_path:
+		printf (_("\tName"));
+		break;
+	      case DW_LNCT_directory_index:
+		printf (_("\tDir"));
+		break;
+	      case DW_LNCT_timestamp:
+		printf (_("\tTime"));
+		break;
+	      case DW_LNCT_size:
+		printf (_("\tSize"));
+		break;
+	      case DW_LNCT_MD5:
+		printf (_("\tMD5"));
+		break;
+	      default:
+		printf (_("\t(Unknown format content type %s)"),
+			dwarf_vmatoa ("u", content_type));
+	      }
+	  read_uleb128 (format, & bytes_read, end);
+	  format += bytes_read;
+	}
+    }
+  putchar ('\n');
+
+  for (datai = 0; datai < data_count; datai++)
+    {
+      unsigned char *datapass = data;
+
+      printf ("  %d", last_entry++);
+      /* Delay displaying name as the last entry for better screen layout.  */ 
+      for (namepass = 0; namepass < 2; namepass++)
+	{
+	  format = format_start;
+	  data = datapass;
+	  for (formati = 0; formati < format_count; formati++)
+	    {
+	      dwarf_vma content_type, form;
+
+	      content_type = read_uleb128 (format, & bytes_read, end);
+	      format += bytes_read;
+	      form = read_uleb128 (format, & bytes_read, end);
+	      format += bytes_read;
+	      data = read_and_display_attr_value (0, form, 0, data, end, 0, 0,
+						  linfo->li_offset_size,
+						  linfo->li_version, NULL,
+			    ((content_type == DW_LNCT_path) != (namepass == 1)),
+						  section, NULL, '\t');
+	    }
+	}
+      if (data == end)
+	{
+	  warn (_("Corrupt %s entries list\n"), what);
+	  return data;
+	}
+      putchar ('\n');
+    }
+  return data;
+}
+
 static int
 display_debug_lines_raw (struct dwarf_section *section,
 			 unsigned char *data,
-			 unsigned char *end)
+			 unsigned char *end, void *file)
 {
   unsigned char *start = section->start;
 
@@ -2846,7 +3057,6 @@ display_debug_lines_raw (struct dwarf_section *section,
       DWARF2_Internal_LineInfo linfo;
       unsigned char *standard_opcodes;
       unsigned char *end_of_sequence;
-      unsigned int last_dir_entry = 0;
       int i;
 
       if (const_strneq (section->name, ".debug_line.")
@@ -2922,67 +3132,82 @@ display_debug_lines_raw (struct dwarf_section *section,
 	  /* Display the contents of the Directory table.  */
 	  data = standard_opcodes + linfo.li_opcode_base - 1;
 
-	  if (*data == 0)
-	    printf (_("\n The Directory Table is empty.\n"));
-	  else
+	  if (linfo.li_version >= 5)
 	    {
-	      printf (_("\n The Directory Table (offset 0x%lx):\n"),
-		      (long)(data - start));
+	      load_debug_section (line_str, file);
 
-	      while (data < end && *data != 0)
+	      data = display_formatted_table (data, start, end, &linfo, section,
+					      _("Directory"));
+	      data = display_formatted_table (data, start, end, &linfo, section,
+					      _("File name"));
+	    }
+	  else
+	    {
+	      if (*data == 0)
+		printf (_("\n The Directory Table is empty.\n"));
+	      else
 		{
-		  printf ("  %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data);
-
-		  data += strnlen ((char *) data, end - data) + 1;
-		}
+		  unsigned int last_dir_entry = 0;
 
-	      /* PR 17512: file: 002-132094-0.004.  */
-	      if (data >= end - 1)
-		break;
-	    }
+		  printf (_("\n The Directory Table (offset 0x%lx):\n"),
+			  (long)(data - start));
 
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
+		  while (data < end && *data != 0)
+		    {
+		      printf ("  %d\t%.*s\n", ++last_dir_entry, (int) (end - data), data);
 
-	  /* Display the contents of the File Name table.  */
-	  if (*data == 0)
-	    printf (_("\n The File Name Table is empty.\n"));
-	  else
-	    {
-	      printf (_("\n The File Name Table (offset 0x%lx):\n"),
-		      (long)(data - start));
-	      printf (_("  Entry\tDir\tTime\tSize\tName\n"));
+		      data += strnlen ((char *) data, end - data) + 1;
+		    }
 
-	      while (data < end && *data != 0)
-		{
-		  unsigned char *name;
-		  unsigned int bytes_read;
+		  /* PR 17512: file: 002-132094-0.004.  */
+		  if (data >= end - 1)
+		    break;
+		}
 
-		  printf ("  %d\t", ++state_machine_regs.last_file_entry);
-		  name = data;
-		  data += strnlen ((char *) data, end - data) + 1;
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
 
-		  printf ("%s\t",
-			  dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
-		  data += bytes_read;
-		  printf ("%s\t",
-			  dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
-		  data += bytes_read;
-		  printf ("%s\t",
-			  dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
-		  data += bytes_read;
-		  printf ("%.*s\n", (int)(end - name), name);
+	      /* Display the contents of the File Name table.  */
+	      if (*data == 0)
+		printf (_("\n The File Name Table is empty.\n"));
+	      else
+		{
+		  printf (_("\n The File Name Table (offset 0x%lx):\n"),
+			  (long)(data - start));
+		  printf (_("  Entry\tDir\tTime\tSize\tName\n"));
 
-		  if (data == end)
+		  while (data < end && *data != 0)
 		    {
-		      warn (_("Corrupt file name table entry\n"));
-		      break;
+		      unsigned char *name;
+		      unsigned int bytes_read;
+
+		      printf ("  %d\t", ++state_machine_regs.last_file_entry);
+		      name = data;
+		      data += strnlen ((char *) data, end - data) + 1;
+
+		      printf ("%s\t",
+			      dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
+		      data += bytes_read;
+		      printf ("%s\t",
+			      dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
+		      data += bytes_read;
+		      printf ("%s\t",
+			      dwarf_vmatoa ("u", read_uleb128 (data, & bytes_read, end)));
+		      data += bytes_read;
+		      printf ("%.*s\n", (int)(end - name), name);
+
+		      if (data == end)
+			{
+			  warn (_("Corrupt file name table entry\n"));
+			  break;
+			}
 		    }
 		}
+
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
 	    }
 
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
 	  putchar ('\n');
 	  saved_linfo = linfo;
 	}
@@ -3196,7 +3421,7 @@ typedef struct
 static int
 display_debug_lines_decoded (struct dwarf_section *section,
 			     unsigned char *data,
-			     unsigned char *end)
+			     unsigned char *end, void *fileptr)
 {
   static DWARF2_Internal_LineInfo saved_linfo;
 
@@ -3213,7 +3438,7 @@ display_debug_lines_decoded (struct dwarf_section *section,
       File_Entry *file_table = NULL;
       unsigned int n_files = 0;
       unsigned char **directory_table = NULL;
-      unsigned int n_directories = 0;
+      dwarf_vma n_directories = 0;
 
       if (const_strneq (section->name, ".debug_line.")
 	  /* Note: the following does not apply to .debug_line.dwo sections.
@@ -3261,129 +3486,304 @@ display_debug_lines_decoded (struct dwarf_section *section,
 	      return 0;
 	    }
 
-	  if (*data != 0)
+	  if (linfo.li_version >= 5)
 	    {
-	      unsigned char *ptr_directory_table = data;
+	      unsigned char *format_start, format_count, *format;
+	      dwarf_vma formati, entryi;
+	      unsigned int bytes_read;
 
-	      while (data < end && *data != 0)
+	      load_debug_section (line_str, fileptr);
+
+	      /* Skip directories format.  */
+	      SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
+	      format_start = data;
+	      for (formati = 0; formati < format_count; formati++)
 		{
-		  data += strnlen ((char *) data, end - data) + 1;
-		  n_directories++;
+		  read_uleb128 (data, & bytes_read, end);
+		  data += bytes_read;
+		  read_uleb128 (data, & bytes_read, end);
+		  data += bytes_read;
 		}
 
-	      /* PR 20440 */
-	      if (data >= end)
+	      n_directories = read_uleb128 (data, & bytes_read, end);
+	      data += bytes_read;
+	      if (data == end)
 		{
-		  warn (_("directory table ends unexpectedly\n"));
-		  n_directories = 0;
+		  warn (_("Corrupt directories list\n"));
 		  break;
 		}
 
-	      /* Go through the directory table again to save the directories.  */
 	      directory_table = (unsigned char **)
 		xmalloc (n_directories * sizeof (unsigned char *));
 
-	      i = 0;
-	      while (*ptr_directory_table != 0)
+	      for (entryi = 0; entryi < n_directories; entryi++)
 		{
-		  directory_table[i] = ptr_directory_table;
-		  ptr_directory_table += strnlen ((char *) ptr_directory_table,
-						  ptr_directory_table - end) + 1;
-		  i++;
-		}
-	    }
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
+		  unsigned char **pathp = &directory_table[entryi];
 
-	  /* Traverse the File Name table just to count the entries.  */
-	  if (data < end && *data != 0)
-	    {
-	      unsigned char *ptr_file_name_table = data;
+		  format = format_start;
+		  for (formati = 0; formati < format_count; formati++)
+		    {
+		      dwarf_vma content_type, form;
+		      dwarf_vma uvalue;
+
+		      content_type = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      form = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      if (data == end)
+			{
+			  warn (_("Corrupt directories list\n"));
+			  break;
+			}
+		      switch (content_type)
+			{
+			case DW_LNCT_path:
+			  switch (form)
+			    {
+			    case DW_FORM_string:
+			      *pathp = data;
+			      break;
+			    case DW_FORM_line_strp:
+			      SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size,
+					     end);
+			      /* Remove const by the cast.  */
+			      *pathp = (unsigned char *)
+				       fetch_indirect_line_string (uvalue);
+			      break;
+			    }
+			  break;
+			}
+		      data = read_and_display_attr_value (0, form, 0, data, end,
+		                                          0, 0,
+							  linfo.li_offset_size,
+							  linfo.li_version,
+							  NULL, 1, section,
+							  NULL, '\t');
+		    }
+		  if (data == end)
+		    {
+		      warn (_("Corrupt directories list\n"));
+		      break;
+		    }
+		}
 
-	      while (data < end && *data != 0)
+	      /* Skip files format.  */
+	      SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
+	      format_start = data;
+	      for (formati = 0; formati < format_count; formati++)
 		{
-		  unsigned int bytes_read;
-
-		  /* Skip Name, directory index, last modification time and length
-		     of file.  */
-		  data += strnlen ((char *) data, end - data) + 1;
-		  read_uleb128 (data, & bytes_read, end);
-		  data += bytes_read;
 		  read_uleb128 (data, & bytes_read, end);
 		  data += bytes_read;
 		  read_uleb128 (data, & bytes_read, end);
 		  data += bytes_read;
-
-		  n_files++;
 		}
 
-	      if (data >= end)
+	      n_files = read_uleb128 (data, & bytes_read, end);
+	      data += bytes_read;
+	      if (data == end)
 		{
-		  warn (_("file table ends unexpectedly\n"));
-		  n_files = 0;
+		  warn (_("Corrupt file name list\n"));
 		  break;
 		}
 
-	      /* Go through the file table again to save the strings.  */
-	      file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry));
+	      file_table = (File_Entry *) xcalloc (1, n_files
+						      * sizeof (File_Entry));
 
-	      i = 0;
-	      while (*ptr_file_name_table != 0)
+	      for (entryi = 0; entryi < n_files; entryi++)
 		{
-		  unsigned int bytes_read;
-
-		  file_table[i].name = ptr_file_name_table;
-		  ptr_file_name_table += strnlen ((char *) ptr_file_name_table,
-						  end - ptr_file_name_table) + 1;
-
-		  /* We are not interested in directory, time or size.  */
-		  file_table[i].directory_index = read_uleb128 (ptr_file_name_table,
-								& bytes_read, end);
-		  ptr_file_name_table += bytes_read;
-		  file_table[i].modification_date = read_uleb128 (ptr_file_name_table,
-								  & bytes_read, end);
-		  ptr_file_name_table += bytes_read;
-		  file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end);
-		  ptr_file_name_table += bytes_read;
-		  i++;
-		}
-	      i = 0;
+		  File_Entry *file = &file_table[entryi];
 
-	      /* Print the Compilation Unit's name and a header.  */
-	      if (directory_table == NULL)
+		  format = format_start;
+		  for (formati = 0; formati < format_count; formati++)
+		    {
+		      dwarf_vma content_type, form;
+		      dwarf_vma uvalue;
+
+		      content_type = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      form = read_uleb128 (format, & bytes_read, end);
+		      format += bytes_read;
+		      if (data == end)
+			{
+			  warn (_("Corrupt file name list\n"));
+			  break;
+			}
+		      switch (content_type)
+			{
+			case DW_LNCT_path:
+			  switch (form)
+			    {
+			    case DW_FORM_string:
+			      file->name = data;
+			      break;
+			    case DW_FORM_line_strp:
+			      SAFE_BYTE_GET (uvalue, data, linfo.li_offset_size,
+					     end);
+			      /* Remove const by the cast.  */
+			      file->name = (unsigned char *)
+					   fetch_indirect_line_string (uvalue);
+			      break;
+			    }
+			  break;
+			case DW_LNCT_directory_index:
+			  switch (form)
+			    {
+			    case DW_FORM_data1:
+			      SAFE_BYTE_GET (file->directory_index, data, 1,
+					     end);
+			      break;
+			    case DW_FORM_data2:
+			      SAFE_BYTE_GET (file->directory_index, data, 2,
+					     end);
+			      break;
+			    case DW_FORM_udata:
+			      file->directory_index = read_uleb128 (data, NULL,
+								    end);
+			      break;
+			    }
+			  break;
+			}
+		      data = read_and_display_attr_value (0, form, 0, data, end,
+							  0, 0,
+							  linfo.li_offset_size,
+							  linfo.li_version,
+							  NULL, 1, section,
+							  NULL, '\t');
+		    }
+		  if (data == end)
+		    {
+		      warn (_("Corrupt file name list\n"));
+		      break;
+		    }
+		}
+	    }
+	  else
+	    {
+	      if (*data != 0)
 		{
-		  printf (_("CU: %s:\n"), file_table[0].name);
-		  printf (_("File name                            Line number    Starting address\n"));
+		  unsigned char *ptr_directory_table = data;
+
+		  while (data < end && *data != 0)
+		    {
+		      data += strnlen ((char *) data, end - data) + 1;
+		      n_directories++;
+		    }
+
+		  /* PR 20440 */
+		  if (data >= end)
+		    {
+		      warn (_("directory table ends unexpectedly\n"));
+		      n_directories = 0;
+		      break;
+		    }
+
+		  /* Go through the directory table again to save the directories.  */
+		  directory_table = (unsigned char **)
+		    xmalloc (n_directories * sizeof (unsigned char *));
+
+		  i = 0;
+		  while (*ptr_directory_table != 0)
+		    {
+		      directory_table[i] = ptr_directory_table;
+		      ptr_directory_table += strnlen ((char *) ptr_directory_table,
+						      ptr_directory_table - end) + 1;
+		      i++;
+		    }
 		}
-	      else
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
+
+	      /* Traverse the File Name table just to count the entries.  */
+	      if (data < end && *data != 0)
 		{
-		  unsigned int ix = file_table[0].directory_index;
-		  const char *directory;
-
-		  if (ix == 0)
-		    directory = ".";
-		  /* PR 20439 */
-		  else if (n_directories == 0)
-		    directory = _("<unknown>");
-		  else if (ix > n_directories)
+		  unsigned char *ptr_file_name_table = data;
+
+		  while (data < end && *data != 0)
 		    {
-		      warn (_("directory index %u > number of directories %u\n"), ix, n_directories);
-		      directory = _("<corrupt>");
+		      unsigned int bytes_read;
+
+		      /* Skip Name, directory index, last modification time and length
+			 of file.  */
+		      data += strnlen ((char *) data, end - data) + 1;
+		      read_uleb128 (data, & bytes_read, end);
+		      data += bytes_read;
+		      read_uleb128 (data, & bytes_read, end);
+		      data += bytes_read;
+		      read_uleb128 (data, & bytes_read, end);
+		      data += bytes_read;
+
+		      n_files++;
 		    }
-		  else
-		    directory = (char *) directory_table[ix - 1];
 
-		  if (do_wide || strlen (directory) < 76)
-		    printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
-		  else
-		    printf ("%s:\n", file_table[0].name);
+		  if (data >= end)
+		    {
+		      warn (_("file table ends unexpectedly\n"));
+		      n_files = 0;
+		      break;
+		    }
+
+		  /* Go through the file table again to save the strings.  */
+		  file_table = (File_Entry *) xmalloc (n_files * sizeof (File_Entry));
 
-		  printf (_("File name                            Line number    Starting address\n"));
+		  i = 0;
+		  while (*ptr_file_name_table != 0)
+		    {
+		      unsigned int bytes_read;
+
+		      file_table[i].name = ptr_file_name_table;
+		      ptr_file_name_table += strnlen ((char *) ptr_file_name_table,
+						      end - ptr_file_name_table) + 1;
+
+		      /* We are not interested in directory, time or size.  */
+		      file_table[i].directory_index = read_uleb128 (ptr_file_name_table,
+								    & bytes_read, end);
+		      ptr_file_name_table += bytes_read;
+		      file_table[i].modification_date = read_uleb128 (ptr_file_name_table,
+								      & bytes_read, end);
+		      ptr_file_name_table += bytes_read;
+		      file_table[i].length = read_uleb128 (ptr_file_name_table, & bytes_read, end);
+		      ptr_file_name_table += bytes_read;
+		      i++;
+		    }
+		  i = 0;
 		}
+
+	      /* Skip the NUL at the end of the table.  */
+	      data++;
 	    }
 
-	  /* Skip the NUL at the end of the table.  */
-	  data++;
+	  /* Print the Compilation Unit's name and a header.  */
+	  if (directory_table == NULL)
+	    {
+	      printf (_("CU: %s:\n"), file_table[0].name);
+	      printf (_("File name                            Line number    Starting address\n"));
+	    }
+	  else
+	    {
+	      unsigned int ix = file_table[0].directory_index;
+	      const char *directory;
+
+	      if (ix == 0)
+		directory = ".";
+	      /* PR 20439 */
+	      else if (n_directories == 0)
+		directory = _("<unknown>");
+	      else if (ix > n_directories)
+		{
+		  warn (_("directory index %u > number of directories %s\n"),
+			ix, dwarf_vmatoa ("u", n_directories));
+		  directory = _("<corrupt>");
+		}
+	      else
+		directory = (char *) directory_table[ix - 1];
+
+	      if (do_wide || strlen (directory) < 76)
+		printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
+	      else
+		printf ("%s:\n", file_table[0].name);
+
+	      printf (_("File name                            Line number    Starting address\n"));
+	    }
 
 	  saved_linfo = linfo;
 	}
@@ -3550,7 +3950,8 @@ display_debug_lines_decoded (struct dwarf_section *section,
 		     /* PR 20439 */
 		     else if (dir > n_directories)
 		       {
-			 warn (_("directory index %u > number of directories %u\n"), dir, n_directories);
+			 warn (_("directory index %u > number of directories %s\n"),
+			       dir, dwarf_vmatoa ("u", n_directories));
 			 printf (_("\n <over large directory table entry %u>\n"), dir);
 		       }
 		     else
@@ -3722,7 +4123,7 @@ display_debug_lines_decoded (struct dwarf_section *section,
 }
 
 static int
-display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
+display_debug_lines (struct dwarf_section *section, void *file)
 {
   unsigned char *data = section->start;
   unsigned char *end = data + section->size;
@@ -3733,10 +4134,10 @@ display_debug_lines (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED)
     do_debug_lines |= FLAG_DEBUG_LINES_RAW;
 
   if (do_debug_lines & FLAG_DEBUG_LINES_RAW)
-    retValRaw = display_debug_lines_raw (section, data, end);
+    retValRaw = display_debug_lines_raw (section, data, end, file);
 
   if (do_debug_lines & FLAG_DEBUG_LINES_DECODED)
-    retValDecoded = display_debug_lines_decoded (section, data, end);
+    retValDecoded = display_debug_lines_decoded (section, data, end, file);
 
   if (!retValRaw || !retValDecoded)
     return 0;
@@ -4326,9 +4727,10 @@ display_debug_macro (struct dwarf_section *section,
 		    {
 		      int val;
 
+		      /* DW_FORM_implicit_const is not expected here.  */
 		      SAFE_BYTE_GET_AND_INC (val, desc, 1, end);
 		      curr
-			= read_and_display_attr_value (0, val,
+			= read_and_display_attr_value (0, val, 0,
 						       curr, end, 0, 0, offset_size,
 						       version, NULL, 0, NULL,
 						       NULL, ' ');
@@ -4381,9 +4783,14 @@ display_debug_abbrev (struct dwarf_section *section,
 		  entry->children ? _("has children") : _("no children"));
 
 	  for (attr = entry->first_attr; attr; attr = attr->next)
-	    printf ("    %-18s %s\n",
-		    get_AT_name (attr->attribute),
-		    get_FORM_name (attr->form));
+	    {
+	      printf ("    %-18s %s",
+		      get_AT_name (attr->attribute),
+		      get_FORM_name (attr->form));
+	      if (attr->form == DW_FORM_implicit_const)
+		printf (": %" BFD_VMA_FMT "d", attr->implicit_const);
+	      putchar ('\n');
+	    }
 	}
     }
   while (start);
@@ -4531,6 +4938,129 @@ display_loc_list (struct dwarf_section *section,
   *start_ptr = start;
 }
 
+/* Display a location list from a normal (ie, non-dwo) .debug_loclists section.  */
+
+static void
+display_loclists_list (struct dwarf_section *section,
+		       unsigned char **start_ptr,
+		       unsigned int debug_info_entry,
+		       dwarf_vma offset,
+		       dwarf_vma base_address,
+		       int has_frame_base)
+{
+  unsigned char *start = *start_ptr;
+  unsigned char *section_end = section->start + section->size;
+  unsigned long cu_offset;
+  unsigned int pointer_size;
+  unsigned int offset_size;
+  int dwarf_version;
+  unsigned int bytes_read;
+
+  dwarf_vma begin;
+  dwarf_vma end;
+  dwarf_vma length;
+  int need_frame_base;
+
+  if (debug_info_entry >= num_debug_info_entries)
+    {
+      warn (_("No debug information available for "
+	      "loclists lists of entry: %u\n"),
+	    debug_info_entry);
+      return;
+    }
+
+  cu_offset = debug_information [debug_info_entry].cu_offset;
+  pointer_size = debug_information [debug_info_entry].pointer_size;
+  offset_size = debug_information [debug_info_entry].offset_size;
+  dwarf_version = debug_information [debug_info_entry].dwarf_version;
+
+  if (pointer_size < 2 || pointer_size > 8)
+    {
+      warn (_("Invalid pointer size (%d) in debug info for entry %d\n"),
+	    pointer_size, debug_info_entry);
+      return;
+    }
+
+  while (1)
+    {
+      dwarf_vma off = offset + (start - *start_ptr);
+      enum dwarf_location_list_entry_type llet;
+
+      if (start + 1 > section_end)
+	{
+	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
+		(unsigned long) offset);
+	  break;
+	}
+
+      printf ("    %8.8lx ", (unsigned long) off);
+
+      SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end);
+
+      switch (llet)
+	{
+	case DW_LLE_end_of_list:
+	  printf (_("<End of list>\n"));
+	  break;
+	case DW_LLE_offset_pair:
+	  begin = read_uleb128 (start, &bytes_read, section_end);
+	  start += bytes_read;
+	  end = read_uleb128 (start, &bytes_read, section_end);
+	  start += bytes_read;
+	  break;
+	case DW_LLE_base_address:
+	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size,
+				 section_end);
+	  print_dwarf_vma (base_address, pointer_size);
+	  printf (_("(base address)\n"));
+	  break;
+	default:
+	  error (_("Invalid location list entry type %d\n"), llet);
+	  return;
+	}
+      if (llet == DW_LLE_end_of_list)
+	break;
+      if (llet != DW_LLE_offset_pair)
+	continue;
+
+      if (start + 2 > section_end)
+	{
+	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
+		(unsigned long) offset);
+	  break;
+	}
+
+      length = read_uleb128 (start, &bytes_read, section_end);
+      start += bytes_read;
+
+      print_dwarf_vma (begin + base_address, pointer_size);
+      print_dwarf_vma (end + base_address, pointer_size);
+
+      putchar ('(');
+      need_frame_base = decode_location_expression (start,
+						    pointer_size,
+						    offset_size,
+						    dwarf_version,
+						    length,
+						    cu_offset, section);
+      putchar (')');
+
+      if (need_frame_base && !has_frame_base)
+	printf (_(" [without DW_AT_frame_base]"));
+
+      if (begin == end)
+	fputs (_(" (start == end)"), stdout);
+      else if (begin > end)
+	fputs (_(" (start > end)"), stdout);
+
+      putchar ('\n');
+
+      start += length;
+    }
+
+  *start_ptr = start;
+}
+
 /* Print a .debug_addr table index in decimal, surrounded by square brackets,
    right-adjusted in a field of length LEN, and followed by a space.  */
 
@@ -4701,6 +5231,8 @@ display_debug_loc (struct dwarf_section *section, void *file)
   unsigned int *array = NULL;
   const char *suffix = strrchr (section->name, '.');
   int is_dwo = 0;
+  int is_loclists = strstr (section->name, "debug_loclists") != NULL;
+  dwarf_vma expected_start = 0;
 
   if (suffix && strcmp (suffix, ".dwo") == 0)
     is_dwo = 1;
@@ -4713,6 +5245,51 @@ display_debug_loc (struct dwarf_section *section, void *file)
       return 0;
     }
 
+  if (is_loclists)
+    {
+      unsigned char *hdrptr = section_begin;
+      dwarf_vma ll_length;
+      unsigned short ll_version;
+      unsigned char *end = section_begin + section->size;
+      unsigned char address_size, segment_selector_size;
+      uint32_t offset_entry_count;
+
+      SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 4, end);
+      if (ll_length == 0xffffffff)
+	SAFE_BYTE_GET_AND_INC (ll_length, hdrptr, 8, end);
+
+      SAFE_BYTE_GET_AND_INC (ll_version, hdrptr, 2, end);
+      if (ll_version != 5)
+	{
+	  warn (_("The %s section contains corrupt or "
+		  "unsupported version number: %d.\n"),
+		section->name, ll_version);
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (address_size, hdrptr, 1, end);
+
+      SAFE_BYTE_GET_AND_INC (segment_selector_size, hdrptr, 1, end);
+      if (segment_selector_size != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported segment selector size: %d.\n"),
+		section->name, segment_selector_size);
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (offset_entry_count, hdrptr, 4, end);
+      if (offset_entry_count != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported offset entry count: %d.\n"),
+		section->name, offset_entry_count);
+	  return 0;
+	}
+
+      expected_start = hdrptr - section_begin;
+    }
+
   if (load_debug_info (file) == 0)
     {
       warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
@@ -4762,7 +5339,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
     error (_("No location lists in .debug_info section!\n"));
 
   if (debug_information [first].num_loc_offsets > 0
-      && debug_information [first].loc_offsets [0] != 0)
+      && debug_information [first].loc_offsets [0] != expected_start)
     warn (_("Location lists in %s section start at 0x%s\n"),
 	  section->name,
 	  dwarf_vmatoa ("x", debug_information [first].loc_offsets [0]));
@@ -4826,11 +5403,23 @@ display_debug_loc (struct dwarf_section *section, void *file)
 	      continue;
 	    }
 
-	  if (is_dwo)
-	    display_loc_list_dwo (section, &start, i, offset, has_frame_base);
+	  if (!is_loclists)
+	    {
+	      if (is_dwo)
+		display_loc_list_dwo (section, &start, i, offset,
+				      has_frame_base);
+	      else
+		display_loc_list (section, &start, i, offset, base_address,
+				  has_frame_base);
+	    }
 	  else
-	    display_loc_list (section, &start, i, offset, base_address,
-			      has_frame_base);
+	    {
+	      if (is_dwo)
+		warn (_("DWO is not yet supported.\n"));
+	      else
+		display_loclists_list (section, &start, i, offset, base_address,
+				       has_frame_base);
+	    }
 	}
     }
 
@@ -5172,6 +5761,125 @@ range_entry_compar (const void *ap, const void *bp)
   return (a > b) - (b > a);
 }
 
+static void
+display_debug_ranges_list (unsigned char *start, unsigned char *finish,
+			   unsigned int pointer_size, unsigned long offset,
+			   unsigned long base_address)
+{
+  while (start < finish)
+    {
+      dwarf_vma begin;
+      dwarf_vma end;
+
+      SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
+      if (start >= finish)
+	break;
+      SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
+
+      printf ("    %8.8lx ", offset);
+
+      if (begin == 0 && end == 0)
+	{
+	  printf (_("<End of list>\n"));
+	  break;
+	}
+
+      /* Check base address specifiers.  */
+      if (is_max_address (begin, pointer_size)
+	  && !is_max_address (end, pointer_size))
+	{
+	  base_address = end;
+	  print_dwarf_vma (begin, pointer_size);
+	  print_dwarf_vma (end, pointer_size);
+	  printf ("(base address)\n");
+	  continue;
+	}
+
+      print_dwarf_vma (begin + base_address, pointer_size);
+      print_dwarf_vma (end + base_address, pointer_size);
+
+      if (begin == end)
+	fputs (_("(start == end)"), stdout);
+      else if (begin > end)
+	fputs (_("(start > end)"), stdout);
+
+      putchar ('\n');
+    }
+}
+
+static void
+display_debug_rnglists_list (unsigned char *start, unsigned char *finish,
+			     unsigned int pointer_size, unsigned long offset,
+			     unsigned long base_address)
+{
+  unsigned char *next = start;
+
+  while (1)
+    {
+      unsigned long off = offset + (start - next);
+      enum dwarf_range_list_entry rlet;
+      dwarf_vma begin, length, end;
+      unsigned int bytes_read;
+
+      if (start + 1 > finish)
+	{
+	  warn (_("Range list starting at offset 0x%lx is not terminated.\n"),
+		offset);
+	  break;
+	}
+
+      printf ("    %8.8lx ", off);
+
+      SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish);
+
+      switch (rlet)
+	{
+	case DW_RLE_end_of_list:
+	  printf (_("<End of list>\n"));
+	  break;
+	case DW_RLE_base_address:
+	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish);
+	  print_dwarf_vma (base_address, pointer_size);
+	  printf (_("(base address)\n"));
+	  break;
+	case DW_RLE_start_length:
+	  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
+	  length = read_uleb128 (start, &bytes_read, finish);
+	  start += bytes_read;
+	  end = begin + length;
+	  break;
+	case DW_RLE_offset_pair:
+	  begin = read_uleb128 (start, &bytes_read, finish);
+	  start += bytes_read;
+	  end = read_uleb128 (start, &bytes_read, finish);
+	  start += bytes_read;
+	  break;
+	case DW_RLE_start_end:
+	  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
+	  SAFE_BYTE_GET_AND_INC (end, start, pointer_size, finish);
+	  break;
+	default:
+	  error (_("Invalid range list entry type %d\n"), rlet);
+	  rlet = DW_RLE_end_of_list;
+	  break;
+	}
+      if (rlet == DW_RLE_end_of_list)
+	break;
+      if (rlet == DW_RLE_base_address)
+	continue;
+
+      print_dwarf_vma (begin + base_address, pointer_size);
+      print_dwarf_vma (end + base_address, pointer_size);
+
+      if (begin == end)
+	fputs (_("(start == end)"), stdout);
+      else if (begin > end)
+	fputs (_("(start > end)"), stdout);
+
+      putchar ('\n');
+    }
+}
+
 static int
 display_debug_ranges (struct dwarf_section *section,
 		      void *file ATTRIBUTE_UNUSED)
@@ -5183,6 +5891,9 @@ display_debug_ranges (struct dwarf_section *section,
   unsigned char *finish = start + bytes;
   unsigned int num_range_list, i;
   struct range_entry *range_entries, *range_entry_fill;
+  int is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
+  /* Initialize it due to a false compiler warning.  */
+  unsigned char address_size = 0;
 
   if (bytes == 0)
     {
@@ -5190,6 +5901,78 @@ display_debug_ranges (struct dwarf_section *section,
       return 0;
     }
 
+  if (is_rnglists)
+    {
+      dwarf_vma initial_length;
+      unsigned int initial_length_size;
+      unsigned char segment_selector_size;
+      unsigned int offset_size, offset_entry_count;
+      unsigned short version;
+
+      /* Get and check the length of the block.  */
+      SAFE_BYTE_GET_AND_INC (initial_length, start, 4, finish);
+
+      if (initial_length == 0xffffffff)
+	{
+	  /* This section is 64-bit DWARF 3.  */
+	  SAFE_BYTE_GET_AND_INC (initial_length, start, 8, finish);
+	  offset_size = 8;
+	  initial_length_size = 12;
+	}
+      else
+	{
+	  offset_size = 4;
+	  initial_length_size = 4;
+	}
+
+      if (initial_length + initial_length_size > section->size)
+	{
+	  /* If the length field has a relocation against it, then we should
+	     not complain if it is inaccurate (and probably negative).
+	     It is copied from .debug_line handling code.  */
+	  if (reloc_at (section, (start - section->start) - offset_size))
+	    {
+	      initial_length = (finish - start) - initial_length_size;
+	    }
+	  else
+	    {
+	      warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"),
+		    (long) initial_length);
+	      return 0;
+	    }
+	}
+
+      /* Get and check the version number.  */
+      SAFE_BYTE_GET_AND_INC (version, start, 2, finish);
+
+      if (version != 5)
+	{
+	  warn (_("Only DWARF version 5 debug_rnglists info "
+		  "is currently supported.\n"));
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (address_size, start, 1, finish);
+
+      SAFE_BYTE_GET_AND_INC (segment_selector_size, start, 1, finish);
+      if (segment_selector_size != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported segment selector size: %d.\n"),
+		section->name, segment_selector_size);
+	  return 0;
+	}
+
+      SAFE_BYTE_GET_AND_INC (offset_entry_count, start, 4, finish);
+      if (offset_entry_count != 0)
+	{
+	  warn (_("The %s section contains "
+		  "unsupported offset entry count: %u.\n"),
+		section->name, offset_entry_count);
+	  return 0;
+	}
+    }
+
   if (load_debug_info (file) == 0)
     {
       warn (_("Unable to load/parse the .debug_info section, so cannot interpret the %s section.\n"),
@@ -5245,7 +6028,7 @@ display_debug_ranges (struct dwarf_section *section,
       unsigned char *next;
       dwarf_vma base_address;
 
-      pointer_size = debug_info_p->pointer_size;
+      pointer_size = (is_rnglists ? address_size : debug_info_p->pointer_size);
       offset = range_entry->ranges_offset;
       next = section_begin + offset;
       base_address = debug_info_p->base_address;
@@ -5276,45 +6059,8 @@ display_debug_ranges (struct dwarf_section *section,
       start = next;
       last_start = next;
 
-      while (start < finish)
-	{
-	  dwarf_vma begin;
-	  dwarf_vma end;
-
-	  SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
-	  if (start >= finish)
-	    break;
-	  SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
-
-	  printf ("    %8.8lx ", (unsigned long) offset);
-
-	  if (begin == 0 && end == 0)
-	    {
-	      printf (_("<End of list>\n"));
-	      break;
-	    }
-
-	  /* Check base address specifiers.  */
-          if (is_max_address (begin, pointer_size)
-              && !is_max_address (end, pointer_size))
-	    {
-	      base_address = end;
-	      print_dwarf_vma (begin, pointer_size);
-	      print_dwarf_vma (end, pointer_size);
-	      printf ("(base address)\n");
-	      continue;
-	    }
-
-	  print_dwarf_vma (begin + base_address, pointer_size);
-	  print_dwarf_vma (end + base_address, pointer_size);
-
-	  if (begin == end)
-	    fputs (_("(start == end)"), stdout);
-	  else if (begin > end)
-	    fputs (_("(start > end)"), stdout);
-
-	  putchar ('\n');
-	}
+      (is_rnglists ? display_debug_rnglists_list : display_debug_ranges_list)
+	(start, finish, pointer_size, offset, base_address);
     }
   putchar ('\n');
 
@@ -7731,14 +8477,20 @@ struct dwarf_section_display debug_displays[] =
     display_debug_macro,    &do_debug_macinfo,	TRUE },
   { { ".debug_str",	    ".zdebug_str",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_str,	    &do_debug_str,	FALSE },
+  { { ".debug_line_str",    ".zdebug_line_str",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
+    display_debug_str,	    &do_debug_str,	FALSE },
   { { ".debug_loc",	    ".zdebug_loc",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_loc,	    &do_debug_loc,	TRUE },
+  { { ".debug_loclists",    ".zdebug_loclists",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
+    display_debug_loc,	    &do_debug_loc,	TRUE },
   { { ".debug_pubtypes",    ".zdebug_pubtypes",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_pubnames, &do_debug_pubtypes,	FALSE },
   { { ".debug_gnu_pubtypes", ".zdebug_gnu_pubtypes", NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_gnu_pubnames, &do_debug_pubtypes, FALSE },
   { { ".debug_ranges",	    ".zdebug_ranges",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_ranges,   &do_debug_ranges,	TRUE },
+  { { ".debug_rnglists",    ".zdebug_rnglists",	NULL, NULL, 0, 0, 0, NULL, 0, NULL },
+    display_debug_ranges,   &do_debug_ranges,	TRUE },
   { { ".debug_static_func", ".zdebug_static_func", NULL, NULL, 0, 0, 0, NULL, 0, NULL },
     display_debug_not_supported, NULL,		FALSE },
   { { ".debug_static_vars", ".zdebug_static_vars", NULL, NULL, 0, 0, 0, NULL, 0, NULL },
diff --git a/binutils/dwarf.h b/binutils/dwarf.h
index 30562be..cf9f331 100644
--- a/binutils/dwarf.h
+++ b/binutils/dwarf.h
@@ -18,6 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "dwarf2.h" /* for enum dwarf_unit_type */
+
 typedef unsigned HOST_WIDEST_INT  dwarf_vma;
 typedef HOST_WIDEST_INT           dwarf_signed_vma;
 typedef unsigned HOST_WIDEST_INT  dwarf_size_type;
@@ -34,6 +36,7 @@ typedef struct
   int            li_line_base;
   unsigned char  li_line_range;
   unsigned char  li_opcode_base;
+  unsigned int   li_offset_size;
 }
 DWARF2_Internal_LineInfo;
 
@@ -54,6 +57,7 @@ typedef struct
   unsigned short cu_version;
   dwarf_vma	 cu_abbrev_offset;
   unsigned char  cu_pointer_size;
+  enum dwarf_unit_type cu_unit_type;
 }
 DWARF2_Internal_CompUnit;
 
@@ -83,6 +87,7 @@ enum dwarf_section_display_enum
   macinfo,
   macro,
   str,
+  line_str,
   loc,
   pubtypes,
   gnu_pubtypes,
diff --git a/binutils/readelf.c b/binutils/readelf.c
index eca066b..9caa4da 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -5962,11 +5962,13 @@ process_section_headers (FILE * file)
 	      || (do_debug_pubtypes && const_strneq (name, "gnu_pubtypes"))
 	      || (do_debug_aranges  && const_strneq (name, "aranges"))
 	      || (do_debug_ranges   && const_strneq (name, "ranges"))
+	      || (do_debug_ranges   && const_strneq (name, "rnglists"))
 	      || (do_debug_frames   && const_strneq (name, "frame"))
 	      || (do_debug_macinfo  && const_strneq (name, "macinfo"))
 	      || (do_debug_macinfo  && const_strneq (name, "macro"))
 	      || (do_debug_str      && const_strneq (name, "str"))
 	      || (do_debug_loc      && const_strneq (name, "loc"))
+	      || (do_debug_loc      && const_strneq (name, "loclists"))
 	      || (do_debug_addr     && const_strneq (name, "addr"))
 	      || (do_debug_cu_index && const_strneq (name, "cu_index"))
 	      || (do_debug_cu_index && const_strneq (name, "tu_index"))
-- 
2.9.3

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [PATCH 4/6] DWARF-5: call sites
  2017-02-22 11:49   ` Nick Clifton
@ 2017-02-23 22:12     ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 22:12 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

Hi Nick,

On Wed, 22 Feb 2017 12:49:16 +0100, Nick Clifton wrote:
> > binutils/ChangeLog
> > 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer,
> > 	DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert
> > 	and DW_OP_reinterpret.
> > 	(read_and_display_attr_value): Support DW_AT_call_value,
> > 	DW_AT_call_data_value, DW_AT_call_target and
> > 	DW_AT_call_target_clobbered.
> 
> Approved - please apply.

bc0a77d2b1a29222dacab21a0572322e39fb0c70


Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [PATCH 5/6] DWARF-5: Macros
  2017-02-22 11:50   ` Nick Clifton
@ 2017-02-23 22:13     ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 22:13 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

Hi Nick,

On Wed, 22 Feb 2017 12:50:04 +0100, Nick Clifton wrote:
> > binutils/ChangeLog
> > 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* dwarf.c (display_debug_macro): Support DWARF-5.  Rename
> > 	DW_MACRO_GNU_*.
> 
> Approved - please apply.

7a7e1061d483f68df1c1369fc49ffadb4ea6f840


Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [PATCH 6/6] DWARF-5: DW_FORM_data16
  2017-02-22 11:51   ` Nick Clifton
@ 2017-02-23 22:13     ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 22:13 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

Hi Nick,

On Wed, 22 Feb 2017 12:50:57 +0100, Nick Clifton wrote:
> > binutils/ChangeLog
> > 2017-02-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
> > 
> > 	* dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.
> 
> Approved - please apply.

2f6cd5918e58572e118b59a26062724404fb4042


Jan

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [commit] [patch] DWARF-5: testcase
  2017-02-21  9:44         ` Nick Clifton
@ 2017-02-23 22:17           ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-23 22:17 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

Hi Nick,

On Tue, 21 Feb 2017 10:44:22 +0100, Nick Clifton wrote:
> Attached is a revised test.

Checked in as:
	a567769b813b2538bebc97d689fc0739f172028e

But I have reverted there your change causing on Fedora 25 x86_64:
regexp_diff match failure
regexp "^    <13a>   DW_AT_call_value  : 1 byte block: 30 $"
line   "    <13a>   DW_AT_call_value  : 1 byte block: 30        (DW_OP_lit0)"
FAIL: readelf -wiaoRlL

This decoding has been implemented in this patchset by:
commit bc0a77d2b1a29222dacab21a0572322e39fb0c70
    DWARF-5: call sites
            (read_and_display_attr_value): Support DW_AT_call_value,

I hope the checked-in version is the right one.


Jan

[-- Attachment #2: Type: message/rfc822, Size: 40487 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] DWARF-5: testcase
Date: Thu, 23 Feb 2017 22:54:02 +0100

binutils/
2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* testsuite/binutils-all/dw5.S: New file.
	* testsuite/binutils-all/dw5.W: New file.
	* testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test.
---
 binutils/ChangeLog                          |   6 +
 binutils/testsuite/binutils-all/dw5.S       | 679 ++++++++++++++++++++++++++++
 binutils/testsuite/binutils-all/dw5.W       | 355 +++++++++++++++
 binutils/testsuite/binutils-all/readelf.exp |  25 +
 4 files changed, 1065 insertions(+)
 create mode 100644 binutils/testsuite/binutils-all/dw5.S
 create mode 100644 binutils/testsuite/binutils-all/dw5.W

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 26aa81e..a21e36e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,11 @@
 2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	* testsuite/binutils-all/dw5.S: New file.
+	* testsuite/binutils-all/dw5.W: New file.
+	* testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test.
+
+2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.
 
 2017-02-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
diff --git a/binutils/testsuite/binutils-all/dw5.S b/binutils/testsuite/binutils-all/dw5.S
new file mode 100644
index 0000000..83bb639
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw5.S
@@ -0,0 +1,679 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+	.file	"main.c"
+	.text
+.Ltext0:
+	.p2align 4,,15
+	.globl	func
+	.type	func, %function
+func:
+.LFB0:
+	/* main.c:5 */
+.LM1:
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	/* main.c:5 */
+.LM2:
+	.dc.b 0
+/* SUCC: */
+	.dc.b 0
+.LFE0:
+	.size	func, .-func
+	.section	.text.startup,"ax",%progbits
+	.p2align 4,,15
+	.globl	main
+	.type	main, %function
+main:
+.LFB1:
+	/* main.c:6 */
+.LM3:
+.LVL0:
+/* BLOCK 2 freq:10000 seq:0 */
+/* PRED: ENTRY [100.0%]  (FALLTHRU) */
+	.dc.b 0
+	/* main.c:6 */
+.LM4:
+	.dc.b 0
+.LVL1:
+	.dc.b 0
+.LVL2:
+	.dc.b 0
+/* SUCC: EXIT [100.0%]  */
+	.dc.b 0
+.LFE1:
+	.size	main, .-main
+	.comm	pvar,8,8
+	.comm	yvar,4,4
+	.globl	xvar
+	.data
+	.align 4
+	.type	xvar, %object
+	.size	xvar, 4
+xvar:
+	.4byte	42
+	.text
+.Letext0:
+	.section	.debug_info,"",%progbits
+.Ldebug_info0:
+	.4byte	0x160	/* Length of Compilation Unit Info */
+	.2byte	0x5	/* DWARF version number */
+	.byte	0x1	/* DW_UT_compile */
+	.byte	0x8	/* Pointer Size (in bytes) */
+	.4byte	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
+	.uleb128 0x6	/* (DIE (0xc) DW_TAG_compile_unit) */
+	.4byte	.LASF21	/* DW_AT_producer: "GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2" */
+	.byte	0x1d	/* DW_AT_language */
+	.4byte	.LASF0	/* DW_AT_name: "main.c" */
+	.4byte	.LASF1	/* DW_AT_comp_dir: "" */
+	.4byte	.LLRL2	/* DW_AT_ranges */
+	.8byte	0	/* DW_AT_low_pc */
+	.4byte	.Ldebug_line0	/* DW_AT_stmt_list */
+	.uleb128 0x1	/* (DIE (0x2a) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x8	/* DW_AT_encoding */
+	.4byte	.LASF2	/* DW_AT_name: "unsigned char" */
+	.uleb128 0x1	/* (DIE (0x31) DW_TAG_base_type) */
+	.byte	0x2	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF3	/* DW_AT_name: "short unsigned int" */
+	.uleb128 0x1	/* (DIE (0x38) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF4	/* DW_AT_name: "unsigned int" */
+	.uleb128 0x1	/* (DIE (0x3f) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF5	/* DW_AT_name: "long unsigned int" */
+	.uleb128 0x1	/* (DIE (0x46) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x6	/* DW_AT_encoding */
+	.4byte	.LASF6	/* DW_AT_name: "signed char" */
+	.uleb128 0x1	/* (DIE (0x4d) DW_TAG_base_type) */
+	.byte	0x2	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.4byte	.LASF7	/* DW_AT_name: "short int" */
+	.uleb128 0x7	/* (DIE (0x54) DW_TAG_base_type) */
+	.byte	0x4	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.ascii "int\0"	/* DW_AT_name */
+	.uleb128 0x1	/* (DIE (0x5b) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x5	/* DW_AT_encoding */
+	.4byte	.LASF8	/* DW_AT_name: "long int" */
+	.uleb128 0x1	/* (DIE (0x62) DW_TAG_base_type) */
+	.byte	0x8	/* DW_AT_byte_size */
+	.byte	0x7	/* DW_AT_encoding */
+	.4byte	.LASF9	/* DW_AT_name: "sizetype" */
+	.uleb128 0x3	/* (DIE (0x69) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.4byte	0x6e	/* DW_AT_type */
+	.uleb128 0x1	/* (DIE (0x6e) DW_TAG_base_type) */
+	.byte	0x1	/* DW_AT_byte_size */
+	.byte	0x6	/* DW_AT_encoding */
+	.4byte	.LASF10	/* DW_AT_name: "char" */
+	.uleb128 0x8	/* (DIE (0x75) DW_TAG_variable) */
+	.4byte	.LASF11	/* DW_AT_name: "__environ" */
+	.byte	0x2	/* DW_AT_decl_file (/usr/include/unistd.h) */
+	.2byte	0x222	/* DW_AT_decl_line */
+	.4byte	0x81	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x3	/* (DIE (0x81) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.4byte	0x69	/* DW_AT_type */
+	.uleb128 0x2	/* (DIE (0x86) DW_TAG_variable) */
+	.4byte	.LASF12	/* DW_AT_name: "optarg" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x39	/* DW_AT_decl_line */
+	.4byte	0x69	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0x90) DW_TAG_variable) */
+	.4byte	.LASF13	/* DW_AT_name: "optind" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x47	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0x9a) DW_TAG_variable) */
+	.4byte	.LASF14	/* DW_AT_name: "opterr" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x4c	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x2	/* (DIE (0xa4) DW_TAG_variable) */
+	.4byte	.LASF15	/* DW_AT_name: "optopt" */
+			/* DW_AT_decl_file (3, /usr/include/getopt.h) */
+	.byte	0x50	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.uleb128 0x4	/* (DIE (0xae) DW_TAG_variable) */
+	.4byte	.LASF16	/* DW_AT_name: "xvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x2	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.8byte	0x1234
+	.uleb128 0x4	/* (DIE (0xc2) DW_TAG_variable) */
+	.4byte	.LASF17	/* DW_AT_name: "yvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x3	/* DW_AT_decl_line */
+	.4byte	0x54	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.8byte	0x1234
+	.uleb128 0x4	/* (DIE (0xd6) DW_TAG_variable) */
+	.4byte	.LASF18	/* DW_AT_name: "pvar" */
+			/* DW_AT_decl_file (1, main.c) */
+	.byte	0x4	/* DW_AT_decl_line */
+	.4byte	0xea	/* DW_AT_type */
+			/* DW_AT_external */
+	.uleb128 0x9	/* DW_AT_location */
+	.byte	0x3	/* DW_OP_addr */
+	.8byte	0x1234
+	.uleb128 0x3	/* (DIE (0xea) DW_TAG_pointer_type) */
+			/* DW_AT_byte_size (0x8) */
+	.4byte	0x54	/* DW_AT_type */
+	.uleb128 0x9	/* (DIE (0xef) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.4byte	.LASF22	/* DW_AT_name: "main" */
+	.byte	0x1	/* DW_AT_decl_file (main.c) */
+	.byte	0x6	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.4byte	0x54	/* DW_AT_type */
+	.8byte	0x1234	/* DW_AT_low_pc */
+	.8byte	0x5678	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.4byte	0x13e	/* DW_AT_sibling */
+	.uleb128 0x5	/* (DIE (0x110) DW_TAG_formal_parameter) */
+	.4byte	.LASF19	/* DW_AT_name: "argc" */
+			/* DW_AT_decl_file (1, main.c) */
+			/* DW_AT_decl_line (0x6) */
+	.4byte	0x54	/* DW_AT_type */
+	.4byte	.LLST0	/* DW_AT_location */
+	.uleb128 0x5	/* (DIE (0x11d) DW_TAG_formal_parameter) */
+	.4byte	.LASF20	/* DW_AT_name: "argv" */
+			/* DW_AT_decl_file (1, main.c) */
+			/* DW_AT_decl_line (0x6) */
+	.4byte	0x81	/* DW_AT_type */
+	.4byte	.LLST1	/* DW_AT_location */
+	.uleb128 0xa	/* (DIE (0x12a) DW_TAG_call_site) */
+	.8byte	0x12345	/* DW_AT_call_return_pc */
+	.4byte	0x157	/* DW_AT_call_origin */
+	.uleb128 0xb	/* (DIE (0x137) DW_TAG_call_site_parameter) */
+	.uleb128 0x1	/* DW_AT_location */
+	.byte	0x55	/* DW_OP_reg5 */
+	.uleb128 0x1	/* DW_AT_call_value */
+	.byte	0x30	/* DW_OP_lit0 */
+	.byte	0	/* end of children of DIE 0x12a */
+	.byte	0	/* end of children of DIE 0xef */
+	.uleb128 0xc	/* (DIE (0x13e) DW_TAG_subprogram) */
+			/* DW_AT_external */
+	.4byte	.LASF23	/* DW_AT_name: "func" */
+	.byte	0x1	/* DW_AT_decl_file (main.c) */
+	.byte	0x5	/* DW_AT_decl_line */
+			/* DW_AT_prototyped */
+	.8byte	0x1234	/* DW_AT_low_pc */
+	.8byte	0x5678	/* DW_AT_high_pc */
+	.uleb128 0x1	/* DW_AT_frame_base */
+	.byte	0x9c	/* DW_OP_call_frame_cfa */
+			/* DW_AT_call_all_calls */
+	.uleb128 0xd	/* (DIE (0x157) DW_TAG_subprogram) */
+			/* DW_AT_external */
+			/* DW_AT_declaration */
+	.4byte	.LASF24	/* DW_AT_linkage_name: "alarm" */
+	.4byte	.LASF24	/* DW_AT_name: "alarm" */
+	.byte	0x2	/* DW_AT_decl_file (/usr/include/unistd.h) */
+	.2byte	0x1b3	/* DW_AT_decl_line */
+	.byte	0	/* end of children of DIE 0xc */
+	.section	.debug_abbrev,"",%progbits
+.Ldebug_abbrev0:
+	.uleb128 0x1	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.byte	0
+	.byte	0
+	.uleb128 0x2	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 3	/* (/usr/include/getopt.h) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x3	/* (abbrev code) */
+	.uleb128 0xf	/* (TAG: DW_TAG_pointer_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 8
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0x4	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (main.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0x5	/* (abbrev code) */
+	.uleb128 0x5	/* (TAG: DW_TAG_formal_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 1	/* (main.c) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x21	/* (DW_FORM_implicit_const) */
+	.sleb128 6
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0x6	/* (abbrev code) */
+	.uleb128 0x11	/* (TAG: DW_TAG_compile_unit) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x25	/* (DW_AT_producer) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x13	/* (DW_AT_language) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x1b	/* (DW_AT_comp_dir) */
+	.uleb128 0x1f	/* (DW_FORM_line_strp) */
+	.uleb128 0x55	/* (DW_AT_ranges) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x10	/* (DW_AT_stmt_list) */
+	.uleb128 0x17	/* (DW_FORM_sec_offset) */
+	.byte	0
+	.byte	0
+	.uleb128 0x7	/* (abbrev code) */
+	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0xb	/* (DW_AT_byte_size) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3e	/* (DW_AT_encoding) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0x8	/* (DW_FORM_string) */
+	.byte	0
+	.byte	0
+	.uleb128 0x8	/* (abbrev code) */
+	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x5	/* (DW_FORM_data2) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0x9	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x49	/* (DW_AT_type) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x1	/* (DW_AT_sibling) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xa	/* (abbrev code) */
+	.uleb128 0x48	/* (TAG: DW_TAG_call_site) */
+	.byte	0x1	/* DW_children_yes */
+	.uleb128 0x7d	/* (DW_AT_call_return_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x7f	/* (DW_AT_call_origin) */
+	.uleb128 0x13	/* (DW_FORM_ref4) */
+	.byte	0
+	.byte	0
+	.uleb128 0xb	/* (abbrev code) */
+	.uleb128 0x49	/* (TAG: DW_TAG_call_site_parameter) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x2	/* (DW_AT_location) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7e	/* (DW_AT_call_value) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.byte	0
+	.byte	0
+	.uleb128 0xc	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x27	/* (DW_AT_prototyped) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x11	/* (DW_AT_low_pc) */
+	.uleb128 0x1	/* (DW_FORM_addr) */
+	.uleb128 0x12	/* (DW_AT_high_pc) */
+	.uleb128 0x7	/* (DW_FORM_data8) */
+	.uleb128 0x40	/* (DW_AT_frame_base) */
+	.uleb128 0x18	/* (DW_FORM_exprloc) */
+	.uleb128 0x7a	/* (DW_AT_call_all_calls) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.byte	0
+	.byte	0
+	.uleb128 0xd	/* (abbrev code) */
+	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
+	.byte	0	/* DW_children_no */
+	.uleb128 0x3f	/* (DW_AT_external) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x3c	/* (DW_AT_declaration) */
+	.uleb128 0x19	/* (DW_FORM_flag_present) */
+	.uleb128 0x6e	/* (DW_AT_linkage_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3	/* (DW_AT_name) */
+	.uleb128 0xe	/* (DW_FORM_strp) */
+	.uleb128 0x3a	/* (DW_AT_decl_file) */
+	.uleb128 0xb	/* (DW_FORM_data1) */
+	.uleb128 0x3b	/* (DW_AT_decl_line) */
+	.uleb128 0x5	/* (DW_FORM_data2) */
+	.byte	0
+	.byte	0
+	.byte	0
+	.section	.debug_loclists,"",%progbits
+	.4byte	.Ldebug_loc2-.Ldebug_loc1	/* Length of Location Lists */
+.Ldebug_loc1:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.4byte	0	/* Offset Entry Count */
+.Ldebug_loc0:
+.LLST0:
+	.byte	0x6	/* DW_LLE_base_address (*.LLST0) */
+	.8byte	0x1234	/* Base address (*.LLST0) */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST0) */
+	.uleb128 .LVL0-.LVL0	/* Location list begin address (*.LLST0) */
+	.uleb128 .LVL1-.LVL0	/* Location list end address (*.LLST0) */
+	.uleb128 0x1	/* Location expression size */
+	.byte	0x55	/* DW_OP_reg5 */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST0) */
+	.uleb128 .LVL1-.LVL0	/* Location list begin address (*.LLST0) */
+	.uleb128 .LFE1-.LVL0	/* Location list end address (*.LLST0) */
+	.uleb128 0x4	/* Location expression size */
+	.byte	0xa3	/* DW_OP_entry_value */
+	.uleb128 0x1
+	.byte	0x55	/* DW_OP_reg5 */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.byte	0	/* DW_LLE_end_of_list (*.LLST0) */
+.LLST1:
+	.byte	0x6	/* DW_LLE_base_address (*.LLST1) */
+	.8byte	0x1234	/* Base address (*.LLST1) */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST1) */
+	.uleb128 .LVL0-.LVL0	/* Location list begin address (*.LLST1) */
+	.uleb128 .LVL2-1-.LVL0	/* Location list end address (*.LLST1) */
+	.uleb128 0x1	/* Location expression size */
+	.byte	0x54	/* DW_OP_reg4 */
+	.byte	0x4	/* DW_LLE_offset_pair (*.LLST1) */
+	.uleb128 .LVL2-1-.LVL0	/* Location list begin address (*.LLST1) */
+	.uleb128 .LFE1-.LVL0	/* Location list end address (*.LLST1) */
+	.uleb128 0x4	/* Location expression size */
+	.byte	0xa3	/* DW_OP_entry_value */
+	.uleb128 0x1
+	.byte	0x54	/* DW_OP_reg4 */
+	.byte	0x9f	/* DW_OP_stack_value */
+	.byte	0	/* DW_LLE_end_of_list (*.LLST1) */
+.Ldebug_loc2:
+	.section	.debug_aranges,"",%progbits
+	.4byte	0x3c	/* Length of Address Ranges Info */
+	.2byte	0x2	/* DWARF Version */
+	.4byte	.Ldebug_info0	/* Offset of Compilation Unit Info */
+	.byte	0x8	/* Size of Address */
+	.byte	0	/* Size of Segment Descriptor */
+	.2byte	0	/* Pad to 16 byte boundary */
+	.2byte	0
+	.8byte	0x1234	/* Address */
+	.8byte	0x4567	/* Length */
+	.8byte	0x1234	/* Address */
+	.8byte	0x5678	/* Length */
+	.8byte	0
+	.8byte	0
+	.section	.debug_rnglists,"",%progbits
+.Ldebug_ranges0:
+	.4byte	.Ldebug_ranges3-.Ldebug_ranges2	/* Length of Range Lists */
+.Ldebug_ranges2:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.4byte	0	/* Offset Entry Count */
+.LLRL2:
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL2) */
+	.8byte	0x1234	/* Range begin address (*.LLRL2) */
+	.uleb128 .Letext0-.Ltext0	/* Range length (*.LLRL2) */
+	.byte	0x7	/* DW_RLE_start_length (*.LLRL2) */
+	.8byte	0x1234	/* Range begin address (*.LLRL2) */
+	.uleb128 .LFE1-.LFB1	/* Range length (*.LLRL2) */
+	.byte	0	/* DW_RLE_end_of_list (*.LLRL2) */
+.Ldebug_ranges3:
+	.section	.debug_line,"",%progbits
+.Ldebug_line0:
+	.4byte	.LELT0-.LSLT0	/* Length of Source Line Info */
+.LSLT0:
+	.2byte	0x5	/* DWARF Version */
+	.byte	0x8	/* Address Size */
+	.byte	0	/* Segment Size */
+	.4byte	.LELTP0-.LASLTP0	/* Prolog Length */
+.LASLTP0:
+	.byte	0x1	/* Minimum Instruction Length */
+	.byte	0x1	/* Maximum Operations Per Instruction */
+	.byte	0x1	/* Default is_stmt_start flag */
+	.byte	0xf6	/* Line Base Value (Special Opcodes) */
+	.byte	0xf2	/* Line Range Value (Special Opcodes) */
+	.byte	0xd	/* Special Opcode Base */
+	.byte	0	/* opcode: 0x1 has 0 args */
+	.byte	0x1	/* opcode: 0x2 has 1 args */
+	.byte	0x1	/* opcode: 0x3 has 1 args */
+	.byte	0x1	/* opcode: 0x4 has 1 args */
+	.byte	0x1	/* opcode: 0x5 has 1 args */
+	.byte	0	/* opcode: 0x6 has 0 args */
+	.byte	0	/* opcode: 0x7 has 0 args */
+	.byte	0	/* opcode: 0x8 has 0 args */
+	.byte	0x1	/* opcode: 0x9 has 1 args */
+	.byte	0	/* opcode: 0xa has 0 args */
+	.byte	0	/* opcode: 0xb has 0 args */
+	.byte	0x1	/* opcode: 0xc has 1 args */
+	.byte	0x1	/* Directory entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x3	/* Directories count */
+	.4byte	.LASF1	/* Directory Entry: 0: "" */
+	.4byte	.LASF25	/* Directory Entry: 0: "" */
+	.4byte	.LASF26	/* Directory Entry: 0: "/usr/include" */
+	.byte	0x2	/* File name entry format count */
+	.uleb128 0x1	/* DW_LNCT_path */
+	.uleb128 0x1f	/* DW_FORM_line_strp */
+	.uleb128 0x2	/* DW_LNCT_directory_index */
+	.uleb128 0xb	/* DW_FORM_data1 */
+	.uleb128 0x4	/* File names count */
+	.4byte	.LASF0	/* File Entry: 0: "main.c" */
+	.byte	0
+	.4byte	.LASF27	/* File Entry: 0: "main.c" */
+	.byte	0x1
+	.4byte	.LASF28	/* File Entry: 0: "unistd.h" */
+	.byte	0x2
+	.4byte	.LASF29	/* File Entry: 0: "getopt.h" */
+	.byte	0x2
+.LELTP0:
+	.byte	0	/* set address *.LM3 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0x1c	/* line 6 */
+	.byte	0	/* set address *.LM4 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x12346
+	.byte	0x1	/* copy line 6 */
+	.byte	0	/* set address *.LFE1 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+	.byte	0	/* set address *.LM1 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0x1b	/* line 5 */
+	.byte	0	/* set address *.LM2 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0x1	/* copy line 5 */
+	.byte	0	/* set address *.Letext0 */
+	.uleb128 0x9
+	.byte	0x2
+	.8byte	0x1234
+	.byte	0	/* end sequence */
+	.uleb128 0x1
+	.byte	0x1
+.LELT0:
+	.section	.debug_str,"MS",%progbits,1
+.LASF4:
+	.string	"unsigned int"
+.LASF15:
+	.string	"optopt"
+.LASF22:
+	.string	"main"
+.LASF6:
+	.string	"signed char"
+.LASF16:
+	.string	"xvar"
+.LASF5:
+	.string	"long unsigned int"
+.LASF14:
+	.string	"opterr"
+.LASF21:
+	.string	"GNU C11 7.0.1 20170218 (experimental) -mtune=generic -march=x86-64 -gdwarf-5 -O2"
+.LASF2:
+	.string	"unsigned char"
+.LASF10:
+	.string	"char"
+.LASF13:
+	.string	"optind"
+.LASF8:
+	.string	"long int"
+.LASF19:
+	.string	"argc"
+.LASF3:
+	.string	"short unsigned int"
+.LASF17:
+	.string	"yvar"
+.LASF18:
+	.string	"pvar"
+.LASF11:
+	.string	"__environ"
+.LASF23:
+	.string	"func"
+.LASF12:
+	.string	"optarg"
+.LASF7:
+	.string	"short int"
+.LASF24:
+	.string	"alarm"
+.LASF9:
+	.string	"sizetype"
+.LASF20:
+	.string	"argv"
+	.section	.debug_line_str,"MS",%progbits,1
+.LASF1:
+	.string	""
+.LASF25:
+	.string	""
+.LASF29:
+	.string	"getopt.h"
+.LASF28:
+	.string	"unistd.h"
+.LASF0:
+	.string	"main.c"
+.LASF27:
+	.string	"main.c"
+.LASF26:
+	.string	"/usr/include"
+	.ident	"GCC: (GNU) 7.0.1 20170218 (experimental)"
+	.section	.note.GNU-stack,"",%progbits
diff --git a/binutils/testsuite/binutils-all/dw5.W b/binutils/testsuite/binutils-all/dw5.W
new file mode 100644
index 0000000..6f3f8ef
--- /dev/null
+++ b/binutils/testsuite/binutils-all/dw5.W
@@ -0,0 +1,355 @@
+Contents of the .debug_info section:
+
+  Compilation Unit @ offset 0x0:
+   Length:        0x160 \(32-bit\)
+   Version:       5
+   Abbrev Offset: 0x0
+   Pointer Size:  8
+ <0><c>: Abbrev Number: 6 \(DW_TAG_compile_unit\)
+    <d>   DW_AT_producer    : \(indirect string, offset: 0x43\): GNU C11 7.0.1 20170218 \(experimental\) -mtune=generic -march=x86-64 -gdwarf-5 -O2
+    <11>   DW_AT_language    : 29	\(C11\)
+    <12>   DW_AT_name        : \(indirect line string, offset: 0x14\): main.c
+    <16>   DW_AT_comp_dir    : \(indirect line string, offset: 0x0\): 
+    <1a>   DW_AT_ranges      : 0xc
+    <1e>   DW_AT_low_pc      : 0x0
+    <26>   DW_AT_stmt_list   : 0x0
+ <1><2a>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <2b>   DW_AT_byte_size   : 1
+    <2c>   DW_AT_encoding    : 8	\(unsigned char\)
+    <2d>   DW_AT_name        : \(indirect string, offset: 0x94\): unsigned char
+ <1><31>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <32>   DW_AT_byte_size   : 2
+    <33>   DW_AT_encoding    : 7	\(unsigned\)
+    <34>   DW_AT_name        : \(indirect string, offset: 0xbc\): short unsigned int
+ <1><38>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <39>   DW_AT_byte_size   : 4
+    <3a>   DW_AT_encoding    : 7	\(unsigned\)
+    <3b>   DW_AT_name        : \(indirect string, offset: 0x0\): unsigned int
+ <1><3f>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <40>   DW_AT_byte_size   : 8
+    <41>   DW_AT_encoding    : 7	\(unsigned\)
+    <42>   DW_AT_name        : \(indirect string, offset: 0x2a\): long unsigned int
+ <1><46>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <47>   DW_AT_byte_size   : 1
+    <48>   DW_AT_encoding    : 6	\(signed char\)
+    <49>   DW_AT_name        : \(indirect string, offset: 0x19\): signed char
+ <1><4d>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <4e>   DW_AT_byte_size   : 2
+    <4f>   DW_AT_encoding    : 5	\(signed\)
+    <50>   DW_AT_name        : \(indirect string, offset: 0xef\): short int
+ <1><54>: Abbrev Number: 7 \(DW_TAG_base_type\)
+    <55>   DW_AT_byte_size   : 4
+    <56>   DW_AT_encoding    : 5	\(signed\)
+    <57>   DW_AT_name        : int
+ <1><5b>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <5c>   DW_AT_byte_size   : 8
+    <5d>   DW_AT_encoding    : 5	\(signed\)
+    <5e>   DW_AT_name        : \(indirect string, offset: 0xae\): long int
+ <1><62>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <63>   DW_AT_byte_size   : 8
+    <64>   DW_AT_encoding    : 7	\(unsigned\)
+    <65>   DW_AT_name        : \(indirect string, offset: 0xff\): sizetype
+ <1><69>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <6a>   DW_AT_byte_size   : 8
+    <6a>   DW_AT_type        : <0x6e>
+ <1><6e>: Abbrev Number: 1 \(DW_TAG_base_type\)
+    <6f>   DW_AT_byte_size   : 1
+    <70>   DW_AT_encoding    : 6	\(signed char\)
+    <71>   DW_AT_name        : \(indirect string, offset: 0xa2\): char
+ <1><75>: Abbrev Number: 8 \(DW_TAG_variable\)
+    <76>   DW_AT_name        : \(indirect string, offset: 0xd9\): __environ
+    <7a>   DW_AT_decl_file   : 2
+    <7b>   DW_AT_decl_line   : 546
+    <7d>   DW_AT_type        : <0x81>
+    <81>   DW_AT_external    : 1
+    <81>   DW_AT_declaration : 1
+ <1><81>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <82>   DW_AT_byte_size   : 8
+    <82>   DW_AT_type        : <0x69>
+ <1><86>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <87>   DW_AT_name        : \(indirect string, offset: 0xe8\): optarg
+    <8b>   DW_AT_decl_file   : 3
+    <8b>   DW_AT_decl_line   : 57
+    <8c>   DW_AT_type        : <0x69>
+    <90>   DW_AT_external    : 1
+    <90>   DW_AT_declaration : 1
+ <1><90>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <91>   DW_AT_name        : \(indirect string, offset: 0xa7\): optind
+    <95>   DW_AT_decl_file   : 3
+    <95>   DW_AT_decl_line   : 71
+    <96>   DW_AT_type        : <0x54>
+    <9a>   DW_AT_external    : 1
+    <9a>   DW_AT_declaration : 1
+ <1><9a>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <9b>   DW_AT_name        : \(indirect string, offset: 0x3c\): opterr
+    <9f>   DW_AT_decl_file   : 3
+    <9f>   DW_AT_decl_line   : 76
+    <a0>   DW_AT_type        : <0x54>
+    <a4>   DW_AT_external    : 1
+    <a4>   DW_AT_declaration : 1
+ <1><a4>: Abbrev Number: 2 \(DW_TAG_variable\)
+    <a5>   DW_AT_name        : \(indirect string, offset: 0xd\): optopt
+    <a9>   DW_AT_decl_file   : 3
+    <a9>   DW_AT_decl_line   : 80
+    <aa>   DW_AT_type        : <0x54>
+    <ae>   DW_AT_external    : 1
+    <ae>   DW_AT_declaration : 1
+ <1><ae>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <af>   DW_AT_name        : \(indirect string, offset: 0x25\): xvar
+    <b3>   DW_AT_decl_file   : 1
+    <b3>   DW_AT_decl_line   : 2
+    <b4>   DW_AT_type        : <0x54>
+    <b8>   DW_AT_external    : 1
+    <b8>   DW_AT_location    : 9 byte block: 3 (0|34) (0|12) 0 0 0 0 (0|12) (0|34) 	\(DW_OP_addr: 1234\)
+ <1><c2>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <c3>   DW_AT_name        : \(indirect string, offset: 0xcf\): yvar
+    <c7>   DW_AT_decl_file   : 1
+    <c7>   DW_AT_decl_line   : 3
+    <c8>   DW_AT_type        : <0x54>
+    <cc>   DW_AT_external    : 1
+    <cc>   DW_AT_location    : 9 byte block: 3 (0|34) (0|12) 0 0 0 0 (0|12) (0|34) 	\(DW_OP_addr: 1234\)
+ <1><d6>: Abbrev Number: 4 \(DW_TAG_variable\)
+    <d7>   DW_AT_name        : \(indirect string, offset: 0xd4\): pvar
+    <db>   DW_AT_decl_file   : 1
+    <db>   DW_AT_decl_line   : 4
+    <dc>   DW_AT_type        : <0xea>
+    <e0>   DW_AT_external    : 1
+    <e0>   DW_AT_location    : 9 byte block: 3 (0|34) (0|12) 0 0 0 0 (0|12) (0|34) 	\(DW_OP_addr: 1234\)
+ <1><ea>: Abbrev Number: 3 \(DW_TAG_pointer_type\)
+    <eb>   DW_AT_byte_size   : 8
+    <eb>   DW_AT_type        : <0x54>
+ <1><ef>: Abbrev Number: 9 \(DW_TAG_subprogram\)
+    <f0>   DW_AT_external    : 1
+    <f0>   DW_AT_name        : \(indirect string, offset: 0x14\): main
+    <f4>   DW_AT_decl_file   : 1
+    <f5>   DW_AT_decl_line   : 6
+    <f6>   DW_AT_prototyped  : 1
+    <f6>   DW_AT_type        : <0x54>
+    <fa>   DW_AT_low_pc      : 0x1234
+    <102>   DW_AT_high_pc     : 0x5678
+    <10a>   DW_AT_frame_base  : 1 byte block: 9c 	\(DW_OP_call_frame_cfa\)
+    <10c>   DW_AT_call_all_calls: 1
+    <10c>   DW_AT_sibling     : <0x13e>
+ <2><110>: Abbrev Number: 5 \(DW_TAG_formal_parameter\)
+    <111>   DW_AT_name        : \(indirect string, offset: 0xb7\): argc
+    <115>   DW_AT_decl_file   : 1
+    <115>   DW_AT_decl_line   : 6
+    <115>   DW_AT_type        : <0x54>
+    <119>   DW_AT_location    : 0xc \(location list\)
+ <2><11d>: Abbrev Number: 5 \(DW_TAG_formal_parameter\)
+    <11e>   DW_AT_name        : \(indirect string, offset: 0x108\): argv
+    <122>   DW_AT_decl_file   : 1
+    <122>   DW_AT_decl_line   : 6
+    <122>   DW_AT_type        : <0x81>
+    <126>   DW_AT_location    : 0x23 \(location list\)
+ <2><12a>: Abbrev Number: 10 \(DW_TAG_call_site\)
+    <12b>   DW_AT_call_return_pc: 0x12345
+    <133>   DW_AT_call_origin : <0x157>
+ <3><137>: Abbrev Number: 11 \(DW_TAG_call_site_parameter\)
+    <138>   DW_AT_location    : 1 byte block: 55 	\(DW_OP_reg5 \([^()]*\)\)
+    <13a>   DW_AT_call_value  : 1 byte block: 30 	\(DW_OP_lit0\)
+ <3><13c>: Abbrev Number: 0
+ <2><13d>: Abbrev Number: 0
+ <1><13e>: Abbrev Number: 12 \(DW_TAG_subprogram\)
+    <13f>   DW_AT_external    : 1
+    <13f>   DW_AT_name        : \(indirect string, offset: 0xe3\): func
+    <143>   DW_AT_decl_file   : 1
+    <144>   DW_AT_decl_line   : 5
+    <145>   DW_AT_prototyped  : 1
+    <145>   DW_AT_low_pc      : 0x1234
+    <14d>   DW_AT_high_pc     : 0x5678
+    <155>   DW_AT_frame_base  : 1 byte block: 9c 	\(DW_OP_call_frame_cfa\)
+    <157>   DW_AT_call_all_calls: 1
+ <1><157>: Abbrev Number: 13 \(DW_TAG_subprogram\)
+    <158>   DW_AT_external    : 1
+    <158>   DW_AT_declaration : 1
+    <158>   DW_AT_linkage_name: \(indirect string, offset: 0xf9\): alarm
+    <15c>   DW_AT_name        : \(indirect string, offset: 0xf9\): alarm
+    <160>   DW_AT_decl_file   : 2
+    <161>   DW_AT_decl_line   : 435
+ <1><163>: Abbrev Number: 0
+
+Contents of the .debug_abbrev section:
+
+  Number TAG \(0x0\)
+   1      DW_TAG_base_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_data1
+    DW_AT_encoding     DW_FORM_data1
+    DW_AT_name         DW_FORM_strp
+    DW_AT value: 0     DW_FORM value: 0
+   2      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 3
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   3      DW_TAG_pointer_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_implicit_const: 8
+    DW_AT_type         DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   4      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_location     DW_FORM_exprloc
+    DW_AT value: 0     DW_FORM value: 0
+   5      DW_TAG_formal_parameter    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_implicit_const: 1
+    DW_AT_decl_line    DW_FORM_implicit_const: 6
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_location     DW_FORM_sec_offset
+    DW_AT value: 0     DW_FORM value: 0
+   6      DW_TAG_compile_unit    \[has children\]
+    DW_AT_producer     DW_FORM_strp
+    DW_AT_language     DW_FORM_data1
+    DW_AT_name         DW_FORM_line_strp
+    DW_AT_comp_dir     DW_FORM_line_strp
+    DW_AT_ranges       DW_FORM_sec_offset
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_stmt_list    DW_FORM_sec_offset
+    DW_AT value: 0     DW_FORM value: 0
+   7      DW_TAG_base_type    \[no children\]
+    DW_AT_byte_size    DW_FORM_data1
+    DW_AT_encoding     DW_FORM_data1
+    DW_AT_name         DW_FORM_string
+    DW_AT value: 0     DW_FORM value: 0
+   8      DW_TAG_variable    \[no children\]
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data2
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   9      DW_TAG_subprogram    \[has children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_prototyped   DW_FORM_flag_present
+    DW_AT_type         DW_FORM_ref4
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_high_pc      DW_FORM_data8
+    DW_AT_frame_base   DW_FORM_exprloc
+    DW_AT_call_all_calls DW_FORM_flag_present
+    DW_AT_sibling      DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   10      DW_TAG_call_site    \[has children\]
+    DW_AT_call_return_pc DW_FORM_addr
+    DW_AT_call_origin  DW_FORM_ref4
+    DW_AT value: 0     DW_FORM value: 0
+   11      DW_TAG_call_site_parameter    \[no children\]
+    DW_AT_location     DW_FORM_exprloc
+    DW_AT_call_value   DW_FORM_exprloc
+    DW_AT value: 0     DW_FORM value: 0
+   12      DW_TAG_subprogram    \[no children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data1
+    DW_AT_prototyped   DW_FORM_flag_present
+    DW_AT_low_pc       DW_FORM_addr
+    DW_AT_high_pc      DW_FORM_data8
+    DW_AT_frame_base   DW_FORM_exprloc
+    DW_AT_call_all_calls DW_FORM_flag_present
+    DW_AT value: 0     DW_FORM value: 0
+   13      DW_TAG_subprogram    \[no children\]
+    DW_AT_external     DW_FORM_flag_present
+    DW_AT_declaration  DW_FORM_flag_present
+    DW_AT_linkage_name DW_FORM_strp
+    DW_AT_name         DW_FORM_strp
+    DW_AT_decl_file    DW_FORM_data1
+    DW_AT_decl_line    DW_FORM_data2
+    DW_AT value: 0     DW_FORM value: 0
+#...
+Contents of the .debug_loclists section:
+#...
+    Offset   Begin            End              Expression
+    0000000c 0000000000001234 \(base address\)
+    00000015 0000000000001234 0000000000001236 \(DW_OP_reg5 \([^()]*\)\)
+    0000001a 0000000000001236 0000000000001239 \(DW_OP_entry_value: \(DW_OP_reg5 \([^()]*\)\); DW_OP_stack_value\)
+    00000022 <End of list>
+    00000023 0000000000001234 \(base address\)
+    0000002c 0000000000001234 0000000000001236 \(DW_OP_reg4 \([^()]*\)\)
+    00000031 0000000000001236 0000000000001239 \(DW_OP_entry_value: \(DW_OP_reg4 \([^()]*\)\); DW_OP_stack_value\)
+    00000039 <End of list>
+
+Contents of the .debug_rnglists section:
+
+    Offset   Begin    End
+    0000000c 0000000000001234 0000000000001236 
+    00000016 0000000000001234 0000000000001239 
+    00000020 <End of list>
+
+Raw dump of debug contents of section .debug_line:
+
+  Offset:                      0x0
+  Length:                      144
+  DWARF Version:               5
+  Prologue Length:             60
+  Minimum Instruction Length:  1
+  Maximum Ops per Instruction: 1
+  Initial value of 'is_stmt':  1
+  Line Base:                   -10
+  Line Range:                  242
+  Opcode Base:                 13
+
+ Opcodes:
+  Opcode 1 has 0 args
+  Opcode 2 has 1 args
+  Opcode 3 has 1 args
+  Opcode 4 has 1 args
+  Opcode 5 has 1 args
+  Opcode 6 has 0 args
+  Opcode 7 has 0 args
+  Opcode 8 has 0 args
+  Opcode 9 has 1 args
+  Opcode 10 has 0 args
+  Opcode 11 has 0 args
+  Opcode 12 has 1 args
+
+ The Directory Table \(offset 0x22\):
+  Entry	Name
+  0	\(indirect line string, offset: 0x0\): 
+  1	\(indirect line string, offset: 0x1\): 
+  2	\(indirect line string, offset: 0x22\): /usr/include
+
+ The File name Table \(offset 0x34\):
+  Entry	Dir	Name
+  0	0	\(indirect line string, offset: 0x14\): main.c
+  1	1	\(indirect line string, offset: 0x1b\): main.c
+  2	2	\(indirect line string, offset: 0xb\): unistd.h
+  3	2	\(indirect line string, offset: 0x2\): getopt.h
+
+ Line Number Statements:
+  \[0x00000048\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000053\]  Special opcode 15: advance Address by 0 to 0x1234 and Line by 5 to 6
+  \[0x00000054\]  Extended opcode 2: set Address to 0x12346
+  \[0x0000005f\]  Copy
+  \[0x00000060\]  Extended opcode 2: set Address to 0x1234
+  \[0x0000006b\]  Extended opcode 1: End of Sequence
+
+  \[0x0000006e\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000079\]  Special opcode 14: advance Address by 0 to 0x1234 and Line by 4 to 5
+  \[0x0000007a\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000085\]  Copy
+  \[0x00000086\]  Extended opcode 2: set Address to 0x1234
+  \[0x00000091\]  Extended opcode 1: End of Sequence
+
+
+Decoded dump of debug contents of section .debug_line:
+
+CU: ./main.c:
+File name                            Line number    Starting address
+main.c                                         6              0x1234
+main.c                                         6             0x12346
+
+main.c                                         5              0x1234
+main.c                                         5              0x1234
+
+
diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsuite/binutils-all/readelf.exp
index e442bdf..10f2b7a 100644
--- a/binutils/testsuite/binutils-all/readelf.exp
+++ b/binutils/testsuite/binutils-all/readelf.exp
@@ -394,3 +394,28 @@ if {![binutils_assemble $srcdir/$subdir/z.s tmpdir/z.o]} then {
 
     readelf_test {--decompress --hex-dump .debug_loc} $tempfile readelf.z  {}
 }
+
+# Skip the next test for the RISCV architectures because they do not
+# support .ULEB128 pseudo-ops with non-constant values.
+if ![istarget "riscv*-*-*"] then {
+
+    # Assemble the DWARF-5 test file.
+    if {![binutils_assemble $srcdir/$subdir/dw5.S tmpdir/dw5.o]} then {
+	perror "could not assemble dw5 test file"
+	unresolved "readelf - failed to assemble dw5"
+	return
+    }
+
+    # Download it.
+    if ![is_remote host] {
+	set tempfile tmpdir/dw5.o
+    } else {
+	set tempfile [remote_download host tmpdir/dw5.o]
+    }
+
+    # First, determine the size, so specific output matchers can be used.
+    readelf_find_size $tempfile
+
+    # Make sure that readelf can decode the contents.
+    readelf_test -wiaoRlL $tempfile dw5.W {}
+}
-- 
2.9.3

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [commit] [PATCH 3/6] DWARF-5 basic functionality
  2017-02-23 22:12     ` [commit] [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
@ 2017-02-27 21:58       ` Maciej W. Rozycki
  2017-02-27 22:24         ` [obv] DWARF-5: Fix compilation with GCC 4.4.7 [Re: [commit] [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
  0 siblings, 1 reply; 32+ messages in thread
From: Maciej W. Rozycki @ 2017-02-27 21:58 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Nick Clifton, binutils, Victor Leschuk

On Thu, 23 Feb 2017, Jan Kratochvil wrote:

> > The SAFE_BYTE_GET_AND_INC macro will trigger a runtime abort if this
> > code is compiled for a 32-bit host (where sizeof base_address == 4) and
> > run on DWARF5 information created for a 64-bit target (where 
> > pointer_size == 8).
> 
> So this is now fixed by checked-in:
> 	[patch] dwarf.c: Use more dwarf_vma
> 
> Checked in as: 77145576fadc4dd2879adf5242b610ebbe30ec30

 This has caused:

cc1: warnings being treated as errors
.../binutils/dwarf.c: In function 'display_debug_rnglists_list':
.../binutils/dwarf.c:5876: error: 'begin' may be used uninitialized in this function
.../binutils/dwarf.c:5876: error: 'end' may be used uninitialized in this function
.../binutils/dwarf.c: In function 'display_loclists_list':
.../binutils/dwarf.c:5014: error: 'begin' may be used uninitialized in this function
.../binutils/dwarf.c:5015: error: 'end' may be used uninitialized in this function
make[4]: *** [dwarf.o] Error 1

(with GCC 4.4.7 and "-g -O -fno-inline"); line numbers as per current 
master.

  Maciej

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [obv] DWARF-5: Fix compilation with GCC 4.4.7  [Re: [commit] [PATCH 3/6] DWARF-5 basic functionality]
  2017-02-27 21:58       ` Maciej W. Rozycki
@ 2017-02-27 22:24         ` Jan Kratochvil
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kratochvil @ 2017-02-27 22:24 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Nick Clifton, binutils, Victor Leschuk

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

On Mon, 27 Feb 2017 22:58:28 +0100, Maciej W. Rozycki wrote:
> cc1: warnings being treated as errors
> .../binutils/dwarf.c: In function 'display_debug_rnglists_list':
> .../binutils/dwarf.c:5876: error: 'begin' may be used uninitialized in this function
> .../binutils/dwarf.c:5876: error: 'end' may be used uninitialized in this function
> .../binutils/dwarf.c: In function 'display_loclists_list':
> .../binutils/dwarf.c:5014: error: 'begin' may be used uninitialized in this function
> .../binutils/dwarf.c:5015: error: 'end' may be used uninitialized in this function
> make[4]: *** [dwarf.o] Error 1
> 
> (with GCC 4.4.7 and "-g -O -fno-inline"); line numbers as per current 
> master.

Checked in as obvious.


Thanks,
Jan

[-- Attachment #2: Type: message/rfc822, Size: 1722 bytes --]

From: Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: [PATCH] Fix compilation with GCC 4.4.7.
Date: Mon, 27 Feb 2017 23:22:53 +0100

binutils/
2017-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix compilation with GCC 4.4.7.
	* dwarf.c (display_loclists_list, display_debug_rnglists_list):
	Initialize begin and end.
---
 binutils/ChangeLog | 6 ++++++
 binutils/dwarf.c   | 8 +++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 4c78f79..21ae4af 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Fix compilation with GCC 4.4.7.
+	* dwarf.c (display_loclists_list, display_debug_rnglists_list):
+	Initialize begin and end.
+
 2017-02-27  Rudy Y  <rudyy.id@gmail.com>
 
 	PR 20881
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 86a8385..ad0bfcf 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -5011,8 +5011,9 @@ display_loclists_list (struct dwarf_section *section,
   int dwarf_version;
   unsigned int bytes_read;
 
-  dwarf_vma begin;
-  dwarf_vma end;
+  /* Initialize it due to a false compiler warning.  */
+  dwarf_vma begin = -1;
+  dwarf_vma end = -1;
   dwarf_vma length;
   int need_frame_base;
 
@@ -5873,7 +5874,8 @@ display_debug_rnglists_list (unsigned char *start, unsigned char *finish,
     {
       unsigned long off = offset + (start - next);
       enum dwarf_range_list_entry rlet;
-      dwarf_vma begin, length, end;
+      /* Initialize it due to a false compiler warning.  */
+      dwarf_vma begin = -1, length, end = -1;
       unsigned int bytes_read;
 
       if (start + 1 > finish)
-- 
2.9.3

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2017-02-27 22:24 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 22:58 [PATCH 1/6] DWARF attrs: add delimiter Jan Kratochvil
2017-02-15 22:58 ` [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
2017-02-22 11:36   ` Nick Clifton
2017-02-22 18:42     ` Jan Kratochvil
2017-02-22 11:47   ` Nick Clifton
2017-02-22 19:13     ` [patch] dwarf.c: Use more dwarf_vma [Re: [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
2017-02-23 16:34       ` Nick Clifton
2017-02-23 16:35       ` Nick Clifton
2017-02-23 20:38         ` [commit] " Jan Kratochvil
2017-02-23 22:12     ` [commit] [PATCH 3/6] DWARF-5 basic functionality Jan Kratochvil
2017-02-27 21:58       ` Maciej W. Rozycki
2017-02-27 22:24         ` [obv] DWARF-5: Fix compilation with GCC 4.4.7 [Re: [commit] [PATCH 3/6] DWARF-5 basic functionality] Jan Kratochvil
2017-02-15 22:58 ` [PATCH 4/6] DWARF-5: call sites Jan Kratochvil
2017-02-22 11:49   ` Nick Clifton
2017-02-23 22:12     ` [commit] " Jan Kratochvil
2017-02-15 22:58 ` [PATCH 2/6] Display user op byte Jan Kratochvil
2017-02-22 11:30   ` Nick Clifton
2017-02-22 19:24     ` [commit] " Jan Kratochvil
2017-02-15 22:58 ` [PATCH 6/6] DWARF-5: DW_FORM_data16 Jan Kratochvil
2017-02-22 11:51   ` Nick Clifton
2017-02-23 22:13     ` [commit] " Jan Kratochvil
2017-02-15 22:58 ` [PATCH 5/6] DWARF-5: Macros Jan Kratochvil
2017-02-22 11:50   ` Nick Clifton
2017-02-23 22:13     ` [commit] " Jan Kratochvil
2017-02-16 10:59 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
2017-02-16 20:13   ` Jan Kratochvil
2017-02-17  8:37     ` Nick Clifton
2017-02-18 19:47       ` [patch] DWARF-5: testcase [Re: [PATCH 1/6] DWARF attrs: add delimiter] Jan Kratochvil
2017-02-21  9:44         ` Nick Clifton
2017-02-23 22:17           ` [commit] [patch] DWARF-5: testcase Jan Kratochvil
2017-02-22 11:48 ` [PATCH 1/6] DWARF attrs: add delimiter Nick Clifton
2017-02-23 22:08   ` [commit] " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).