public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Make dwarf_vma uint64_t
@ 2022-08-13  6:43 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-08-13  6:43 UTC (permalink / raw)
  To: binutils

This replaces dwarf_vma, dwarf_size_type and dwarf_signed_vma with
uint64_t and int64_t everywhere.  The patch also gets rid of
DWARF_VMA_FMT since we can't use that with uint64_t, and all of the
configure support for deciding the flavour of HOST_WIDEST_INT.
dwarf_vmatoa also disappears, replacing most uses with one of
PRIx64, PRId64 or PRIu64.  Printing of size_t and ptrdiff_t values
now use %z and %t rather than by casting to unsigned long.  Also,
most warning messages that used 0x%lx or similar now use %#lx and a
few that didn't print the 0x hex prefix now also use %#.  The patch
doesn't change normal readelf output, except in odd cases where values
previously might have been truncated.

diff --git a/binutils/config.in b/binutils/config.in
index 131f09b4212..c5fb919aa95 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -185,12 +185,6 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* The size of `long', as computed by sizeof. */
-#undef SIZEOF_LONG
-
-/* The size of `long long', as computed by sizeof. */
-#undef SIZEOF_LONG_LONG
-
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
diff --git a/binutils/configure b/binutils/configure
index ddb3020b3c9..542c832be18 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -1980,189 +1980,6 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
-# --------------------------------------------
-# Tries to find the compile-time value of EXPR in a program that includes
-# INCLUDES, setting VAR accordingly. Returns whether the value could be
-# computed
-ac_fn_c_compute_int ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if test "$cross_compiling" = yes; then
-    # Depending upon the size, compute the lo and hi bounds.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) >= 0)];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_lo=0 ac_mid=0
-  while :; do
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_hi=$ac_mid; break
-else
-  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
-			if test $ac_lo -le $ac_mid; then
-			  ac_lo= ac_hi=
-			  break
-			fi
-			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) < 0)];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_hi=-1 ac_mid=-1
-  while :; do
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) >= $ac_mid)];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_lo=$ac_mid; break
-else
-  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
-			if test $ac_mid -le $ac_hi; then
-			  ac_lo= ac_hi=
-			  break
-			fi
-			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-  done
-else
-  ac_lo= ac_hi=
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
-  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-static int test_array [1 - 2 * !(($2) <= $ac_mid)];
-test_array [0] = 0;
-return test_array [0];
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_hi=$ac_mid
-else
-  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in #((
-?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
-'') ac_retval=1 ;;
-esac
-  else
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-static long int longval () { return $2; }
-static unsigned long int ulongval () { return $2; }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
-  FILE *f = fopen ("conftest.val", "w");
-  if (! f)
-    return 1;
-  if (($2) < 0)
-    {
-      long int i = longval ();
-      if (i != ($2))
-	return 1;
-      fprintf (f, "%ld", i);
-    }
-  else
-    {
-      unsigned long int i = ulongval ();
-      if (i != ($2))
-	return 1;
-      fprintf (f, "%lu", i);
-    }
-  /* Do not output a trailing newline, as this causes \r\n confusion
-     on some platforms.  */
-  return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
-else
-  ac_retval=1
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-rm -f conftest.val
-
-  fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_compute_int
-
 # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
 # ----------------------------------------------------
 # Tries to find if the field MEMBER exists in type AGGR, after including
@@ -10987,7 +10804,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10990 "configure"
+#line 10807 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11093,7 +10910,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11096 "configure"
+#line 10913 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13024,73 +12841,6 @@ case "${host}" in
 esac
 
 
-# The cast to long int works around a bug in the HP C Compiler
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-# This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
-$as_echo_n "checking size of long... " >&6; }
-if ${ac_cv_sizeof_long+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"; then :
-
-else
-  if test "$ac_cv_type_long" = yes; then
-     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute sizeof (long)
-See \`config.log' for more details" "$LINENO" 5; }
-   else
-     ac_cv_sizeof_long=0
-   fi
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
-$as_echo "$ac_cv_sizeof_long" >&6; }
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG $ac_cv_sizeof_long
-_ACEOF
-
-
-# The cast to long int works around a bug in the HP C Compiler
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
-# This bug is HP SR number 8606223364.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
-$as_echo_n "checking size of long long... " >&6; }
-if ${ac_cv_sizeof_long_long+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long"        "$ac_includes_default"; then :
-
-else
-  if test "$ac_cv_type_long_long" = yes; then
-     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute sizeof (long long)
-See \`config.log' for more details" "$LINENO" 5; }
-   else
-     ac_cv_sizeof_long_long=0
-   fi
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
-$as_echo "$ac_cv_sizeof_long_long" >&6; }
-
-
-
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
-_ACEOF
-
-
-
 # We use headers from include/ that check various HAVE_*_H macros, thus
 # should ensure they are set by configure.  This is true even when C99
 # guarantees they are available.
diff --git a/binutils/configure.ac b/binutils/configure.ac
index 50dac4ee8f4..ec002d3f88f 100644
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -174,9 +174,6 @@ case "${host}" in
 esac
 AC_SUBST(DEMANGLER_NAME)
 
-AC_CHECK_SIZEOF([long])
-AC_CHECK_SIZEOF([long long])
-
 # We use headers from include/ that check various HAVE_*_H macros, thus
 # should ensure they are set by configure.  This is true even when C99
 # guarantees they are available.
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index fdbe1280ac6..a20d546e210 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -76,7 +76,7 @@ typedef struct dwo_info
 {
   dwo_type          type;
   const char *      value;
-  dwarf_vma         cu_offset;
+  uint64_t          cu_offset;
   struct dwo_info * next;
 } dwo_info;
 
@@ -119,10 +119,6 @@ unsigned long dwarf_start_die;
 
 int dwarf_check = 0;
 
-/* Convenient constant, to avoid having to cast -1 to dwarf_vma when
-   testing whether e.g. a locview list is present.  */
-static const dwarf_vma vm1 = -1;
-
 /* Collection of CU/TU section sets from .debug_cu_index and .debug_tu_index
    sections.  For version 1 package files, each set is stored in SHNDX_POOL
    as a zero-terminated list of section indexes comprising one set of debug
@@ -140,9 +136,9 @@ static unsigned int shndx_pool_used = 0;
 
 struct cu_tu_set
 {
-  uint64_t   signature;
-  dwarf_vma  section_offsets[DW_SECT_MAX];
-  size_t     section_sizes[DW_SECT_MAX];
+  uint64_t signature;
+  uint64_t section_offsets[DW_SECT_MAX];
+  size_t   section_sizes[DW_SECT_MAX];
 };
 
 static int cu_count = 0;
@@ -175,7 +171,7 @@ size_of_encoded_value (int encoding)
     }
 }
 
-static dwarf_vma
+static uint64_t
 get_encoded_value (unsigned char **pdata,
 		   int encoding,
 		   struct dwarf_section *section,
@@ -183,7 +179,7 @@ get_encoded_value (unsigned char **pdata,
 {
   unsigned char * data = * pdata;
   unsigned int size = size_of_encoded_value (encoding);
-  dwarf_vma val;
+  uint64_t val;
 
   if (data >= end || size > (size_t) (end - data))
     {
@@ -220,98 +216,43 @@ get_encoded_value (unsigned char **pdata,
   return val;
 }
 
-#if SIZEOF_LONG_LONG > SIZEOF_LONG
-# ifndef __MINGW32__
-#  define DWARF_VMA_FMT		"ll"
-#  define DWARF_VMA_FMT_LONG	"%16.16llx"
-# else
-#  define DWARF_VMA_FMT		"I64"
-#  define DWARF_VMA_FMT_LONG	"%016I64x"
-# endif
-#else
-# define DWARF_VMA_FMT		"l"
-# define DWARF_VMA_FMT_LONG	"%16.16lx"
-#endif
-
-/* Convert a dwarf vma value into a string.  Returns a pointer to a static
-   buffer containing the converted VALUE.  The value is converted according
-   to the printf formating character FMTCH.  If NUM_BYTES is non-zero then
-   it specifies the maximum number of bytes to be displayed in the converted
-   value and FMTCH is ignored - hex is always used.  */
+/* Print a uint64_t value (typically an address, offset or length) in
+   hexadecimal format, followed by a space.  The precision displayed is
+   determined by the NUM_BYTES parameter.  */
 
-static const char *
-dwarf_vmatoa_1 (const char *fmtch, dwarf_vma value, unsigned num_bytes)
+static void
+print_hex (uint64_t value, unsigned num_bytes)
 {
-  /* As dwarf_vmatoa is used more then once in a printf call
-     for output, we are cycling through a fixed array of pointers
-     for return address.  */
-  static int buf_pos = 0;
-  static struct dwarf_vmatoa_buf
-  {
-    char place[64];
-  } buf[16];
-  char *ret;
-
-  ret = buf[buf_pos++].place;
-  buf_pos %= ARRAY_SIZE (buf);
-
-  if (num_bytes)
-    {
-      /* Printf does not have a way of specifying a maximum field width for an
-	 integer value, so we print the full value into a buffer and then select
-	 the precision we need.  */
-      snprintf (ret, sizeof (buf[0].place), DWARF_VMA_FMT_LONG, value);
-      if (num_bytes > 8)
-	num_bytes = 8;
-      return ret + (16 - 2 * num_bytes);
-    }
-  else
-    {
-      char fmt[32];
+  if (num_bytes == 0)
+    num_bytes = 2;
 
-      if (fmtch)
-	sprintf (fmt, "%%%s%s", DWARF_VMA_FMT, fmtch);
-      else
-	sprintf (fmt, "%%%s", DWARF_VMA_FMT);
-      snprintf (ret, sizeof (buf[0].place), fmt, value);
-      return ret;
-    }
-}
-
-static inline const char *
-dwarf_vmatoa (const char * fmtch, dwarf_vma value)
-{
-  return dwarf_vmatoa_1 (fmtch, value, 0);
+  printf ("%0*" PRIx64 " ", num_bytes * 2,
+	  value & ~(~(uint64_t) 0 << num_bytes * 4 << num_bytes * 4));
 }
 
-/* Print a dwarf_vma value (typically an address, offset or length) in
-   hexadecimal format, followed by a space.  The length of the VALUE (and
-   hence the precision displayed) is determined by the NUM_BYTES parameter.  */
+/* Like print_hex, but no trailing space.  */
 
 static void
-print_dwarf_vma (dwarf_vma value, unsigned num_bytes)
+print_hex_ns (uint64_t value, unsigned num_bytes)
 {
-  printf ("%s ", dwarf_vmatoa_1 (NULL, value, num_bytes));
+  if (num_bytes == 0)
+    num_bytes = 2;
+
+  printf ("%0*" PRIx64, num_bytes * 2,
+	  value & ~(~(uint64_t) 0 << num_bytes * 4 << num_bytes * 4));
 }
 
-/* Print a view number in hexadecimal value, with the same width
-   print_dwarf_vma would have printed it with the same num_bytes.
-   Print blanks for zero view, unless force is nonzero.  */
+/* Print a view number in hexadecimal value, with the same width as
+   print_hex would have printed it.  */
 
 static void
-print_dwarf_view (dwarf_vma value, unsigned num_bytes, int force)
+print_view (uint64_t value, unsigned num_bytes)
 {
-  int len;
-  if (!num_bytes)
-    len = 4;
-  else
-    len = num_bytes * 2;
+  if (num_bytes == 0)
+    num_bytes = 2;
 
-  assert (value == (unsigned long) value);
-  if (value || force)
-    printf ("v%0*lx ", len - 1, (unsigned long) value);
-  else
-    printf ("%*s", len + 1, "");
+  printf ("v%0*" PRIx64 " ", num_bytes * 2 - 1,
+	  value & ~(~(uint64_t) 0 << num_bytes * 4 << num_bytes * 4));
 }
 
 /* Read in a LEB128 encoded value starting at address DATA.
@@ -319,17 +260,17 @@ print_dwarf_view (dwarf_vma value, unsigned num_bytes, int force)
    If LENGTH_RETURN is not NULL, return in it the number of bytes read.
    If STATUS_RETURN is not NULL, return with bit 0 (LSB) set if the
    terminating byte was not found and with bit 1 set if the value
-   overflows a dwarf_vma.
+   overflows a uint64_t.
    No bytes will be read at address END or beyond.  */
 
-dwarf_vma
+uint64_t
 read_leb128 (unsigned char *data,
 	     const unsigned char *const end,
 	     bool sign,
 	     unsigned int *length_return,
 	     int *status_return)
 {
-  dwarf_vma result = 0;
+  uint64_t result = 0;
   unsigned int num_read = 0;
   unsigned int shift = 0;
   int status = 1;
@@ -343,11 +284,11 @@ read_leb128 (unsigned char *data,
 
       if (shift < CHAR_BIT * sizeof (result))
 	{
-	  result |= ((dwarf_vma) (byte & 0x7f)) << shift;
+	  result |= ((uint64_t) (byte & 0x7f)) << shift;
 	  /* These bits overflowed.  */
 	  lost = byte ^ (result >> shift);
 	  /* And this is the mask of possible overflow bits.  */
-	  mask = 0x7f ^ ((dwarf_vma) 0x7f << shift >> shift);
+	  mask = 0x7f ^ ((uint64_t) 0x7f << shift >> shift);
 	  shift += 7;
 	}
       else
@@ -355,14 +296,14 @@ read_leb128 (unsigned char *data,
 	  lost = byte;
 	  mask = 0x7f;
 	}
-      if ((lost & mask) != (sign && (dwarf_signed_vma) result < 0 ? mask : 0))
+      if ((lost & mask) != (sign && (int64_t) result < 0 ? mask : 0))
 	status |= 2;
 
       if ((byte & 0x80) == 0)
 	{
 	  status &= ~1;
 	  if (sign && shift < CHAR_BIT * sizeof (result) && (byte & 0x40))
-	    result |= -((dwarf_vma) 1 << shift);
+	    result |= -((uint64_t) 1 << shift);
 	  break;
 	}
     }
@@ -427,7 +368,7 @@ read_leb128 (unsigned char *data,
 
 typedef struct State_Machine_Registers
 {
-  dwarf_vma address;
+  uint64_t address;
   unsigned int view;
   unsigned int file;
   unsigned int line;
@@ -470,7 +411,7 @@ process_extended_line_op (unsigned char * data,
   size_t len, header_len;
   unsigned char *name;
   unsigned char *orig_data = data;
-  dwarf_vma adr, val;
+  uint64_t adr, val;
 
   READ_ULEB (len, data, end);
   header_len = data - orig_data;
@@ -496,13 +437,13 @@ process_extended_line_op (unsigned char * data,
       /* PR 17512: file: 002-100480-0.004.  */
       if (len - 1 > 8)
 	{
-	  warn (_("Length (%lu) of DW_LNE_set_address op is too long\n"),
-		(unsigned long) len - 1);
+	  warn (_("Length (%zu) of DW_LNE_set_address op is too long\n"),
+		len - 1);
 	  adr = 0;
 	}
       else
 	SAFE_BYTE_GET (adr, data, len - 1, end);
-      printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr));
+      printf (_("set Address to 0x%" PRIx64 "\n"), adr);
       state_machine_regs.address = adr;
       state_machine_regs.view = 0;
       state_machine_regs.op_index = 0;
@@ -522,11 +463,11 @@ process_extended_line_op (unsigned char * data,
 	if (data < end)
 	  data++;
 	READ_ULEB (val, data, end);
-	printf ("%s\t", dwarf_vmatoa ("u", val));
+	printf ("%" PRIu64 "\t", val);
 	READ_ULEB (val, data, end);
-	printf ("%s\t", dwarf_vmatoa ("u", val));
+	printf ("%" PRIu64 "\t", val);
 	READ_ULEB (val, data, end);
-	printf ("%s\t", dwarf_vmatoa ("u", val));
+	printf ("%" PRIu64 "\t", val);
 	printf ("%.*s\n\n", (int) l, name);
       }
 
@@ -536,7 +477,7 @@ process_extended_line_op (unsigned char * data,
 
     case DW_LNE_set_discriminator:
       READ_ULEB (val, data, end);
-      printf (_("set Discriminator to %s\n"), dwarf_vmatoa ("u", val));
+      printf (_("set Discriminator to %" PRIu64 "\n"), val);
       break;
 
     /* HP extensions.  */
@@ -589,17 +530,17 @@ process_extended_line_op (unsigned char * data,
 		break;
 	      case DW_LNE_HP_SFC_set_listing_line:
 		READ_ULEB (val, data, edata);
-		printf ("    DW_LNE_HP_SFC_set_listing_line (%s)\n",
-			dwarf_vmatoa ("u", val));
+		printf ("    DW_LNE_HP_SFC_set_listing_line (%" PRIu64 ")\n",
+			val);
 		break;
 	      case DW_LNE_HP_SFC_associate:
 		printf ("    DW_LNE_HP_SFC_associate ");
 		READ_ULEB (val, data, edata);
-		printf ("(%s", dwarf_vmatoa ("u", val));
+		printf ("(%" PRIu64 , val);
 		READ_ULEB (val, data, edata);
-		printf (",%s", dwarf_vmatoa ("u", val));
+		printf (",%" PRIu64, val);
 		READ_ULEB (val, data, edata);
-		printf (",%s)\n", dwarf_vmatoa ("u", val));
+		printf (",%" PRIu64 ")\n", val);
 		break;
 	      default:
 		printf (_("    UNKNOWN DW_LNE_HP_SFC opcode (%u)\n"), opc);
@@ -634,7 +575,7 @@ process_extended_line_op (unsigned char * data,
 }
 
 static const unsigned char *
-fetch_indirect_string (dwarf_vma offset)
+fetch_indirect_string (uint64_t offset)
 {
   struct dwarf_section *section = &debug_displays [str].section;
   const unsigned char * ret;
@@ -644,8 +585,7 @@ fetch_indirect_string (dwarf_vma offset)
 
   if (offset >= section->size)
     {
-      warn (_("DW_FORM_strp offset too big: 0x%s\n"),
-	    dwarf_vmatoa ("x", offset));
+      warn (_("DW_FORM_strp offset too big: %#" PRIx64 "\n"), offset);
       return (const unsigned char *) _("<offset is too big>");
     }
 
@@ -662,7 +602,7 @@ fetch_indirect_string (dwarf_vma offset)
 }
 
 static const unsigned char *
-fetch_indirect_line_string (dwarf_vma offset)
+fetch_indirect_line_string (uint64_t offset)
 {
   struct dwarf_section *section = &debug_displays [line_str].section;
   const unsigned char * ret;
@@ -672,8 +612,7 @@ fetch_indirect_line_string (dwarf_vma offset)
 
   if (offset >= section->size)
     {
-      warn (_("DW_FORM_line_strp offset too big: 0x%s\n"),
-	    dwarf_vmatoa ("x", offset));
+      warn (_("DW_FORM_line_strp offset too big: %#" PRIx64 "\n"), offset);
       return (const unsigned char *) _("<offset is too big>");
     }
 
@@ -690,18 +629,18 @@ fetch_indirect_line_string (dwarf_vma offset)
 }
 
 static const char *
-fetch_indexed_string (dwarf_vma           idx,
-		      struct cu_tu_set *  this_set,
-		      dwarf_vma           offset_size,
-		      bool                dwo,
-		      dwarf_vma           str_offsets_base)
+fetch_indexed_string (uint64_t idx,
+		      struct cu_tu_set *this_set,
+		      uint64_t offset_size,
+		      bool dwo,
+		      uint64_t str_offsets_base)
 {
   enum dwarf_section_display_enum str_sec_idx = dwo ? str_dwo : str;
   enum dwarf_section_display_enum idx_sec_idx = dwo ? str_index_dwo : str_index;
   struct dwarf_section *index_section = &debug_displays [idx_sec_idx].section;
   struct dwarf_section *str_section = &debug_displays [str_sec_idx].section;
-  dwarf_vma index_offset;
-  dwarf_vma str_offset;
+  uint64_t index_offset;
+  uint64_t str_offset;
   const char * ret;
 
   if (index_section->start == NULL)
@@ -721,10 +660,9 @@ fetch_indexed_string (dwarf_vma           idx,
 
   if (index_offset + offset_size > index_section->size)
     {
-      warn (_("string index of %s converts to an offset of 0x%s which is too big for section %s"),
-	    dwarf_vmatoa ("d", idx),
-	    dwarf_vmatoa ("x", index_offset),
-	    str_section->name);
+      warn (_("string index of %" PRIu64 " converts to an offset of %#" PRIx64
+	      " which is too big for section %s"),
+	    idx, index_offset, str_section->name);
 
       return _("<string index too big>");
     }
@@ -739,8 +677,7 @@ fetch_indexed_string (dwarf_vma           idx,
   str_offset -= str_section->address;
   if (str_offset >= str_section->size)
     {
-      warn (_("indirect offset too big: 0x%s\n"),
-	    dwarf_vmatoa ("x", str_offset));
+      warn (_("indirect offset too big: %#" PRIx64 "\n"), str_offset);
       return _("<indirect index offset is too big>");
     }
 
@@ -756,8 +693,8 @@ fetch_indexed_string (dwarf_vma           idx,
   return ret;
 }
 
-static dwarf_vma
-fetch_indexed_addr (dwarf_vma offset, uint32_t num_bytes)
+static uint64_t
+fetch_indexed_addr (uint64_t offset, uint32_t num_bytes)
 {
   struct dwarf_section *section = &debug_displays [debug_addr].section;
 
@@ -769,8 +706,8 @@ fetch_indexed_addr (dwarf_vma offset, uint32_t num_bytes)
 
   if (offset + num_bytes > section->size)
     {
-      warn (_("Offset into section %s too big: 0x%s\n"),
-	    section->name, dwarf_vmatoa ("x", offset));
+      warn (_("Offset into section %s too big: %#" PRIx64 "\n"),
+	    section->name, offset);
       return 0;
     }
 
@@ -781,10 +718,10 @@ fetch_indexed_addr (dwarf_vma offset, uint32_t num_bytes)
    something in another section (eg DW_FORM_loclistx or DW_FORM_rnglistx).
    Returns -1 if the value could not be found.  */
 
-static dwarf_vma
-fetch_indexed_value (dwarf_vma idx,
+static uint64_t
+fetch_indexed_value (uint64_t idx,
 		     enum dwarf_section_display_enum sec_enum,
-		     dwarf_vma base_address)
+		     uint64_t base_address)
 {
   struct dwarf_section *section = &debug_displays [sec_enum].section;
 
@@ -807,7 +744,7 @@ fetch_indexed_value (dwarf_vma idx,
       bias = 12;
     }
 
-  dwarf_vma offset = idx * pointer_size;
+  uint64_t offset = idx * pointer_size;
 
   /* Offsets are biased by the size of the section header
      or base address.  */
@@ -818,8 +755,8 @@ fetch_indexed_value (dwarf_vma idx,
 
   if (offset + pointer_size > section->size)
     {
-      warn (_("Offset into section %s too big: 0x%s\n"),
-	    section->name, dwarf_vmatoa ("x", offset));
+      warn (_("Offset into section %s too big: %#" PRIx64 "\n"),
+	    section->name, offset);
       return -1;
     }
 
@@ -832,10 +769,10 @@ fetch_indexed_value (dwarf_vma idx,
 /* Records a single attribute in an abbrev.  */
 typedef struct abbrev_attr
 {
-  unsigned long          attribute;
-  unsigned long          form;
-  dwarf_signed_vma       implicit_const;
-  struct abbrev_attr *   next;
+  unsigned long attribute;
+  unsigned long form;
+  int64_t implicit_const;
+  struct abbrev_attr *next;
 }
 abbrev_attr;
 
@@ -867,9 +804,9 @@ static struct abbrev_list * abbrev_lists = NULL;
 
 typedef struct abbrev_map
 {
-  dwarf_vma      start;
-  dwarf_vma      end;
-  abbrev_list *  list;
+  uint64_t start;
+  uint64_t end;
+  abbrev_list *list;
 } abbrev_map;
 
 /* Maps between CU offsets and abbrev sets.  */
@@ -881,7 +818,7 @@ static unsigned long  next_free_abbrev_map_entry = 0;
 #define ABBREV_MAP_ENTRIES_INCREMENT   8
 
 static void
-record_abbrev_list_for_cu (dwarf_vma start, dwarf_vma end,
+record_abbrev_list_for_cu (uint64_t start, uint64_t end,
 			   abbrev_list *list, abbrev_list *free_list)
 {
   if (free_list != NULL)
@@ -962,7 +899,7 @@ find_abbrev_list_by_raw_abbrev (unsigned char *raw)
    Not caching abbrevs is likely the answer.  */
 
 static  abbrev_map *
-find_abbrev_map_by_offset (dwarf_vma offset)
+find_abbrev_map_by_offset (uint64_t offset)
 {
   unsigned long i;
 
@@ -1002,10 +939,10 @@ add_abbrev (unsigned long  number,
 }
 
 static void
-add_abbrev_attr (unsigned long    attribute,
-		 unsigned long    form,
-		 dwarf_signed_vma implicit_const,
-		 abbrev_list *    list)
+add_abbrev_attr (unsigned long attribute,
+		 unsigned long form,
+		 int64_t implicit_const,
+		 abbrev_list *list)
 {
   abbrev_attr *attr;
 
@@ -1073,7 +1010,7 @@ process_abbrev_set (struct dwarf_section *section,
 	{
 	  unsigned long form;
 	  /* Initialize it due to a false compiler warning.  */
-	  dwarf_signed_vma implicit_const = -1;
+	  int64_t implicit_const = -1;
 
 	  READ_ULEB (attribute, start, end);
 	  if (start == end)
@@ -1112,9 +1049,9 @@ process_abbrev_set (struct dwarf_section *section,
 
 static abbrev_list *
 find_and_process_abbrev_set (struct dwarf_section *section,
-			     dwarf_vma abbrev_base,
-			     dwarf_vma abbrev_size,
-			     dwarf_vma abbrev_offset,
+			     uint64_t abbrev_base,
+			     uint64_t abbrev_size,
+			     uint64_t abbrev_offset,
 			     abbrev_list **free_list)
 {
   if (free_list)
@@ -1124,18 +1061,16 @@ find_and_process_abbrev_set (struct dwarf_section *section,
       || abbrev_size > section->size - abbrev_base)
     {
       /* PR 17531: file:4bcd9ce9.  */
-      warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
-	      "abbrev section size (%lx)\n"),
-	      (unsigned long) (abbrev_base + abbrev_size),
-	      (unsigned long) section->size);
+      warn (_("Debug info is corrupted, abbrev size (%#" PRIx64 ")"
+	      " is larger than abbrev section size (%#" PRIx64 ")\n"),
+	      abbrev_base + abbrev_size, section->size);
       return NULL;
     }
   if (abbrev_offset >= abbrev_size)
     {
-      warn (_("Debug info is corrupted, abbrev offset (%lx) is larger than "
-	      "abbrev section size (%lx)\n"),
-	    (unsigned long) abbrev_offset,
-	    (unsigned long) abbrev_size);
+      warn (_("Debug info is corrupted, abbrev offset (%#" PRIx64 ")"
+	      " is larger than abbrev section size (%#" PRIx64 ")\n"),
+	    abbrev_offset, abbrev_size);
       return NULL;
     }
 
@@ -1154,18 +1089,22 @@ find_and_process_abbrev_set (struct dwarf_section *section,
 }
 
 static const char *
-get_TAG_name (unsigned long tag)
+get_TAG_name (uint64_t tag)
 {
-  const char *name = get_DW_TAG_name ((unsigned int) tag);
+  const char *name = NULL;
 
+  if ((unsigned int) tag == tag)
+    name = get_DW_TAG_name ((unsigned int) tag);
   if (name == NULL)
     {
       static char buffer[100];
 
       if (tag >= DW_TAG_lo_user && tag <= DW_TAG_hi_user)
-	snprintf (buffer, sizeof (buffer), _("User TAG value: %#lx"), tag);
+	snprintf (buffer, sizeof (buffer),
+		  _("User TAG value: %#" PRIx64), tag);
       else
-	snprintf (buffer, sizeof (buffer), _("Unknown TAG value: %#lx"), tag);
+	snprintf (buffer, sizeof (buffer),
+		  _("Unknown TAG value: %#" PRIx64), tag);
       return buffer;
     }
 
@@ -1175,12 +1114,13 @@ get_TAG_name (unsigned long tag)
 static const char *
 get_FORM_name (unsigned long form)
 {
-  const char *name;
+  const char *name = NULL;
 
   if (form == 0)
     return "DW_FORM value: 0";
 
-  name = get_DW_FORM_name (form);
+  if ((unsigned int) form == form)
+    name = get_DW_FORM_name ((unsigned int) form);
   if (name == NULL)
     {
       static char buffer[100];
@@ -1195,8 +1135,10 @@ get_FORM_name (unsigned long form)
 static const char *
 get_IDX_name (unsigned long idx)
 {
-  const char *name = get_DW_IDX_name ((unsigned int) idx);
+  const char *name = NULL;
 
+  if ((unsigned int) idx == idx)
+    name = get_DW_IDX_name ((unsigned int) idx);
   if (name == NULL)
     {
       static char buffer[100];
@@ -1210,20 +1152,20 @@ get_IDX_name (unsigned long idx)
 
 static unsigned char *
 display_block (unsigned char *data,
-	       dwarf_vma length,
+	       uint64_t length,
 	       const unsigned char * const end, char delimiter)
 {
-  dwarf_vma maxlen;
+  size_t maxlen;
 
-  printf (_("%c%s byte block: "), delimiter, dwarf_vmatoa ("u", length));
+  printf (_("%c%" PRIu64 " byte block: "), delimiter, length);
   if (data > end)
     return (unsigned char *) end;
 
-  maxlen = (dwarf_vma) (end - data);
+  maxlen = end - data;
   length = length > maxlen ? maxlen : length;
 
   while (length --)
-    printf ("%lx ", (unsigned long) byte_get (data++, 1));
+    printf ("%" PRIx64 " ", byte_get (data++, 1));
 
   return data;
 }
@@ -1233,13 +1175,13 @@ decode_location_expression (unsigned char * data,
 			    unsigned int pointer_size,
 			    unsigned int offset_size,
 			    int dwarf_version,
-			    dwarf_vma length,
-			    dwarf_vma cu_offset,
+			    uint64_t length,
+			    uint64_t cu_offset,
 			    struct dwarf_section * section)
 {
   unsigned op;
-  dwarf_vma uvalue;
-  dwarf_signed_vma svalue;
+  uint64_t uvalue;
+  int64_t svalue;
   unsigned char *end = data + length;
   int need_frame_base = 0;
 
@@ -1251,54 +1193,50 @@ decode_location_expression (unsigned char * data,
 	{
 	case DW_OP_addr:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, pointer_size, end);
-	  printf ("DW_OP_addr: %s", dwarf_vmatoa ("x", uvalue));
+	  printf ("DW_OP_addr: %" PRIx64, uvalue);
 	  break;
 	case DW_OP_deref:
 	  printf ("DW_OP_deref");
 	  break;
 	case DW_OP_const1u:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  printf ("DW_OP_const1u: %lu", (unsigned long) uvalue);
+	  printf ("DW_OP_const1u: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_const1s:
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 1, end);
-	  printf ("DW_OP_const1s: %ld", (long) svalue);
+	  printf ("DW_OP_const1s: %" PRId64, svalue);
 	  break;
 	case DW_OP_const2u:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 2, end);
-	  printf ("DW_OP_const2u: %lu", (unsigned long) uvalue);
+	  printf ("DW_OP_const2u: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_const2s:
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
-	  printf ("DW_OP_const2s: %ld", (long) svalue);
+	  printf ("DW_OP_const2s: %" PRId64, svalue);
 	  break;
 	case DW_OP_const4u:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
-	  printf ("DW_OP_const4u: %lu", (unsigned long) uvalue);
+	  printf ("DW_OP_const4u: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_const4s:
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
-	  printf ("DW_OP_const4s: %ld", (long) svalue);
+	  printf ("DW_OP_const4s: %" PRId64, svalue);
 	  break;
 	case DW_OP_const8u:
-	  SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
-	  printf ("DW_OP_const8u: %lu ", (unsigned long) uvalue);
-	  SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
-	  printf ("%lu", (unsigned long) uvalue);
+	  SAFE_BYTE_GET_AND_INC (uvalue, data, 8, end);
+	  printf ("DW_OP_const8u: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_const8s:
-	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
-	  printf ("DW_OP_const8s: %ld ", (long) svalue);
-	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
-	  printf ("%ld", (long) svalue);
+	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 8, end);
+	  printf ("DW_OP_const8s: %" PRId64, svalue);
 	  break;
 	case DW_OP_constu:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_constu: %s", dwarf_vmatoa ("u", uvalue));
+	  printf ("DW_OP_constu: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_consts:
 	  READ_SLEB (svalue, data, end);
-	  printf ("DW_OP_consts: %s", dwarf_vmatoa ("d", svalue));
+	  printf ("DW_OP_consts: %" PRId64, svalue);
 	  break;
 	case DW_OP_dup:
 	  printf ("DW_OP_dup");
@@ -1311,7 +1249,7 @@ decode_location_expression (unsigned char * data,
 	  break;
 	case DW_OP_pick:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  printf ("DW_OP_pick: %ld", (unsigned long) uvalue);
+	  printf ("DW_OP_pick: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_swap:
 	  printf ("DW_OP_swap");
@@ -1354,7 +1292,7 @@ decode_location_expression (unsigned char * data,
 	  break;
 	case DW_OP_plus_uconst:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_plus_uconst: %s", dwarf_vmatoa ("u", uvalue));
+	  printf ("DW_OP_plus_uconst: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_shl:
 	  printf ("DW_OP_shl");
@@ -1370,7 +1308,7 @@ decode_location_expression (unsigned char * data,
 	  break;
 	case DW_OP_bra:
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
-	  printf ("DW_OP_bra: %ld", (long) svalue);
+	  printf ("DW_OP_bra: %" PRId64, svalue);
 	  break;
 	case DW_OP_eq:
 	  printf ("DW_OP_eq");
@@ -1392,7 +1330,7 @@ decode_location_expression (unsigned char * data,
 	  break;
 	case DW_OP_skip:
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
-	  printf ("DW_OP_skip: %ld", (long) svalue);
+	  printf ("DW_OP_skip: %" PRId64, svalue);
 	  break;
 
 	case DW_OP_lit0:
@@ -1499,38 +1437,37 @@ decode_location_expression (unsigned char * data,
 	case DW_OP_breg30:
 	case DW_OP_breg31:
 	  READ_SLEB (svalue, data, end);
-	  printf ("DW_OP_breg%d (%s): %s", op - DW_OP_breg0,
-		  regname (op - DW_OP_breg0, 1), dwarf_vmatoa ("d", svalue));
+	  printf ("DW_OP_breg%d (%s): %" PRId64,
+		  op - DW_OP_breg0, regname (op - DW_OP_breg0, 1), svalue);
 	  break;
 
 	case DW_OP_regx:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_regx: %s (%s)",
-		  dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
+	  printf ("DW_OP_regx: %" PRIu64 " (%s)",
+		  uvalue, regname (uvalue, 1));
 	  break;
 	case DW_OP_fbreg:
 	  need_frame_base = 1;
 	  READ_SLEB (svalue, data, end);
-	  printf ("DW_OP_fbreg: %s", dwarf_vmatoa ("d", svalue));
+	  printf ("DW_OP_fbreg: %" PRId64, svalue);
 	  break;
 	case DW_OP_bregx:
 	  READ_ULEB (uvalue, data, end);
 	  READ_SLEB (svalue, data, end);
-	  printf ("DW_OP_bregx: %s (%s) %s",
-		  dwarf_vmatoa ("u", uvalue), regname (uvalue, 1),
-		  dwarf_vmatoa ("d", svalue));
+	  printf ("DW_OP_bregx: %" PRIu64 " (%s) %" PRId64,
+		  uvalue, regname (uvalue, 1), svalue);
 	  break;
 	case DW_OP_piece:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_piece: %s", dwarf_vmatoa ("u", uvalue));
+	  printf ("DW_OP_piece: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_deref_size:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  printf ("DW_OP_deref_size: %ld", (long) uvalue);
+	  printf ("DW_OP_deref_size: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_xderef_size:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 1, end);
-	  printf ("DW_OP_xderef_size: %ld", (long) uvalue);
+	  printf ("DW_OP_xderef_size: %" PRIu64, uvalue);
 	  break;
 	case DW_OP_nop:
 	  printf ("DW_OP_nop");
@@ -1544,15 +1481,13 @@ decode_location_expression (unsigned char * data,
 	  /* FIXME: Strictly speaking for 64-bit DWARF3 files
 	     this ought to be an 8-byte wide computation.  */
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 2, end);
-	  printf ("DW_OP_call2: <0x%s>",
-		  dwarf_vmatoa ("x", svalue + cu_offset));
+	  printf ("DW_OP_call2: <0x%" PRIx64 ">", svalue + cu_offset);
 	  break;
 	case DW_OP_call4:
 	  /* FIXME: Strictly speaking for 64-bit DWARF3 files
 	     this ought to be an 8-byte wide computation.  */
 	  SAFE_SIGNED_BYTE_GET_AND_INC (svalue, data, 4, end);
-	  printf ("DW_OP_call4: <0x%s>",
-		  dwarf_vmatoa ("x", svalue + cu_offset));
+	  printf ("DW_OP_call4: <0x%" PRIx64 ">", svalue + cu_offset);
 	  break;
 	case DW_OP_call_ref:
 	  /* FIXME: Strictly speaking for 64-bit DWARF3 files
@@ -1571,7 +1506,7 @@ decode_location_expression (unsigned char * data,
 	    {
 	      SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
 	    }
-	  printf ("DW_OP_call_ref: <0x%s>", dwarf_vmatoa ("x", uvalue));
+	  printf ("DW_OP_call_ref: <0x%" PRIx64 ">", uvalue);
 	  break;
 	case DW_OP_form_tls_address:
 	  printf ("DW_OP_form_tls_address");
@@ -1582,9 +1517,9 @@ decode_location_expression (unsigned char * data,
 	case DW_OP_bit_piece:
 	  printf ("DW_OP_bit_piece: ");
 	  READ_ULEB (uvalue, data, end);
-	  printf (_("size: %s "), dwarf_vmatoa ("u", uvalue));
+	  printf (_("size: %" PRIu64 " "), uvalue);
 	  READ_ULEB (uvalue, data, end);
-	  printf (_("offset: %s "), dwarf_vmatoa ("u", uvalue));
+	  printf (_("offset: %" PRIu64 " "), uvalue);
 	  break;
 
 	  /* DWARF 4 extensions.  */
@@ -1609,14 +1544,14 @@ decode_location_expression (unsigned char * data,
 	case DW_OP_GNU_encoded_addr:
 	  {
 	    int encoding = 0;
-	    dwarf_vma addr;
+	    uint64_t addr;
 
 	    if (data < end)
 	      encoding = *data++;
 	    addr = get_encoded_value (&data, encoding, section, end);
 
 	    printf ("DW_OP_GNU_encoded_addr: fmt:%02x addr:", encoding);
-	    print_dwarf_vma (addr, pointer_size);
+	    print_hex (addr, pointer_size);
 	  }
 	  break;
 	case DW_OP_implicit_pointer:
@@ -1641,17 +1576,16 @@ decode_location_expression (unsigned char * data,
 	      SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
 	    }
 	  READ_SLEB (svalue, data, end);
-	  printf ("%s: <0x%s> %s",
+	  printf ("%s: <0x%" PRIx64 "> %" PRId64,
 		  (op == DW_OP_implicit_pointer
 		   ? "DW_OP_implicit_pointer" : "DW_OP_GNU_implicit_pointer"),
-		  dwarf_vmatoa ("x", uvalue),
-		  dwarf_vmatoa ("d", svalue));
+		  uvalue, svalue);
 	  break;
 	case DW_OP_entry_value:
 	case DW_OP_GNU_entry_value:
 	  READ_ULEB (uvalue, data, end);
 	  /* PR 17531: file: 0cc9cd00.  */
-	  if (uvalue > (dwarf_vma) (end - data))
+	  if (uvalue > (size_t) (end - data))
 	    uvalue = end - data;
 	  printf ("%s: (", (op == DW_OP_entry_value ? "DW_OP_entry_value"
 						    : "DW_OP_GNU_entry_value"));
@@ -1665,64 +1599,64 @@ decode_location_expression (unsigned char * data,
 	case DW_OP_const_type:
 	case DW_OP_GNU_const_type:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("%s: <0x%s> ",
+	  printf ("%s: <0x%" PRIx64 "> ",
 		  (op == DW_OP_const_type ? "DW_OP_const_type"
 					  : "DW_OP_GNU_const_type"),
-		  dwarf_vmatoa ("x", cu_offset + uvalue));
+		  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:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("%s: %s (%s)",
+	  printf ("%s: %" PRIu64 " (%s)",
 		  (op == DW_OP_regval_type ? "DW_OP_regval_type"
 					   : "DW_OP_GNU_regval_type"),
-		  dwarf_vmatoa ("u", uvalue), regname (uvalue, 1));
+		  uvalue, regname (uvalue, 1));
 	  READ_ULEB (uvalue, data, end);
-	  printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
+	  printf (" <0x%" PRIx64 ">", 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 ("%s: %ld",
+	  printf ("%s: %" PRId64,
 		  (op == DW_OP_deref_type ? "DW_OP_deref_type"
 					  : "DW_OP_GNU_deref_type"),
-		  (long) uvalue);
+		  uvalue);
 	  READ_ULEB (uvalue, data, end);
-	  printf (" <0x%s>", dwarf_vmatoa ("x", cu_offset + uvalue));
+	  printf (" <0x%" PRIx64 ">", cu_offset + uvalue);
 	  break;
 	case DW_OP_convert:
 	case DW_OP_GNU_convert:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("%s <0x%s>",
+	  printf ("%s <0x%" PRIx64 ">",
 		  (op == DW_OP_convert ? "DW_OP_convert" : "DW_OP_GNU_convert"),
-		  dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
+		  uvalue ? cu_offset + uvalue : uvalue);
 	  break;
 	case DW_OP_reinterpret:
 	case DW_OP_GNU_reinterpret:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("%s <0x%s>",
+	  printf ("%s <0x%" PRIx64 ">",
 		  (op == DW_OP_reinterpret ? "DW_OP_reinterpret"
 					   : "DW_OP_GNU_reinterpret"),
-		  dwarf_vmatoa ("x", uvalue ? cu_offset + uvalue : 0));
+		  uvalue ? cu_offset + uvalue : uvalue);
 	  break;
 	case DW_OP_GNU_parameter_ref:
 	  SAFE_BYTE_GET_AND_INC (uvalue, data, 4, end);
-	  printf ("DW_OP_GNU_parameter_ref: <0x%s>",
-		  dwarf_vmatoa ("x", cu_offset + uvalue));
+	  printf ("DW_OP_GNU_parameter_ref: <0x%" PRIx64 ">",
+		  cu_offset + uvalue);
 	  break;
 	case DW_OP_addrx:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_addrx <0x%s>", dwarf_vmatoa ("x", uvalue));
+	  printf ("DW_OP_addrx <0x%" PRIx64 ">", uvalue);
 	  break;
 	case DW_OP_GNU_addr_index:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_GNU_addr_index <0x%s>", dwarf_vmatoa ("x", uvalue));
+	  printf ("DW_OP_GNU_addr_index <0x%" PRIx64 ">", uvalue);
 	  break;
 	case DW_OP_GNU_const_index:
 	  READ_ULEB (uvalue, data, end);
-	  printf ("DW_OP_GNU_const_index <0x%s>", dwarf_vmatoa ("x", uvalue));
+	  printf ("DW_OP_GNU_const_index <0x%" PRIx64 ">", uvalue);
 	  break;
 	case DW_OP_GNU_variable_value:
 	  /* FIXME: Strictly speaking for 64-bit DWARF3 files
@@ -1741,7 +1675,7 @@ decode_location_expression (unsigned char * data,
 	    {
 	      SAFE_BYTE_GET_AND_INC (uvalue, data, offset_size, end);
 	    }
-	  printf ("DW_OP_GNU_variable_value: <0x%s>", dwarf_vmatoa ("x", uvalue));
+	  printf ("DW_OP_GNU_variable_value: <0x%" PRIx64 ">", uvalue);
 	  break;
 
 	  /* HP extensions.  */
@@ -1801,7 +1735,7 @@ decode_location_expression (unsigned char * data,
    This is used for DWARF package files.  */
 
 static struct cu_tu_set *
-find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types)
+find_cu_tu_set_v2 (uint64_t cu_offset, int do_types)
 {
   struct cu_tu_set *p;
   unsigned int nsets;
@@ -1830,7 +1764,7 @@ find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types)
 }
 
 static const char *
-fetch_alt_indirect_string (dwarf_vma offset)
+fetch_alt_indirect_string (uint64_t offset)
 {
   separate_info * i;
 
@@ -1867,8 +1801,8 @@ fetch_alt_indirect_string (dwarf_vma offset)
       return ret;
     }
 
-  warn (_("DW_FORM_GNU_strp_alt offset (%s) too big or no string sections available\n"),
-	dwarf_vmatoa ("x", offset));
+  warn (_("DW_FORM_GNU_strp_alt offset (%#" PRIx64 ")"
+	  " too big or no string sections available\n"), offset);
   return _("<offset is too big>");
 }
 
@@ -1899,7 +1833,7 @@ get_AT_name (unsigned long attribute)
 }
 
 static void
-add_dwo_info (const char * value, dwarf_vma cu_offset, dwo_type type)
+add_dwo_info (const char * value, uint64_t cu_offset, dwo_type type)
 {
   dwo_info * dwinfo = xmalloc (sizeof * dwinfo);
 
@@ -1911,19 +1845,19 @@ add_dwo_info (const char * value, dwarf_vma cu_offset, dwo_type type)
 }
 
 static void
-add_dwo_name (const char * name, dwarf_vma cu_offset)
+add_dwo_name (const char * name, uint64_t cu_offset)
 {
   add_dwo_info (name, cu_offset, DWO_NAME);
 }
 
 static void
-add_dwo_dir (const char * dir, dwarf_vma cu_offset)
+add_dwo_dir (const char * dir, uint64_t cu_offset)
 {
   add_dwo_info (dir, cu_offset, DWO_DIR);
 }
 
 static void
-add_dwo_id (const char * id, dwarf_vma cu_offset)
+add_dwo_id (const char * id, uint64_t cu_offset)
 {
   add_dwo_info (id, cu_offset, DWO_ID);
 }
@@ -1945,18 +1879,18 @@ free_dwo_info (void)
 /* Ensure that START + UVALUE is less than END.
    Return an adjusted UVALUE if necessary to ensure this relationship.  */
 
-static inline dwarf_vma
-check_uvalue (const unsigned char * start,
-	      dwarf_vma             uvalue,
-	      const unsigned char * end)
+static inline uint64_t
+check_uvalue (const unsigned char *start,
+	      uint64_t uvalue,
+	      const unsigned char *end)
 {
-  dwarf_vma max_uvalue = end - start;
+  uint64_t max_uvalue = end - start;
 
   /* See PR 17512: file: 008-103549-0.001:0.1.
      and PR 24829 for examples of where these tests are triggered.  */
   if (uvalue > max_uvalue)
     {
-      warn (_("Corrupt attribute block length: %lx\n"), (long) uvalue);
+      warn (_("Corrupt attribute block length: %#" PRIx64 "\n"), uvalue);
       uvalue = max_uvalue;
     }
 
@@ -1967,14 +1901,14 @@ static unsigned char *
 skip_attr_bytes (unsigned long form,
 		 unsigned char *data,
 		 unsigned char *end,
-		 dwarf_vma pointer_size,
-		 dwarf_vma offset_size,
+		 uint64_t pointer_size,
+		 uint64_t offset_size,
 		 int dwarf_version,
-		 dwarf_vma *value_return)
+		 uint64_t *value_return)
 {
-  dwarf_signed_vma svalue;
-  dwarf_vma uvalue = 0;
-  dwarf_vma inc = 0;
+  int64_t svalue;
+  uint64_t uvalue = 0;
+  uint64_t inc = 0;
 
   * value_return = 0;
 
@@ -2098,7 +2032,7 @@ skip_attr_bytes (unsigned long form,
     }
 
   * value_return = uvalue;
-  if (inc <= (dwarf_vma) (end - data))
+  if (inc <= (size_t) (end - data))
     data += inc;
   else
     data = end;
@@ -2111,7 +2045,7 @@ skip_attr_bytes (unsigned long form,
 static abbrev_entry *
 get_type_abbrev_from_form (unsigned long form,
 			   unsigned long uvalue,
-			   dwarf_vma cu_offset,
+			   uint64_t cu_offset,
 			   unsigned char *cu_end,
 			   const struct dwarf_section *section,
 			   unsigned long *abbrev_num_return,
@@ -2138,8 +2072,9 @@ get_type_abbrev_from_form (unsigned long form,
     case DW_FORM_ref_addr:
       if (uvalue >= section->size)
 	{
-	  warn (_("Unable to resolve ref_addr form: uvalue %lx > section size %lx (%s)\n"),
-		uvalue, (long) section->size, section->name);
+	  warn (_("Unable to resolve ref_addr form: uvalue %lx "
+		  "> section size %" PRIx64 " (%s)\n"),
+		uvalue, section->size, section->name);
 	  return NULL;
 	}
       break;
@@ -2156,8 +2091,9 @@ get_type_abbrev_from_form (unsigned long form,
       if (uvalue + cu_offset < uvalue
 	  || uvalue + cu_offset > (size_t) (cu_end - section->start))
 	{
-	  warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %lx > CU size %lx\n"),
-		uvalue, (long) cu_offset, (long) (cu_end - section->start));
+	  warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %" PRIx64
+		  " > CU size %tx\n"),
+		uvalue, cu_offset, cu_end - section->start);
 	  return NULL;
 	}
       uvalue += cu_offset;
@@ -2219,9 +2155,9 @@ get_type_signedness (abbrev_entry *entry,
 		     const struct dwarf_section *section,
 		     unsigned char *data,
 		     unsigned char *end,
-		     dwarf_vma cu_offset,
-		     dwarf_vma pointer_size,
-		     dwarf_vma offset_size,
+		     uint64_t cu_offset,
+		     uint64_t pointer_size,
+		     uint64_t offset_size,
 		     int dwarf_version,
 		     bool *is_signed,
 		     unsigned int nesting)
@@ -2243,7 +2179,7 @@ get_type_signedness (abbrev_entry *entry,
        attr = attr->next)
     {
       unsigned char * orig_data = data;
-      dwarf_vma uvalue = 0;
+      uint64_t uvalue = 0;
 
       data = skip_attr_bytes (attr->form, data, end, pointer_size,
 			      offset_size, dwarf_version, & uvalue);
@@ -2325,18 +2261,20 @@ read_and_print_leb128 (unsigned char *data,
 		       bool is_signed)
 {
   int status;
-  dwarf_vma val = read_leb128 (data, end, is_signed, bytes_read, &status);
+  uint64_t val = read_leb128 (data, end, is_signed, bytes_read, &status);
   if (status != 0)
     report_leb_status (status);
+  else if (is_signed)
+    printf ("%" PRId64, val);
   else
-    printf ("%s", dwarf_vmatoa (is_signed ? "d" : "u", val));
+    printf ("%" PRIu64, val);
 }
 
 static void
-display_discr_list (unsigned long          form,
-		    dwarf_vma              uvalue,
-		    unsigned char *        data,
-		    int                    level)
+display_discr_list (unsigned long form,
+		    uint64_t uvalue,
+		    unsigned char *data,
+		    int level)
 {
   unsigned char *end = data;
 
@@ -2415,26 +2353,26 @@ display_discr_list (unsigned long          form,
 }
 
 static unsigned char *
-read_and_display_attr_value (unsigned long           attribute,
-			     unsigned long           form,
-			     dwarf_signed_vma        implicit_const,
-			     unsigned char *         start,
-			     unsigned char *         data,
-			     unsigned char *         end,
-			     dwarf_vma               cu_offset,
-			     dwarf_vma               pointer_size,
-			     dwarf_vma               offset_size,
-			     int                     dwarf_version,
-			     debug_info *            debug_info_p,
-			     int                     do_loc,
-			     struct dwarf_section *  section,
-			     struct cu_tu_set *      this_set,
-			     char                    delimiter,
-			     int                     level)
-{
-  dwarf_signed_vma svalue;
-  dwarf_vma uvalue = 0;
-  dwarf_vma uvalue_hi = 0;
+read_and_display_attr_value (unsigned long attribute,
+			     unsigned long form,
+			     int64_t implicit_const,
+			     unsigned char *start,
+			     unsigned char *data,
+			     unsigned char *end,
+			     uint64_t cu_offset,
+			     uint64_t pointer_size,
+			     uint64_t offset_size,
+			     int dwarf_version,
+			     debug_info *debug_info_p,
+			     int do_loc,
+			     struct dwarf_section *section,
+			     struct cu_tu_set *this_set,
+			     char delimiter,
+			     int level)
+{
+  int64_t svalue;
+  uint64_t uvalue = 0;
+  uint64_t uvalue_hi = 0;
   unsigned char *block_start = NULL;
   unsigned char *orig_data = data;
 
@@ -2523,7 +2461,7 @@ read_and_display_attr_value (unsigned long           attribute,
       SAFE_BYTE_GET_AND_INC (uvalue_hi, data, 8, end);
       if (byte_get != byte_get_little_endian)
 	{
-	  dwarf_vma utmp = uvalue;
+	  uint64_t utmp = uvalue;
 	  uvalue = uvalue_hi;
 	  uvalue_hi = utmp;
 	}
@@ -2570,7 +2508,7 @@ read_and_display_attr_value (unsigned long           attribute,
     {
     case DW_FORM_ref_addr:
       if (!do_loc)
-	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue));
+	printf ("%c<0x%" PRIx64 ">", delimiter, uvalue);
       break;
 
     case DW_FORM_GNU_ref_alt:
@@ -2578,9 +2516,9 @@ read_and_display_attr_value (unsigned long           attribute,
 	{
 	  if (do_wide)
 	    /* We have already printed the form name.  */
-	    printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue));
+	    printf ("%c<0x%" PRIx64 ">", delimiter, uvalue);
 	  else
-	    printf ("%c<alt 0x%s>", delimiter, dwarf_vmatoa ("x", uvalue));
+	    printf ("%c<alt 0x%" PRIx64 ">", delimiter, uvalue);
 	}
       /* FIXME: Follow the reference...  */
       break;
@@ -2591,14 +2529,14 @@ read_and_display_attr_value (unsigned long           attribute,
     case DW_FORM_ref_sup4:
     case DW_FORM_ref_udata:
       if (!do_loc)
-	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset));
+	printf ("%c<0x%" PRIx64 ">", delimiter, uvalue + cu_offset);
       break;
 
     case DW_FORM_data4:
     case DW_FORM_addr:
     case DW_FORM_sec_offset:
       if (!do_loc)
-	printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", uvalue));
+	printf ("%c0x%" PRIx64, delimiter, uvalue);
       break;
 
     case DW_FORM_flag_present:
@@ -2607,17 +2545,17 @@ read_and_display_attr_value (unsigned long           attribute,
     case DW_FORM_data2:
     case DW_FORM_sdata:
       if (!do_loc)
-	printf ("%c%s", delimiter, dwarf_vmatoa ("d", uvalue));
+	printf ("%c%" PRId64, delimiter, uvalue);
       break;
 
     case DW_FORM_udata:
       if (!do_loc)
-	printf ("%c%s", delimiter, dwarf_vmatoa ("u", uvalue));
+	printf ("%c%" PRIu64, delimiter, uvalue);
       break;
 
     case DW_FORM_implicit_const:
       if (!do_loc)
-	printf ("%c%s", delimiter, dwarf_vmatoa ("d", implicit_const));
+	printf ("%c%" PRId64, delimiter, implicit_const);
       break;
 
     case DW_FORM_ref_sup8:
@@ -2625,18 +2563,21 @@ read_and_display_attr_value (unsigned long           attribute,
     case DW_FORM_data8:
       if (!do_loc)
 	{
-	  dwarf_vma utmp = uvalue;
+	  uint64_t utmp = uvalue;
 	  if (form == DW_FORM_ref8)
 	    utmp += cu_offset;
-	  printf ("%c0x%s", delimiter, dwarf_vmatoa ("x", utmp));
+	  printf ("%c0x%" PRIx64, delimiter, utmp);
 	}
       break;
 
     case DW_FORM_data16:
       if (!do_loc)
-	printf (" 0x%s%s",
-		uvalue_hi == 0 ? "" : dwarf_vmatoa ("x", uvalue_hi),
-		dwarf_vmatoa_1 ("x", uvalue, uvalue_hi == 0 ? 0 : 8));
+	{
+	  if (uvalue_hi == 0)
+	    printf (" 0x%" PRIx64, uvalue);
+	  else
+	    printf (" 0x%" PRIx64 "%016" PRIx64, uvalue_hi, uvalue);
+	}
       break;
 
     case DW_FORM_string:
@@ -2689,13 +2630,11 @@ read_and_display_attr_value (unsigned long           attribute,
 	{
 	  if (do_wide)
 	    /* We have already displayed the form name.  */
-	    printf (_("%c(offset: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    fetch_indirect_string (uvalue));
+	    printf (_("%c(offset: 0x%" PRIx64 "): %s"),
+		    delimiter, uvalue, fetch_indirect_string (uvalue));
 	  else
-	    printf (_("%c(indirect string, offset: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    fetch_indirect_string (uvalue));
+	    printf (_("%c(indirect string, offset: 0x%" PRIx64 "): %s"),
+		    delimiter, uvalue, fetch_indirect_string (uvalue));
 	}
       break;
 
@@ -2704,13 +2643,11 @@ read_and_display_attr_value (unsigned long           attribute,
 	{
 	  if (do_wide)
 	    /* We have already displayed the form name.  */
-	    printf (_("%c(offset: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    fetch_indirect_line_string (uvalue));
+	    printf (_("%c(offset: 0x%" PRIx64 "): %s"),
+		    delimiter, uvalue, fetch_indirect_line_string (uvalue));
 	  else
-	    printf (_("%c(indirect line string, offset: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    fetch_indirect_line_string (uvalue));
+	    printf (_("%c(indirect line string, offset: 0x%" PRIx64 "): %s"),
+		    delimiter, uvalue, fetch_indirect_line_string (uvalue));
 	}
       break;
 
@@ -2730,11 +2667,11 @@ read_and_display_attr_value (unsigned long           attribute,
 					debug_info_p ? debug_info_p->str_offsets_base : 0);
 	  if (do_wide)
 	    /* We have already displayed the form name.  */
-	    printf (_("%c(offset: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue), strng);
+	    printf (_("%c(offset: 0x%" PRIx64 "): %s"),
+		    delimiter, uvalue, strng);
 	  else
-	    printf (_("%c(indexed string: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue), strng);
+	    printf (_("%c(indexed string: 0x%" PRIx64 "): %s"),
+		    delimiter, uvalue, strng);
 	}
       break;
 
@@ -2743,13 +2680,11 @@ read_and_display_attr_value (unsigned long           attribute,
 	{
 	  if (do_wide)
 	    /* We have already displayed the form name.  */
-	    printf (_("%c(offset: 0x%s) %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    fetch_alt_indirect_string (uvalue));
+	    printf (_("%c(offset: 0x%" PRIx64 ") %s"),
+		    delimiter, uvalue, fetch_alt_indirect_string (uvalue));
 	  else
-	    printf (_("%c(alt indirect string, offset: 0x%s) %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    fetch_alt_indirect_string (uvalue));
+	    printf (_("%c(alt indirect string, offset: 0x%" PRIx64 ") %s"),
+		    delimiter, uvalue, fetch_alt_indirect_string (uvalue));
 	}
       break;
 
@@ -2759,8 +2694,8 @@ read_and_display_attr_value (unsigned long           attribute,
 
     case DW_FORM_ref_sig8:
       if (!do_loc)
-	printf ("%c%s: 0x%s", delimiter, do_wide ? "" : "signature",
-		dwarf_vmatoa ("x", uvalue));
+	printf ("%c%s: 0x%" PRIx64, delimiter, do_wide ? "" : "signature",
+		uvalue);
       break;
 
     case DW_FORM_GNU_addr_index:
@@ -2773,7 +2708,7 @@ read_and_display_attr_value (unsigned long           attribute,
     case DW_FORM_rnglistx:
       if (!do_loc)
 	{
-	  dwarf_vma base, idx;
+	  uint64_t base, idx;
 	  const char *suffix = strrchr (section->name, '.');
 	  bool dwo = suffix && strcmp (suffix, ".dwo") == 0;
 
@@ -2782,7 +2717,7 @@ read_and_display_attr_value (unsigned long           attribute,
 	      if (dwo)
 		{
 		  idx = fetch_indexed_value (uvalue, loclists_dwo, 0);
-		  if (idx != (dwarf_vma) -1)
+		  if (idx != (uint64_t) -1)
 		    idx += (offset_size == 8) ? 20 : 12;
 		}
 	      else if (debug_info_p == NULL)
@@ -2810,7 +2745,7 @@ read_and_display_attr_value (unsigned long           attribute,
 	      if (dwo)
 		{
 		  idx = fetch_indexed_value (uvalue, rnglists_dwo, 0);
-		  if (idx != (dwarf_vma) -1)
+		  if (idx != (uint64_t) -1)
 		    idx += (offset_size == 8) ? 20 : 12;
 		}
 	      else
@@ -2822,7 +2757,7 @@ read_and_display_attr_value (unsigned long           attribute,
 		  /* We do not have a cached value this time, so we perform the
 		     computation manually.  */
 		  idx = fetch_indexed_value (uvalue, rnglists, base);
-		  if (idx != (dwarf_vma) -1)
+		  if (idx != (uint64_t) -1)
 		    idx += base;
 		}
 	    }
@@ -2840,16 +2775,15 @@ read_and_display_attr_value (unsigned long           attribute,
 	    }
 
 	  /* We have already displayed the form name.  */
-	  if (idx != (dwarf_vma) -1)
-	    printf (_("%c(index: 0x%s): %s"), delimiter,
-		    dwarf_vmatoa ("x", uvalue),
-		    dwarf_vmatoa ("x", idx));
+	  if (idx != (uint64_t) -1)
+	    printf (_("%c(index: 0x%" PRIx64 "): %" PRIx64),
+		    delimiter, uvalue, idx);
 	}
       break;
 
     case DW_FORM_strp_sup:
       if (!do_loc)
-	printf ("%c<0x%s>", delimiter, dwarf_vmatoa ("x", uvalue + cu_offset));
+	printf ("%c<0x%" PRIx64 ">", delimiter, uvalue + cu_offset);
       break;
 
     default:
@@ -2867,26 +2801,26 @@ read_and_display_attr_value (unsigned long           attribute,
 	{
 	case DW_AT_loclists_base:
 	  if (debug_info_p->loclists_base)
-	    warn (_("CU @ 0x%s has multiple loclists_base values (0x%s and 0x%s)"),
-		  dwarf_vmatoa ("x", debug_info_p->cu_offset),
-		  dwarf_vmatoa ("x", debug_info_p->loclists_base),
-		  dwarf_vmatoa ("x", uvalue));
+	    warn (_("CU @ %#" PRIx64 " has multiple loclists_base values "
+		    "(%#" PRIx64 " and %#" PRIx64 ")"),
+		  debug_info_p->cu_offset,
+		  debug_info_p->loclists_base, uvalue);
 	  debug_info_p->loclists_base = uvalue;
 	  break;
 	case DW_AT_rnglists_base:
 	  if (debug_info_p->rnglists_base)
-	    warn (_("CU @ 0x%s has multiple rnglists_base values (0x%s and 0x%s)"),
-		  dwarf_vmatoa ("x", debug_info_p->cu_offset),
-		  dwarf_vmatoa ("x", debug_info_p->rnglists_base),
-		  dwarf_vmatoa ("x", uvalue));
+	    warn (_("CU @ %#" PRIx64 " has multiple rnglists_base values "
+		    "(%#" PRIx64 " and %#" PRIx64 ")"),
+		  debug_info_p->cu_offset,
+		  debug_info_p->rnglists_base, uvalue);
 	  debug_info_p->rnglists_base = uvalue;
 	  break;
 	case DW_AT_str_offsets_base:
 	  if (debug_info_p->str_offsets_base)
-	    warn (_("CU @ 0x%s has multiple str_offsets_base values (0x%s and 0x%s)"),
-		  dwarf_vmatoa ("x", debug_info_p->cu_offset),
-		  dwarf_vmatoa ("x", debug_info_p->str_offsets_base),
-		  dwarf_vmatoa ("x", uvalue));
+	    warn (_("CU @ %#" PRIx64 " has multiple str_offsets_base values "
+		    "%#" PRIx64 " and %#" PRIx64 ")"),
+		  debug_info_p->cu_offset,
+		  debug_info_p->str_offsets_base, uvalue);
 	  debug_info_p->str_offsets_base = uvalue;
 	  break;
 
@@ -2922,10 +2856,10 @@ read_and_display_attr_value (unsigned long           attribute,
 	      if (lmax == 0 || num >= lmax)
 		{
 		  lmax += 1024;
-		  debug_info_p->loc_offsets = (dwarf_vma *)
+		  debug_info_p->loc_offsets = (uint64_t *)
 		    xcrealloc (debug_info_p->loc_offsets,
 			       lmax, sizeof (*debug_info_p->loc_offsets));
-		  debug_info_p->loc_views = (dwarf_vma *)
+		  debug_info_p->loc_views = (uint64_t *)
 		    xcrealloc (debug_info_p->loc_views,
 			       lmax, sizeof (*debug_info_p->loc_views));
 		  debug_info_p->have_frame_base = (int *)
@@ -2996,7 +2930,7 @@ read_and_display_attr_value (unsigned long           attribute,
 	      if (lmax == 0 || num >= lmax)
 		{
 		  lmax += 1024;
-		  debug_info_p->range_lists = (dwarf_vma *)
+		  debug_info_p->range_lists = (uint64_t *)
 		    xcrealloc (debug_info_p->range_lists,
 			       lmax, sizeof (*debug_info_p->range_lists));
 		  debug_info_p->max_range_lists = lmax;
@@ -3143,8 +3077,8 @@ read_and_display_attr_value (unsigned long           attribute,
 	  printf (_("(declared as inline and inlined)"));
 	  break;
 	default:
-	  printf (_("  (Unknown inline attribute value: %s)"),
-		  dwarf_vmatoa ("x", uvalue));
+	  printf (_("  (Unknown inline attribute value: %#" PRIx64 ")"),
+		  uvalue);
 	  break;
 	}
       break;
@@ -3200,10 +3134,9 @@ read_and_display_attr_value (unsigned long           attribute,
 	case DW_LANG_Upc:		printf ("(Unified Parallel C)"); break;
 	default:
 	  if (uvalue >= DW_LANG_lo_user && uvalue <= DW_LANG_hi_user)
-	    printf (_("(implementation defined: %s)"),
-		    dwarf_vmatoa ("x", uvalue));
+	    printf (_("(implementation defined: %#" PRIx64 ")"), uvalue);
 	  else
-	    printf (_("(Unknown: %s)"), dwarf_vmatoa ("x", uvalue));
+	    printf (_("(unknown: %#" PRIx64 ")"), uvalue);
 	  break;
 	}
       break;
@@ -3460,9 +3393,9 @@ read_and_display_attr_value (unsigned long           attribute,
 	if (entry == NULL)
 	  {
 	    if (form != DW_FORM_GNU_ref_alt)
-	      warn (_("Offset %s used as value for DW_AT_import attribute of DIE at offset 0x%lx is too big.\n"),
-		    dwarf_vmatoa ("x", uvalue),
-		    (unsigned long) (orig_data - section->start));
+	      warn (_("Offset %#" PRIx64 " used as value for DW_AT_import attribute of DIE at offset %#tx is too big.\n"),
+		    uvalue,
+		    orig_data - section->start);
 	  }
 	else
 	  {
@@ -3481,21 +3414,21 @@ read_and_display_attr_value (unsigned long           attribute,
 }
 
 static unsigned char *
-read_and_display_attr (unsigned long           attribute,
-		       unsigned long           form,
-		       dwarf_signed_vma        implicit_const,
-		       unsigned char *         start,
-		       unsigned char *         data,
-		       unsigned char *         end,
-		       dwarf_vma               cu_offset,
-		       dwarf_vma               pointer_size,
-		       dwarf_vma               offset_size,
-		       int                     dwarf_version,
-		       debug_info *            debug_info_p,
-		       int                     do_loc,
-		       struct dwarf_section *  section,
-		       struct cu_tu_set *      this_set,
-		       int                     level)
+read_and_display_attr (unsigned long attribute,
+		       unsigned long form,
+		       int64_t implicit_const,
+		       unsigned char *start,
+		       unsigned char *data,
+		       unsigned char *end,
+		       uint64_t cu_offset,
+		       uint64_t pointer_size,
+		       uint64_t offset_size,
+		       int dwarf_version,
+		       debug_info *debug_info_p,
+		       int do_loc,
+		       struct dwarf_section *section,
+		       struct cu_tu_set *this_set,
+		       int level)
 {
   if (!do_loc)
     printf ("   %-18s:", get_AT_name (attribute));
@@ -3604,7 +3537,7 @@ process_debug_info (struct dwarf_section * section,
   for (section_begin = start, num_units = 0; section_begin < end;
        num_units ++)
     {
-      dwarf_vma length;
+      uint64_t length;
 
       /* Read the first 4 bytes.  For a 32-bit DWARF section, this
 	 will be the length.  For a 64-bit DWARF section, it'll be
@@ -3615,8 +3548,8 @@ process_debug_info (struct dwarf_section * section,
 	SAFE_BYTE_GET_AND_INC (length, section_begin, 8, end);
       else if (length >= 0xfffffff0 && length < 0xffffffff)
 	{
-	  warn (_("Reserved length value (0x%s) found in section %s\n"),
-		dwarf_vmatoa ("x", length), section->name);
+	  warn (_("Reserved length value (%#" PRIx64 ") found in section %s\n"),
+		length, section->name);
 	  return false;
 	}
 
@@ -3625,10 +3558,9 @@ process_debug_info (struct dwarf_section * section,
 	 relocations to an object file, or if the file is corrupt.  */
       if (length > (size_t) (end - section_begin))
 	{
-	  warn (_("Corrupt unit length (got 0x%s expected at most 0x%s) in section %s\n"),
-		dwarf_vmatoa ("x", length),
-		dwarf_vmatoa ("x", end - section_begin),
-		section->name);
+	  warn (_("Corrupt unit length (got %#" PRIx64
+		  " expected at most %#tx) in section %s\n"),
+		length, end - section_begin, section->name);
 	  return false;
 	}
       section_begin += length;
@@ -3700,13 +3632,13 @@ process_debug_info (struct dwarf_section * section,
      every CU header twice.  */
   for (section_begin = start; start < end;)
     {
-      DWARF2_Internal_CompUnit  compunit;
-      unsigned char *           hdrptr;
-      dwarf_vma                 abbrev_base;
-      size_t                    abbrev_size;
-      dwarf_vma                 cu_offset;
-      unsigned int              offset_size;
-      struct cu_tu_set *        this_set;
+      DWARF2_Internal_CompUnit compunit;
+      unsigned char *hdrptr;
+      uint64_t abbrev_base;
+      size_t abbrev_size;
+      uint64_t cu_offset;
+      unsigned int offset_size;
+      struct cu_tu_set *this_set;
       unsigned char *end_cu;
 
       hdrptr = start;
@@ -3782,12 +3714,12 @@ process_debug_info (struct dwarf_section * section,
       unsigned char *hdrptr;
       unsigned char *tags;
       int level, last_level, saved_level;
-      dwarf_vma cu_offset;
+      uint64_t cu_offset;
       unsigned int offset_size;
-      dwarf_vma signature = 0;
-      dwarf_vma type_offset = 0;
+      uint64_t signature = 0;
+      uint64_t type_offset = 0;
       struct cu_tu_set *this_set;
-      dwarf_vma abbrev_base;
+      uint64_t abbrev_base;
       size_t abbrev_size;
       unsigned char *end_cu;
 
@@ -3896,10 +3828,10 @@ process_debug_info (struct dwarf_section * section,
 
       if (!do_loc && dwarf_start_die == 0)
 	{
-	  printf (_("  Compilation Unit @ offset 0x%s:\n"),
-		  dwarf_vmatoa ("x", cu_offset));
-	  printf (_("   Length:        0x%s (%s)\n"),
-		  dwarf_vmatoa ("x", compunit.cu_length),
+	  printf (_("  Compilation Unit @ offset 0x%" PRIx64 ":\n"),
+		  cu_offset);
+	  printf (_("   Length:        0x%" PRIx64 " (%s)\n"),
+		  compunit.cu_length,
 		  offset_size == 8 ? "64-bit" : "32-bit");
 	  printf (_("   Version:       %d\n"), compunit.cu_version);
 	  if (compunit.cu_version >= 5)
@@ -3910,36 +3842,30 @@ process_debug_info (struct dwarf_section * section,
 		      name ? name : "???",
 		      compunit.cu_unit_type);
 	    }
-	  printf (_("   Abbrev Offset: 0x%s\n"),
-		  dwarf_vmatoa ("x", compunit.cu_abbrev_offset));
+	  printf (_("   Abbrev Offset: 0x%" PRIx64 "\n"),
+		  compunit.cu_abbrev_offset);
 	  printf (_("   Pointer Size:  %d\n"), compunit.cu_pointer_size);
 	  if (do_types)
 	    {
-	      printf (_("   Signature:     0x%s\n"),
-		      dwarf_vmatoa ("x", signature));
-	      printf (_("   Type Offset:   0x%s\n"),
-		      dwarf_vmatoa ("x", type_offset));
+	      printf (_("   Signature:     0x%" PRIx64 "\n"), signature);
+	      printf (_("   Type Offset:   0x%" PRIx64 "\n"), type_offset);
 	    }
 	  if (do_dwo_id)
-	    printf (_("   DWO ID:        0x%s\n"), dwarf_vmatoa ("x", dwo_id));
+	    printf (_("   DWO ID:        0x%" PRIx64 "\n"), dwo_id);
 	  if (this_set != NULL)
 	    {
-	      dwarf_vma *offsets = this_set->section_offsets;
+	      uint64_t *offsets = this_set->section_offsets;
 	      size_t *sizes = this_set->section_sizes;
 
 	      printf (_("   Section contributions:\n"));
-	      printf (_("    .debug_abbrev.dwo:       0x%s  0x%s\n"),
-		      dwarf_vmatoa ("x", offsets [DW_SECT_ABBREV]),
-		      dwarf_vmatoa ("x", sizes [DW_SECT_ABBREV]));
-	      printf (_("    .debug_line.dwo:         0x%s  0x%s\n"),
-		      dwarf_vmatoa ("x", offsets [DW_SECT_LINE]),
-		      dwarf_vmatoa ("x", sizes [DW_SECT_LINE]));
-	      printf (_("    .debug_loc.dwo:          0x%s  0x%s\n"),
-		      dwarf_vmatoa ("x", offsets [DW_SECT_LOC]),
-		      dwarf_vmatoa ("x", sizes [DW_SECT_LOC]));
-	      printf (_("    .debug_str_offsets.dwo:  0x%s  0x%s\n"),
-		      dwarf_vmatoa ("x", offsets [DW_SECT_STR_OFFSETS]),
-		      dwarf_vmatoa ("x", sizes [DW_SECT_STR_OFFSETS]));
+	      printf (_("    .debug_abbrev.dwo:       0x%" PRIx64 "  0x%zx\n"),
+		      offsets[DW_SECT_ABBREV], sizes[DW_SECT_ABBREV]);
+	      printf (_("    .debug_line.dwo:         0x%" PRIx64 "  0x%zx\n"),
+		      offsets[DW_SECT_LINE], sizes[DW_SECT_LINE]);
+	      printf (_("    .debug_loc.dwo:          0x%" PRIx64 "  0x%zx\n"),
+		      offsets[DW_SECT_LOC], sizes[DW_SECT_LOC]);
+	      printf (_("    .debug_str_offsets.dwo:  0x%" PRIx64 "  0x%zx\n"),
+		      offsets[DW_SECT_STR_OFFSETS], sizes[DW_SECT_STR_OFFSETS]);
 	    }
 	}
 
@@ -3948,9 +3874,9 @@ process_debug_info (struct dwarf_section * section,
 
       if (compunit.cu_version < 2 || compunit.cu_version > 5)
 	{
-	  warn (_("CU at offset %s contains corrupt or "
+	  warn (_("CU at offset %#" PRIx64 " contains corrupt or "
 		  "unsupported version number: %d.\n"),
-		dwarf_vmatoa ("x", cu_offset), compunit.cu_version);
+		cu_offset, compunit.cu_version);
 	  continue;
 	}
 
@@ -3960,9 +3886,9 @@ process_debug_info (struct dwarf_section * section,
 	  && compunit.cu_unit_type != DW_UT_split_compile
 	  && compunit.cu_unit_type != DW_UT_skeleton)
 	{
-	  warn (_("CU at offset %s contains corrupt or "
+	  warn (_("CU at offset %#" PRIx64 " contains corrupt or "
 		  "unsupported unit type: %d.\n"),
-		dwarf_vmatoa ("x", cu_offset), compunit.cu_unit_type);
+		cu_offset, compunit.cu_unit_type);
 	  continue;
 	}
 
@@ -4062,7 +3988,7 @@ process_debug_info (struct dwarf_section * section,
 		  printf ("\n");
 		  fflush (stdout);
 		}
-	      warn (_("DIE at offset 0x%lx refers to abbreviation number %lu which does not exist\n"),
+	      warn (_("DIE at offset %#lx refers to abbreviation number %lu which does not exist\n"),
 		    die_offset, abbrev_number);
 	      return false;
 	    }
@@ -4102,7 +4028,7 @@ process_debug_info (struct dwarf_section * section,
 	    {
 	      if (! do_loc && do_printing)
 		/* Show the offset from where the tag was extracted.  */
-		printf ("    <%lx>", (unsigned long)(tags - section_begin));
+		printf ("    <%tx>", tags - section_begin);
 	      tags = read_and_display_attr (attr->attribute,
 					    attr->form,
 					    attr->implicit_const,
@@ -4127,7 +4053,7 @@ process_debug_info (struct dwarf_section * section,
 	    switch (debug_info_p->num_loc_offsets - debug_info_p->num_loc_views)
 	      {
 	      case 1:
-		debug_info_p->loc_views [debug_info_p->num_loc_views] = vm1;
+		debug_info_p->loc_views [debug_info_p->num_loc_views] = -1;
 		debug_info_p->num_loc_views++;
 		assert (debug_info_p->num_loc_views
 			== debug_info_p->num_loc_offsets);
@@ -4248,8 +4174,10 @@ read_debug_line_header (struct dwarf_section * section,
 	}
       else
 	{
-	  warn (_("The length field (0x%lx) in the debug_line header is wrong - the section is too small\n"),
-		(long) linfo->li_length);
+	  warn (_("The length field (%#" PRIx64 ")"
+		  " in the debug_line header is wrong"
+		  " - the section is too small\n"),
+		linfo->li_length);
 	  return NULL;
 	}
     }
@@ -4317,7 +4245,7 @@ display_formatted_table (unsigned char *data,
 			 bool is_dir)
 {
   unsigned char *format_start, format_count, *format, formati;
-  dwarf_vma data_count, datai;
+  uint64_t data_count, datai;
   unsigned int namepass, last_entry = 0;
   const char * table_name = is_dir ? N_("Directory Table") : N_("File Name Table");
 
@@ -4346,8 +4274,8 @@ display_formatted_table (unsigned char *data,
     }
   else if (data >= end)
     {
-      warn (_("%s: Corrupt entry count - expected %s but none found\n"),
-	    table_name, dwarf_vmatoa ("x", data_count));
+      warn (_("%s: Corrupt entry count - expected %#" PRIx64
+	      " but none found\n"), table_name, data_count);
       return data;
     }
 
@@ -4358,9 +4286,8 @@ display_formatted_table (unsigned char *data,
       return end;
     }
 
-  printf (_("\n The %s (offset 0x%lx, lines %s, columns %u):\n"),
-	  table_name, (long) (data - start), dwarf_vmatoa ("u", data_count),
-	  format_count);
+  printf (_("\n The %s (offset 0x%tx, lines %" PRIu64 ", columns %u):\n"),
+	  table_name, data - start, data_count, format_count);
 
   printf (_("  Entry"));
   /* Delay displaying name as the last entry for better screen layout.  */
@@ -4369,7 +4296,7 @@ display_formatted_table (unsigned char *data,
       format = format_start;
       for (formati = 0; formati < format_count; formati++)
 	{
-	  dwarf_vma content_type;
+	  uint64_t content_type;
 
 	  READ_ULEB (content_type, format, end);
 	  if ((content_type == DW_LNCT_path) == (namepass == 1))
@@ -4391,8 +4318,8 @@ display_formatted_table (unsigned char *data,
 		printf (_("\tMD5\t\t\t"));
 		break;
 	      default:
-		printf (_("\t(Unknown format content type %s)"),
-			dwarf_vmatoa ("u", content_type));
+		printf (_("\t(Unknown format content type %" PRIu64 ")"),
+			content_type);
 	      }
 	  SKIP_ULEB (format, end);
 	}
@@ -4411,7 +4338,7 @@ display_formatted_table (unsigned char *data,
 	  data = datapass;
 	  for (formati = 0; formati < format_count; formati++)
 	    {
-	      dwarf_vma content_type, form;
+	      uint64_t content_type, form;
 
 	      READ_ULEB (content_type, format, end);
 	      READ_ULEB (form, format, end);
@@ -4445,7 +4372,7 @@ display_debug_sup (struct dwarf_section *  section,
   size_t sup_filename_len;
   unsigned int num_read;
   int status;
-  dwarf_vma checksum_len;
+  uint64_t checksum_len;
 
 
   introduce (section, true);
@@ -4483,21 +4410,22 @@ display_debug_sup (struct dwarf_section *  section,
       checksum_len = 0;
     }
   start += num_read;
-  if (checksum_len > (dwarf_vma) (end - start))
+  if (checksum_len > (size_t) (end - start))
     {
       error (_("corrupt .debug_sup section: checksum length is longer than the remaining section length\n"));
       checksum_len = end - start;
     }
-  else if (checksum_len < (dwarf_vma) (end - start))
+  else if (checksum_len < (size_t) (end - start))
     {
-      warn (_("corrupt .debug_sup section: there are 0x%lx extra, unused bytes at the end of the section\n"),
-	    (long) ((end - start) - checksum_len));
+      warn (_("corrupt .debug_sup section: there are %#" PRIx64
+	      " extra, unused bytes at the end of the section\n"),
+	    (end - start) - checksum_len);
     }
 
   printf (_("  Version:      %u\n"), version);
   printf (_("  Is Supp:      %u\n"), is_supplementary);
   printf (_("  Filename:     %s\n"), sup_filename);
-  printf (_("  Checksum Len: %lu\n"), (long) checksum_len);
+  printf (_("  Checksum Len: %" PRIu64 "\n"), checksum_len);
   if (checksum_len > 0)
     {
       printf (_("  Checksum:     "));
@@ -4561,8 +4489,8 @@ display_debug_lines_raw (struct dwarf_section *  section,
 						& end_of_sequence)) == NULL)
 	    return 0;
 
-	  printf (_("  Offset:                      0x%lx\n"), (long)(data - start));
-	  printf (_("  Length:                      %ld\n"), (long) linfo.li_length);
+	  printf (_("  Offset:                      0x%tx\n"), data - start);
+	  printf (_("  Length:                      %" PRId64 "\n"), linfo.li_length);
 	  printf (_("  DWARF Version:               %d\n"), linfo.li_version);
 	  if (linfo.li_version >= 5)
 	    {
@@ -4625,8 +4553,8 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		{
 		  unsigned int last_dir_entry = 0;
 
-		  printf (_("\n The Directory Table (offset 0x%lx):\n"),
-			  (long)(data - start));
+		  printf (_("\n The Directory Table (offset 0x%tx):\n"),
+			  data - start);
 
 		  while (data < end && *data != 0)
 		    {
@@ -4651,14 +4579,14 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		printf (_("\n The File Name Table is empty.\n"));
 	      else
 		{
-		  printf (_("\n The File Name Table (offset 0x%lx):\n"),
-			  (long)(data - start));
+		  printf (_("\n The File Name Table (offset 0x%tx):\n"),
+			  data - start);
 		  printf (_("  Entry\tDir\tTime\tSize\tName\n"));
 
 		  while (data < end && *data != 0)
 		    {
 		      unsigned char *name;
-		      dwarf_vma val;
+		      uint64_t val;
 
 		      printf ("  %d\t", ++state_machine_regs.last_file_entry);
 		      name = data;
@@ -4667,11 +4595,11 @@ display_debug_lines_raw (struct dwarf_section *  section,
 			data++;
 
 		      READ_ULEB (val, data, end);
-		      printf ("%s\t", dwarf_vmatoa ("u", val));
+		      printf ("%" PRIu64 "\t", val);
 		      READ_ULEB (val, data, end);
-		      printf ("%s\t", dwarf_vmatoa ("u", val));
+		      printf ("%" PRIu64 "\t", val);
 		      READ_ULEB (val, data, end);
-		      printf ("%s\t", dwarf_vmatoa ("u", val));
+		      printf ("%" PRIu64 "\t", val);
 		      printf ("%.*s\n", (int)(end - name), name);
 
 		      if (data >= end)
@@ -4701,10 +4629,10 @@ display_debug_lines_raw (struct dwarf_section *  section,
 	  while (data < end_of_sequence)
 	    {
 	      unsigned char op_code;
-	      dwarf_signed_vma adv;
-	      dwarf_vma uladv;
+	      int64_t adv;
+	      uint64_t uladv;
 
-	      printf ("  [0x%08lx]", (long)(data - start));
+	      printf ("  [0x%08tx]", data - start);
 
 	      op_code = *data++;
 
@@ -4719,9 +4647,9 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		      if (uladv)
 			state_machine_regs.view = 0;
 		      printf (_("  Special opcode %d: "
-				"advance Address by %s to 0x%s%s"),
-			      op_code, dwarf_vmatoa ("u", uladv),
-			      dwarf_vmatoa ("x", state_machine_regs.address),
+				"advance Address by %" PRIu64
+				" to 0x%" PRIx64 "%s"),
+			      op_code, uladv, state_machine_regs.address,
 			      verbose_view && uladv
 			      ? _(" (reset view)") : "");
 		    }
@@ -4739,17 +4667,17 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		      if (addrdelta)
 			state_machine_regs.view = 0;
 		      printf (_("  Special opcode %d: "
-				"advance Address by %s to 0x%s[%d]%s"),
-			      op_code, dwarf_vmatoa ("u", uladv),
-			      dwarf_vmatoa ("x", state_machine_regs.address),
+				"advance Address by %" PRIu64
+				" to 0x%" PRIx64 "[%d]%s"),
+			      op_code, uladv, state_machine_regs.address,
 			      state_machine_regs.op_index,
 			      verbose_view && addrdelta
 			      ? _(" (reset view)") : "");
 		    }
 		  adv = (op_code % linfo.li_line_range) + linfo.li_line_base;
 		  state_machine_regs.line += adv;
-		  printf (_(" and Line by %s to %d"),
-			  dwarf_vmatoa ("d", adv), state_machine_regs.line);
+		  printf (_(" and Line by %" PRId64 " to %d"),
+			  adv, state_machine_regs.line);
 		  if (verbose_view || state_machine_regs.view)
 		    printf (_(" (view %u)\n"), state_machine_regs.view);
 		  else
@@ -4782,9 +4710,9 @@ display_debug_lines_raw (struct dwarf_section *  section,
 			state_machine_regs.address += uladv;
 			if (uladv)
 			  state_machine_regs.view = 0;
-			printf (_("  Advance PC by %s to 0x%s%s\n"),
-				dwarf_vmatoa ("u", uladv),
-				dwarf_vmatoa ("x", state_machine_regs.address),
+			printf (_("  Advance PC by %" PRIu64
+				  " to 0x%" PRIx64 "%s\n"),
+				uladv, state_machine_regs.address,
 				verbose_view && uladv
 				? _(" (reset view)") : "");
 		      }
@@ -4801,9 +4729,9 @@ display_debug_lines_raw (struct dwarf_section *  section,
 			  % linfo.li_max_ops_per_insn;
 			if (addrdelta)
 			  state_machine_regs.view = 0;
-			printf (_("  Advance PC by %s to 0x%s[%d]%s\n"),
-				dwarf_vmatoa ("u", uladv),
-				dwarf_vmatoa ("x", state_machine_regs.address),
+			printf (_("  Advance PC by %" PRIu64
+				  " to 0x%" PRIx64 "[%d]%s\n"),
+				uladv, state_machine_regs.address,
 				state_machine_regs.op_index,
 				verbose_view && addrdelta
 				? _(" (reset view)") : "");
@@ -4813,29 +4741,27 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		  case DW_LNS_advance_line:
 		    READ_SLEB (adv, data, end);
 		    state_machine_regs.line += adv;
-		    printf (_("  Advance Line by %s to %d\n"),
-			    dwarf_vmatoa ("d", adv),
-			    state_machine_regs.line);
+		    printf (_("  Advance Line by %" PRId64 " to %d\n"),
+			    adv, state_machine_regs.line);
 		    break;
 
 		  case DW_LNS_set_file:
 		    READ_ULEB (uladv, data, end);
-		    printf (_("  Set File Name to entry %s in the File Name Table\n"),
-			    dwarf_vmatoa ("u", uladv));
+		    printf (_("  Set File Name to entry %" PRIu64
+			      " in the File Name Table\n"), uladv);
 		    state_machine_regs.file = uladv;
 		    break;
 
 		  case DW_LNS_set_column:
 		    READ_ULEB (uladv, data, end);
-		    printf (_("  Set column to %s\n"),
-			    dwarf_vmatoa ("u", uladv));
+		    printf (_("  Set column to %" PRIu64 "\n"), uladv);
 		    state_machine_regs.column = uladv;
 		    break;
 
 		  case DW_LNS_negate_stmt:
 		    adv = state_machine_regs.is_stmt;
 		    adv = ! adv;
-		    printf (_("  Set is_stmt to %s\n"), dwarf_vmatoa ("d", adv));
+		    printf (_("  Set is_stmt to %" PRId64 "\n"), adv);
 		    state_machine_regs.is_stmt = adv;
 		    break;
 
@@ -4852,9 +4778,9 @@ display_debug_lines_raw (struct dwarf_section *  section,
 			state_machine_regs.address += uladv;
 			if (uladv)
 			  state_machine_regs.view = 0;
-			printf (_("  Advance PC by constant %s to 0x%s%s\n"),
-				dwarf_vmatoa ("u", uladv),
-				dwarf_vmatoa ("x", state_machine_regs.address),
+			printf (_("  Advance PC by constant %" PRIu64
+				  " to 0x%" PRIx64 "%s\n"),
+				uladv, state_machine_regs.address,
 				verbose_view && uladv
 				? _(" (reset view)") : "");
 		      }
@@ -4871,9 +4797,9 @@ display_debug_lines_raw (struct dwarf_section *  section,
 			  % linfo.li_max_ops_per_insn;
 			if (addrdelta)
 			  state_machine_regs.view = 0;
-			printf (_("  Advance PC by constant %s to 0x%s[%d]%s\n"),
-				dwarf_vmatoa ("u", uladv),
-				dwarf_vmatoa ("x", state_machine_regs.address),
+			printf (_("  Advance PC by constant %" PRIu64
+				  " to 0x%" PRIx64 "[%d]%s\n"),
+				uladv, state_machine_regs.address,
 				state_machine_regs.op_index,
 				verbose_view && addrdelta
 				? _(" (reset view)") : "");
@@ -4884,9 +4810,9 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		    SAFE_BYTE_GET_AND_INC (uladv, data, 2, end);
 		    state_machine_regs.address += uladv;
 		    state_machine_regs.op_index = 0;
-		    printf (_("  Advance PC by fixed size amount %s to 0x%s\n"),
-			    dwarf_vmatoa ("u", uladv),
-			    dwarf_vmatoa ("x", state_machine_regs.address));
+		    printf (_("  Advance PC by fixed size amount %" PRIu64
+			      " to 0x%" PRIx64 "\n"),
+			    uladv, state_machine_regs.address);
 		    /* Do NOT reset view.  */
 		    break;
 
@@ -4900,7 +4826,7 @@ display_debug_lines_raw (struct dwarf_section *  section,
 
 		  case DW_LNS_set_isa:
 		    READ_ULEB (uladv, data, end);
-		    printf (_("  Set ISA to %s\n"), dwarf_vmatoa ("u", uladv));
+		    printf (_("  Set ISA to %" PRIu64 "\n"), uladv);
 		    break;
 
 		  default:
@@ -4910,8 +4836,7 @@ display_debug_lines_raw (struct dwarf_section *  section,
 		      for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
 			{
 			  READ_ULEB (uladv, data, end);
-			  printf ("0x%s%s", dwarf_vmatoa ("x", uladv),
-				  i == 1 ? "" : ", ");
+			  printf ("0x%" PRIx64 "%s", uladv, i == 1 ? "" : ", ");
 			}
 		    putchar ('\n');
 		    break;
@@ -4955,7 +4880,7 @@ display_debug_lines_decoded (struct dwarf_section *  section,
       File_Entry *file_table = NULL;
       unsigned int n_files = 0;
       unsigned char **directory_table = NULL;
-      dwarf_vma n_directories = 0;
+      uint64_t n_directories = 0;
 
       if (startswith (section->name, ".debug_line.")
 	  /* Note: the following does not apply to .debug_line.dwo sections.
@@ -5006,7 +4931,7 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 	  if (linfo.li_version >= 5)
 	    {
 	      unsigned char *format_start, format_count, *format;
-	      dwarf_vma formati, entryi;
+	      uint64_t formati, entryi;
 
 	      load_debug_section_with_follow (line_str, fileptr);
 
@@ -5042,8 +4967,8 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		  format = format_start;
 		  for (formati = 0; formati < format_count; formati++)
 		    {
-		      dwarf_vma content_type, form;
-		      dwarf_vma uvalue;
+		      uint64_t content_type, form;
+		      uint64_t uvalue;
 
 		      READ_ULEB (content_type, format, end);
 		      READ_ULEB (form, format, end);
@@ -5116,8 +5041,8 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		  format = format_start;
 		  for (formati = 0; formati < format_count; formati++)
 		    {
-		      dwarf_vma content_type, form;
-		      dwarf_vma uvalue;
+		      uint64_t content_type, form;
+		      uint64_t uvalue;
 		      unsigned char *tmp;
 
 		      READ_ULEB (content_type, format, end);
@@ -5282,8 +5207,8 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		directory = _("<unknown>");
 	      else if (ix > n_directories)
 		{
-		  warn (_("directory index %u > number of directories %s\n"),
-			ix, dwarf_vmatoa ("u", n_directories));
+		  warn (_("directory index %u > number of directories %" PRIu64 "\n"),
+			ix, n_directories);
 		  directory = _("<corrupt>");
 		}
 	      else
@@ -5473,8 +5398,8 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		  /* PR 20439 */
 		  else if (dir > n_directories)
 		    {
-		      warn (_("directory index %u > number of directories %s\n"),
-			    dir, dwarf_vmatoa ("u", n_directories));
+		      warn (_("directory index %u > number of directories %" PRIu64 "\n"),
+			    dir, n_directories);
 		      printf (_("\n <over large directory table entry %u>\n"), dir);
 		    }
 		  else
@@ -5548,11 +5473,10 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		if (standard_opcodes != NULL)
 		  for (i = standard_opcodes[op_code - 1]; i > 0 ; --i)
 		    {
-		      dwarf_vma val;
+		      uint64_t val;
 
 		      READ_ULEB (val, data, end);
-		      printf ("0x%s%s", dwarf_vmatoa ("x", val),
-			      i == 1 ? "" : ", ");
+		      printf ("0x%" PRIx64 "%s", val, i == 1 ? "" : ", ");
 		    }
 		putchar ('\n');
 		break;
@@ -5607,23 +5531,23 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		  if (linfo.li_max_ops_per_insn == 1)
 		    {
 		      if (xop == -DW_LNE_end_sequence)
-			printf ("%-35s  %11s  %#18" DWARF_VMA_FMT "x",
+			printf ("%-35s  %11s  %#18" PRIx64,
 				newFileName, "-",
 				state_machine_regs.address);
 		      else
-			printf ("%-35s  %11d  %#18" DWARF_VMA_FMT "x",
+			printf ("%-35s  %11d  %#18" PRIx64,
 				newFileName, state_machine_regs.line,
 				state_machine_regs.address);
 		    }
 		  else
 		    {
 		      if (xop == -DW_LNE_end_sequence)
-			printf ("%-35s  %11s  %#18" DWARF_VMA_FMT "x[%d]",
+			printf ("%-35s  %11s  %#18" PRIx64 "[%d]",
 				newFileName, "-",
 				state_machine_regs.address,
 				state_machine_regs.op_index);
 		      else
-			printf ("%-35s  %11d  %#18" DWARF_VMA_FMT "x[%d]",
+			printf ("%-35s  %11d  %#18" PRIx64 "[%d]",
 				newFileName, state_machine_regs.line,
 				state_machine_regs.address,
 				state_machine_regs.op_index);
@@ -5634,23 +5558,23 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		  if (linfo.li_max_ops_per_insn == 1)
 		    {
 		      if (xop == -DW_LNE_end_sequence)
-			printf ("%s  %11s  %#18" DWARF_VMA_FMT "x",
+			printf ("%s  %11s  %#18" PRIx64,
 				newFileName, "-",
 				state_machine_regs.address);
 		      else
-			printf ("%s  %11d  %#18" DWARF_VMA_FMT "x",
+			printf ("%s  %11d  %#18" PRIx64,
 				newFileName, state_machine_regs.line,
 				state_machine_regs.address);
 		    }
 		  else
 		    {
 		      if (xop == -DW_LNE_end_sequence)
-			printf ("%s  %11s  %#18" DWARF_VMA_FMT "x[%d]",
+			printf ("%s  %11s  %#18" PRIx64 "[%d]",
 				newFileName, "-",
 				state_machine_regs.address,
 				state_machine_regs.op_index);
 		      else
-			printf ("%s  %11d  %#18" DWARF_VMA_FMT "x[%d]",
+			printf ("%s  %11d  %#18" PRIx64 "[%d]",
 				newFileName, state_machine_regs.line,
 				state_machine_regs.address,
 				state_machine_regs.op_index);
@@ -5726,7 +5650,7 @@ display_debug_lines (struct dwarf_section *section, void *file)
 }
 
 static debug_info *
-find_debug_info_for_offset (dwarf_vma offset)
+find_debug_info_for_offset (uint64_t offset)
 {
   unsigned int i;
 
@@ -5791,10 +5715,9 @@ display_debug_pubnames_worker (struct dwarf_section *section,
 
       if (names.pn_length > (size_t) (end - start))
 	{
-	  warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
-		section->name,
-		sec_off,
-		dwarf_vmatoa ("x", names.pn_length));
+	  warn (_("Debug info is corrupted, "
+		  "%s header at %#lx has length %#" PRIx64 "\n"),
+		section->name, sec_off, names.pn_length);
 	  break;
 	}
 
@@ -5807,19 +5730,20 @@ display_debug_pubnames_worker (struct dwarf_section *section,
       if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
 	  && num_debug_info_entries > 0
 	  && find_debug_info_for_offset (names.pn_offset) == NULL)
-	warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
-	      (unsigned long) names.pn_offset, section->name);
+	warn (_(".debug_info offset of %#" PRIx64
+		" in %s section does not point to a CU header.\n"),
+	      names.pn_offset, section->name);
 
       SAFE_BYTE_GET_AND_INC (names.pn_size, data, offset_size, start);
 
-      printf (_("  Length:                              %ld\n"),
-	      (long) names.pn_length);
+      printf (_("  Length:                              %" PRId64 "\n"),
+	      names.pn_length);
       printf (_("  Version:                             %d\n"),
 	      names.pn_version);
-      printf (_("  Offset into .debug_info section:     0x%lx\n"),
-	      (unsigned long) names.pn_offset);
-      printf (_("  Size of area in .debug_info section: %ld\n"),
-	      (long) names.pn_size);
+      printf (_("  Offset into .debug_info section:     0x%" PRIx64 "\n"),
+	      names.pn_offset);
+      printf (_("  Size of area in .debug_info section: %" PRId64 "\n"),
+	      names.pn_size);
 
       if (names.pn_version != 2 && names.pn_version != 3)
 	{
@@ -5842,7 +5766,7 @@ display_debug_pubnames_worker (struct dwarf_section *section,
       while (1)
 	{
 	  size_t maxprint;
-	  dwarf_vma offset;
+	  uint64_t offset;
 
 	  SAFE_BYTE_GET_AND_INC (offset, data, offset_size, start);
 
@@ -5870,13 +5794,13 @@ display_debug_pubnames_worker (struct dwarf_section *section,
 	      kind = GDB_INDEX_SYMBOL_KIND_VALUE (kind_data);
 	      kind_name = get_gdb_index_symbol_kind_name (kind);
 	      is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (kind_data);
-	      printf ("    %-6lx  %s,%-10s  %.*s\n",
-		      (unsigned long) offset, is_static ? _("s") : _("g"),
+	      printf ("    %-6" PRIx64 "  %s,%-10s  %.*s\n",
+		      offset, is_static ? _("s") : _("g"),
 		      kind_name, (int) maxprint, data);
 	    }
 	  else
-	    printf ("    %-6lx\t%.*s\n",
-		    (unsigned long) offset, (int) maxprint, data);
+	    printf ("    %-6" PRIx64 "\t%.*s\n",
+		    offset, (int) maxprint, data);
 
 	  data += strnlen ((char *) data, maxprint);
 	  if (data < start)
@@ -5982,15 +5906,15 @@ display_debug_macinfo (struct dwarf_section *section,
    FILEIDX.  Return NULL on failure.  */
 
 static unsigned char *
-get_line_filename_and_dirname (dwarf_vma line_offset,
-			       dwarf_vma fileidx,
+get_line_filename_and_dirname (uint64_t line_offset,
+			       uint64_t fileidx,
 			       unsigned char **dir_name)
 {
   struct dwarf_section *section = &debug_displays [line].section;
   unsigned char *hdrptr, *dirtable, *file_name;
   unsigned int offset_size;
   unsigned int version, opcode_base;
-  dwarf_vma length, diridx;
+  uint64_t length, diridx;
   const unsigned char * end;
 
   *dir_name = NULL;
@@ -6103,7 +6027,7 @@ display_debug_macro (struct dwarf_section *section,
       unsigned int lineno, version, flags;
       unsigned int offset_size;
       const unsigned char *string;
-      dwarf_vma line_offset = 0, sec_offset = curr - start, offset;
+      uint64_t line_offset = 0, sec_offset = curr - start, offset;
       unsigned char **extended_ops = NULL;
 
       SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
@@ -6116,20 +6040,19 @@ display_debug_macro (struct dwarf_section *section,
 
       SAFE_BYTE_GET_AND_INC (flags, curr, 1, end);
       offset_size = (flags & 1) ? 8 : 4;
-      printf (_("  Offset:                      0x%lx\n"),
-	      (unsigned long) sec_offset);
+      printf (_("  Offset:                      0x%" PRIx64 "\n"), sec_offset);
       printf (_("  Version:                     %d\n"), version);
       printf (_("  Offset size:                 %d\n"), offset_size);
       if (flags & 2)
 	{
 	  SAFE_BYTE_GET_AND_INC (line_offset, curr, offset_size, end);
-	  printf (_("  Offset into .debug_line:     0x%lx\n"),
-		  (unsigned long) line_offset);
+	  printf (_("  Offset into .debug_line:     0x%" PRIx64 "\n"),
+		  line_offset);
 	}
       if (flags & 4)
 	{
 	  unsigned int i, count, op;
-	  dwarf_vma nargs, n;
+	  uint64_t nargs, n;
 
 	  SAFE_BYTE_GET_AND_INC (count, curr, 1, end);
 
@@ -6273,28 +6196,30 @@ display_debug_macro (struct dwarf_section *section,
 
 	    case DW_MACRO_import:
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_import - offset : 0x%lx\n"),
-		      (unsigned long) offset);
+	      printf (_(" DW_MACRO_import - offset : 0x%" PRIx64 "\n"),
+		      offset);
 	      break;
 
 	    case DW_MACRO_define_sup:
 	      READ_ULEB (lineno, curr, end);
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_define_sup - lineno : %d macro offset : 0x%lx\n"),
-		      lineno, (unsigned long) offset);
+	      printf (_(" DW_MACRO_define_sup - lineno : %d"
+			" macro offset : 0x%" PRIx64 "\n"),
+		      lineno, offset);
 	      break;
 
 	    case DW_MACRO_undef_sup:
 	      READ_ULEB (lineno, curr, end);
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_undef_sup - lineno : %d macro offset : 0x%lx\n"),
-		      lineno, (unsigned long) offset);
+	      printf (_(" DW_MACRO_undef_sup - lineno : %d"
+			" macro offset : 0x%" PRIx64 "\n"),
+		      lineno, offset);
 	      break;
 
 	    case DW_MACRO_import_sup:
 	      SAFE_BYTE_GET_AND_INC (offset, curr, offset_size, end);
-	      printf (_(" DW_MACRO_import_sup - offset : 0x%lx\n"),
-		      (unsigned long) offset);
+	      printf (_(" DW_MACRO_import_sup - offset : 0x%" PRIx64 "\n"),
+		      offset);
 	      break;
 
 	    case DW_MACRO_define_strx:
@@ -6308,7 +6233,7 @@ display_debug_macro (struct dwarf_section *section,
 	      else
 		printf (" DW_MACRO_undef_strx ");
 	      if (do_wide)
-		printf (_("(with offset %s) "), dwarf_vmatoa ("x", offset));
+		printf (_("(with offset %" PRIx64 ") "), offset);
 	      printf (_("lineno : %d macro : %s\n"),
 		      lineno, string);
 	      break;
@@ -6328,7 +6253,7 @@ display_debug_macro (struct dwarf_section *section,
 	      else
 		{
 		  /* Skip over unhandled opcodes.  */
-		  dwarf_vma nargs, n;
+		  uint64_t nargs, n;
 		  unsigned char *desc = extended_ops[op];
 		  READ_ULEB (nargs, desc, end);
 		  if (nargs == 0)
@@ -6375,7 +6300,7 @@ display_debug_abbrev (struct dwarf_section *section,
 
   do
     {
-      dwarf_vma offset = start - section->start;
+      uint64_t offset = start - section->start;
       abbrev_list *list = find_and_process_abbrev_set (section, 0,
 						       section->size, offset,
 						       NULL);
@@ -6383,7 +6308,7 @@ display_debug_abbrev (struct dwarf_section *section,
 	break;
 
       if (list->first_abbrev)
-	printf (_("  Number TAG (0x%lx)\n"), (long) offset);
+	printf (_("  Number TAG (0x%" PRIx64 ")\n"), offset);
 
       for (entry = list->first_abbrev; entry; entry = entry->next)
 	{
@@ -6400,7 +6325,7 @@ display_debug_abbrev (struct dwarf_section *section,
 		      get_AT_name (attr->attribute),
 		      get_FORM_name (attr->form));
 	      if (attr->form == DW_FORM_implicit_const)
-		printf (": %s", dwarf_vmatoa ("d", attr->implicit_const));
+		printf (": %" PRId64, attr->implicit_const);
 	      putchar ('\n');
 	    }
 	}
@@ -6418,9 +6343,9 @@ display_debug_abbrev (struct dwarf_section *section,
    POINTER_SIZE bytes long.  */
 
 static bool
-is_max_address (dwarf_vma addr, unsigned int pointer_size)
+is_max_address (uint64_t addr, unsigned int pointer_size)
 {
-  dwarf_vma mask = ~(~(dwarf_vma) 1 << (pointer_size * 8 - 1));
+  uint64_t mask = ~(~(uint64_t) 0 << 1 << (pointer_size * 8 - 1));
   return ((addr & mask) == mask);
 }
 
@@ -6444,18 +6369,18 @@ display_view_pair_list (struct dwarf_section *section,
 
   while (vstart < section_end)
     {
-      dwarf_vma off = vstart - section->start;
-      dwarf_vma vbegin, vend;
+      uint64_t off = vstart - section->start;
+      uint64_t vbegin, vend;
 
       READ_ULEB (vbegin, vstart, section_end);
       if (vstart == section_end)
 	break;
 
       READ_ULEB (vend, vstart, section_end);
-      printf ("    %8.8lx ", (unsigned long) off);
+      printf ("    %8.8" PRIx64 " ", off);
 
-      print_dwarf_view (vbegin, pointer_size, 1);
-      print_dwarf_view (vend, pointer_size, 1);
+      print_view (vbegin, pointer_size);
+      print_view (vend, pointer_size);
       printf (_("location view pair\n"));
     }
 
@@ -6469,19 +6394,19 @@ static void
 display_loc_list (struct dwarf_section *section,
 		  unsigned char **start_ptr,
 		  unsigned int debug_info_entry,
-		  dwarf_vma offset,
-		  dwarf_vma base_address,
+		  uint64_t offset,
+		  uint64_t base_address,
 		  unsigned char **vstart_ptr,
 		  int has_frame_base)
 {
   unsigned char *start = *start_ptr, *vstart = *vstart_ptr;
   unsigned char *section_end = section->start + section->size;
-  dwarf_vma    cu_offset;
+  uint64_t cu_offset;
   unsigned int pointer_size;
   unsigned int offset_size;
   int dwarf_version;
-  dwarf_vma begin;
-  dwarf_vma end;
+  uint64_t begin;
+  uint64_t end;
   unsigned short length;
   int need_frame_base;
 
@@ -6506,18 +6431,18 @@ display_loc_list (struct dwarf_section *section,
 
   while (1)
     {
-      dwarf_vma off = offset + (start - *start_ptr);
-      dwarf_vma vbegin = vm1, vend = vm1;
+      uint64_t off = offset + (start - *start_ptr);
+      uint64_t vbegin = -1, vend = -1;
 
       if (2 * pointer_size > (size_t) (section_end - start))
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
       printf ("    ");
-      print_dwarf_vma (off, 4);
+      print_hex (off, 4);
 
       SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);
       SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end);
@@ -6543,8 +6468,8 @@ display_loc_list (struct dwarf_section *section,
 	  && !is_max_address (end, pointer_size))
 	{
 	  base_address = end;
-	  print_dwarf_vma (begin, pointer_size);
-	  print_dwarf_vma (end, pointer_size);
+	  print_hex (begin, pointer_size);
+	  print_hex (end, pointer_size);
 	  printf (_("(base address)\n"));
 	  continue;
 	}
@@ -6554,19 +6479,18 @@ display_loc_list (struct dwarf_section *section,
 	  off = offset + (vstart - *start_ptr);
 
 	  READ_ULEB (vbegin, vstart, section_end);
-	  print_dwarf_view (vbegin, pointer_size, 1);
+	  print_view (vbegin, pointer_size);
 
 	  READ_ULEB (vend, vstart, section_end);
-	  print_dwarf_view (vend, pointer_size, 1);
+	  print_view (vend, pointer_size);
 
-	  printf (_("views at %8.8lx for:\n    %*s "),
-		  (unsigned long) off, 8, "");
+	  printf (_("views at %8.8" PRIx64 " for:\n    %*s "), off, 8, "");
 	}
 
       if (2 > (size_t) (section_end - start))
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
@@ -6574,13 +6498,13 @@ display_loc_list (struct dwarf_section *section,
 
       if (length > (size_t) (section_end - start))
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
-      print_dwarf_vma (begin + base_address, pointer_size);
-      print_dwarf_vma (end + base_address, pointer_size);
+      print_hex (begin + base_address, pointer_size);
+      print_hex (end + base_address, pointer_size);
 
       putchar ('(');
       need_frame_base = decode_location_expression (start,
@@ -6614,23 +6538,23 @@ 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,
+		       uint64_t                offset,
+		       uint64_t                base_address,
 		       unsigned char **        vstart_ptr,
 		       int                     has_frame_base)
 {
-  unsigned char *  start = *start_ptr;
-  unsigned char *  vstart = *vstart_ptr;
-  unsigned char *  section_end = section->start + section->size;
-  dwarf_vma        cu_offset;
-  unsigned int     pointer_size;
-  unsigned int     offset_size;
-  unsigned int     dwarf_version;
+  unsigned char *start = *start_ptr;
+  unsigned char *vstart = *vstart_ptr;
+  unsigned char *section_end = section->start + section->size;
+  uint64_t cu_offset;
+  unsigned int pointer_size;
+  unsigned int offset_size;
+  unsigned int dwarf_version;
 
   /* Initialize it due to a false compiler warning.  */
-  dwarf_vma begin = -1, vbegin = -1;
-  dwarf_vma end = -1, vend = -1;
-  dwarf_vma length;
+  uint64_t begin = -1, vbegin = -1;
+  uint64_t end = -1, vend = -1;
+  uint64_t length;
   int need_frame_base;
 
   if (debug_info_entry >= num_debug_info_entries)
@@ -6655,18 +6579,18 @@ display_loclists_list (struct dwarf_section *  section,
 
   while (1)
     {
-      dwarf_vma off = offset + (start - *start_ptr);
+      uint64_t 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);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
       printf ("    ");
-      print_dwarf_vma (off, 4);
+      print_hex (off, 4);
 
       SAFE_BYTE_GET_AND_INC (llet, start, 1, section_end);
 
@@ -6677,13 +6601,12 @@ display_loclists_list (struct dwarf_section *  section,
 	  off = offset + (vstart - *start_ptr);
 
 	  READ_ULEB (vbegin, vstart, section_end);
-	  print_dwarf_view (vbegin, pointer_size, 1);
+	  print_view (vbegin, pointer_size);
 
 	  READ_ULEB (vend, vstart, section_end);
-	  print_dwarf_view (vend, pointer_size, 1);
+	  print_view (vend, pointer_size);
 
-	  printf (_("views at %8.8lx for:\n    %*s "),
-		  (unsigned long) off, 8, "");
+	  printf (_("views at %8.8" PRIx64 " for:\n    %*s "), off, 8, "");
 	}
 
       switch (llet)
@@ -6694,10 +6617,10 @@ display_loclists_list (struct dwarf_section *  section,
 
 	case DW_LLE_base_addressx:
 	  READ_ULEB (base_address, start, section_end);
-	  print_dwarf_vma (base_address, pointer_size);
+	  print_hex (base_address, pointer_size);
 	  printf (_("(index into .debug_addr) "));
 	  base_address = fetch_indexed_addr (base_address, pointer_size);
-	  print_dwarf_vma (base_address, pointer_size);
+	  print_hex (base_address, pointer_size);
 	  printf (_("(base address)\n"));
 	  break;
 
@@ -6729,7 +6652,7 @@ display_loclists_list (struct dwarf_section *  section,
 	case DW_LLE_base_address:
 	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size,
 				 section_end);
-	  print_dwarf_vma (base_address, pointer_size);
+	  print_hex (base_address, pointer_size);
 	  printf (_("(base address)\n"));
 	  break;
 
@@ -6749,10 +6672,10 @@ display_loclists_list (struct dwarf_section *  section,
 	  if (vstart)
 	    printf (_("View pair entry in loclist with locviews attribute\n"));
 	  READ_ULEB (vbegin, start, section_end);
-	  print_dwarf_view (vbegin, pointer_size, 1);
+	  print_view (vbegin, pointer_size);
 
 	  READ_ULEB (vend, start, section_end);
-	  print_dwarf_view (vend, pointer_size, 1);
+	  print_view (vend, pointer_size);
 
 	  printf (_("views for:\n"));
 	  continue;
@@ -6772,21 +6695,21 @@ display_loclists_list (struct dwarf_section *  section,
 
       if (start == section_end)
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
       READ_ULEB (length, start, section_end);
 
       if (length > (size_t) (section_end - start))
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
-      print_dwarf_vma (begin, pointer_size);
-      print_dwarf_vma (end, pointer_size);
+      print_hex (begin, pointer_size);
+      print_hex (end, pointer_size);
 
       putchar ('(');
       need_frame_base = decode_location_expression (start,
@@ -6811,7 +6734,7 @@ display_loclists_list (struct dwarf_section *  section,
       vbegin = vend = -1;
     }
 
-  if (vbegin != vm1 || vend != vm1)
+  if (vbegin != (uint64_t) -1 || vend != (uint64_t) -1)
     printf (_("Trailing view pair not used in a range"));
 
   *start_ptr = start;
@@ -6837,13 +6760,13 @@ static void
 display_loc_list_dwo (struct dwarf_section *section,
 		      unsigned char **start_ptr,
 		      unsigned int debug_info_entry,
-		      dwarf_vma offset,
+		      uint64_t offset,
 		      unsigned char **vstart_ptr,
 		      int has_frame_base)
 {
   unsigned char *start = *start_ptr, *vstart = *vstart_ptr;
   unsigned char *section_end = section->start + section->size;
-  dwarf_vma    cu_offset;
+  uint64_t cu_offset;
   unsigned int pointer_size;
   unsigned int offset_size;
   int dwarf_version;
@@ -6874,12 +6797,12 @@ display_loc_list_dwo (struct dwarf_section *section,
   while (1)
     {
       printf ("    ");
-      print_dwarf_vma (offset + (start - *start_ptr), 4);
+      print_hex (offset + (start - *start_ptr), 4);
 
       if (start >= section_end)
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
@@ -6895,17 +6818,16 @@ display_loc_list_dwo (struct dwarf_section *section,
 	  case 3:
 	  case 4:
 	    {
-	      dwarf_vma view;
-	      dwarf_vma off = offset + (vstart - *start_ptr);
+	      uint64_t view;
+	      uint64_t off = offset + (vstart - *start_ptr);
 
 	      READ_ULEB (view, vstart, section_end);
-	      print_dwarf_view (view, 8, 1);
+	      print_view (view, 8);
 
 	      READ_ULEB (view, vstart, section_end);
-	      print_dwarf_view (view, 8, 1);
+	      print_view (view, 8);
 
-	      printf (_("views at %8.8lx for:\n    %*s "),
-		      (unsigned long) off, 8, "");
+	      printf (_("views at %8.8" PRIx64 " for:\n    %*s "), off, 8, "");
 
 	    }
 	    break;
@@ -6951,16 +6873,16 @@ display_loc_list_dwo (struct dwarf_section *section,
 
       if (2 > (size_t) (section_end - start))
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
       SAFE_BYTE_GET_AND_INC (length, start, 2, section_end);
       if (length > (size_t) (section_end - start))
 	{
-	  warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		(unsigned long) offset);
+	  warn (_("Location list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
@@ -6988,13 +6910,13 @@ display_loc_list_dwo (struct dwarf_section *section,
 /* Sort array of indexes in ascending order of loc_offsets[idx] and
    loc_views.  */
 
-static dwarf_vma *loc_offsets, *loc_views;
+static uint64_t *loc_offsets, *loc_views;
 
 static int
 loc_offsets_compar (const void *ap, const void *bp)
 {
-  dwarf_vma a = loc_offsets[*(const unsigned int *) ap];
-  dwarf_vma b = loc_offsets[*(const unsigned int *) bp];
+  uint64_t a = loc_offsets[*(const unsigned int *) ap];
+  uint64_t b = loc_offsets[*(const unsigned int *) bp];
 
   int ret = (a > b) - (b > a);
   if (ret)
@@ -7018,15 +6940,15 @@ display_offset_entry_loclists (struct dwarf_section *section)
 
   do
     {
-      dwarf_vma        length;
-      unsigned short   version;
-      unsigned char    address_size;
-      unsigned char    segment_selector_size;
-      uint32_t         offset_entry_count;
-      uint32_t         i;
-      bool             is_64bit;
+      uint64_t length;
+      unsigned short version;
+      unsigned char address_size;
+      unsigned char segment_selector_size;
+      uint32_t offset_entry_count;
+      uint32_t i;
+      bool is_64bit;
 
-      printf (_("Table at Offset 0x%lx\n"), (long)(start - section->start));
+      printf (_("Table at Offset 0x%tx\n"), start - section->start);
 
       SAFE_BYTE_GET_AND_INC (length, start, 4, end);
       if (length == 0xffffffff)
@@ -7042,7 +6964,7 @@ display_offset_entry_loclists (struct dwarf_section *section)
       SAFE_BYTE_GET_AND_INC (segment_selector_size, start, 1, end);
       SAFE_BYTE_GET_AND_INC (offset_entry_count, start, 4, end);
 
-      printf (_("  Length:          0x%s\n"), dwarf_vmatoa ("x", length));
+      printf (_("  Length:          0x%" PRIx64 "\n"), length);
       printf (_("  DWARF version:   %u\n"), version);
       printf (_("  Address size:    %u\n"), address_size);
       printf (_("  Segment size:    %u\n"), segment_selector_size);
@@ -7071,28 +6993,15 @@ display_offset_entry_loclists (struct dwarf_section *section)
 	  return 0;
 	}
 
-      printf (_("\n   Offset Entries starting at 0x%lx:\n"),
-	      (long)(start - section->start));
-
-      if (is_64bit)
-	{
-	  for (i = 0; i < offset_entry_count; i++)
-	    {
-	      dwarf_vma entry;
+      printf (_("\n   Offset Entries starting at 0x%tx:\n"),
+	      start - section->start);
 
-	      SAFE_BYTE_GET_AND_INC (entry, start, 8, end);
-	      printf (_("    [%6u] 0x%s\n"), i, dwarf_vmatoa ("x", entry));
-	    }
-	}
-      else
+      for (i = 0; i < offset_entry_count; i++)
 	{
-	  for (i = 0; i < offset_entry_count; i++)
-	    {
-	      uint32_t entry;
+	  uint64_t entry;
 
-	      SAFE_BYTE_GET_AND_INC (entry, start, 4, end);
-	      printf (_("    [%6u] 0x%x\n"), i, entry);
-	    }
+	  SAFE_BYTE_GET_AND_INC (entry, start, is_64bit ? 8 : 4, end);
+	  printf (_("    [%6u] 0x%" PRIx64 "\n"), i, entry);
 	}
 
       putchar ('\n');
@@ -7101,11 +7010,11 @@ display_offset_entry_loclists (struct dwarf_section *section)
 
       for (j = 1, i = 0; i < offset_entry_count;)
 	{
-	  unsigned char  lle;
-	  dwarf_vma      base_address = 0;
-	  dwarf_vma      begin;
-	  dwarf_vma      finish;
-	  dwarf_vma      off = start - section->start;
+	  unsigned char lle;
+	  uint64_t base_address = 0;
+	  uint64_t begin;
+	  uint64_t finish;
+	  uint64_t off = start - section->start;
 
 	  if (j != i)
 	    {
@@ -7114,7 +7023,7 @@ display_offset_entry_loclists (struct dwarf_section *section)
 	    }
 
 	  printf ("    ");
-	  print_dwarf_vma (off, 4);
+	  print_hex (off, 4);
 
 	  SAFE_BYTE_GET_AND_INC (lle, start, 1, end);
 
@@ -7127,10 +7036,10 @@ display_offset_entry_loclists (struct dwarf_section *section)
 
 	    case DW_LLE_base_addressx:
 	      READ_ULEB (base_address, start, end);
-	      print_dwarf_vma (base_address, address_size);
+	      print_hex (base_address, address_size);
 	      printf (_("(index into .debug_addr) "));
 	      base_address = fetch_indexed_addr (base_address, address_size);
-	      print_dwarf_vma (base_address, address_size);
+	      print_hex (base_address, address_size);
 	      printf (_("(base address)\n"));
 	      continue;
 
@@ -7161,7 +7070,7 @@ display_offset_entry_loclists (struct dwarf_section *section)
 
 	    case DW_LLE_base_address:
 	      SAFE_BYTE_GET_AND_INC (base_address, start, address_size, end);
-	      print_dwarf_vma (base_address, address_size);
+	      print_hex (base_address, address_size);
 	      printf (_("(base address)\n"));
 	      continue;
 
@@ -7183,30 +7092,29 @@ display_offset_entry_loclists (struct dwarf_section *section)
 
 	  if (start == end)
 	    {
-	      warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		    (unsigned long) off);
+	      warn (_("Location list starting at offset %#" PRIx64
+		      " is not terminated.\n"), off);
 	      break;
 	    }
 
-	  print_dwarf_vma (begin, address_size);
-	  print_dwarf_vma (finish, address_size);
+	  print_hex (begin, address_size);
+	  print_hex (finish, address_size);
 
 	  if (begin == finish)
-	    fputs (_(" (start == end)"), stdout);
+	    fputs (_("(start == end)"), stdout);
 	  else if (begin > finish)
-	    fputs (_(" (start > end)"), stdout);
+	    fputs (_("(start > end)"), stdout);
 
 	  /* Read the counted location descriptions.  */
 	  READ_ULEB (length, start, end);
 
 	  if (length > (size_t) (end - start))
 	    {
-	      warn (_("Location list starting at offset 0x%lx is not terminated.\n"),
-		    (unsigned long) off);
+	      warn (_("Location list starting at offset %#" PRIx64
+		      " is not terminated.\n"), off);
 	      break;
 	    }
 
-	  putchar (' ');
 	  (void) decode_location_expression (start, address_size, address_size,
 					     version, length, 0, section);
 	  start += length;
@@ -7224,11 +7132,11 @@ static int
 display_debug_loc (struct dwarf_section *section, void *file)
 {
   unsigned char *start = section->start, *vstart = NULL;
-  dwarf_vma bytes;
+  uint64_t bytes;
   unsigned char *section_begin = start;
   unsigned int num_loc_list = 0;
-  dwarf_vma last_offset = 0;
-  dwarf_vma last_view = 0;
+  uint64_t last_offset = 0;
+  uint64_t last_view = 0;
   unsigned int first = 0;
   unsigned int i;
   unsigned int j;
@@ -7239,7 +7147,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
   const char *suffix = strrchr (section->name, '.');
   bool is_dwo = false;
   int is_loclists = strstr (section->name, "debug_loclists") != NULL;
-  dwarf_vma expected_start = 0;
+  uint64_t expected_start = 0;
 
   if (suffix && strcmp (suffix, ".dwo") == 0)
     is_dwo = true;
@@ -7255,7 +7163,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
   if (is_loclists)
     {
       unsigned char *hdrptr = section_begin;
-      dwarf_vma ll_length;
+      uint64_t ll_length;
       unsigned short ll_version;
       unsigned char *end = section_begin + section->size;
       unsigned char address_size, segment_selector_size;
@@ -7348,10 +7256,10 @@ display_debug_loc (struct dwarf_section *section, void *file)
   if (debug_information [first].num_loc_offsets > 0
       && debug_information [first].loc_offsets [0] != expected_start
       && debug_information [first].loc_views [0] != expected_start)
-    warn (_("Location lists in %s section start at 0x%s rather than 0x%s\n"),
-	  section->name,
-	  dwarf_vmatoa ("x", debug_information [first].loc_offsets [0]),
-	  dwarf_vmatoa ("x", expected_start));
+    warn (_("Location lists in %s section start at %#" PRIx64
+	    " rather than %#" PRIx64 "\n"),
+	  section->name, debug_information [first].loc_offsets [0],
+	  expected_start);
 
   if (!locs_sorted)
     array = (unsigned int *) xcmalloc (num_loc_list, sizeof (unsigned int));
@@ -7366,8 +7274,8 @@ display_debug_loc (struct dwarf_section *section, void *file)
   seen_first_offset = 0;
   for (i = first; i < num_debug_info_entries; i++)
     {
-      dwarf_vma offset, voffset;
-      dwarf_vma base_address;
+      uint64_t offset, voffset;
+      uint64_t base_address;
       unsigned int k;
       int has_frame_base;
 
@@ -7397,7 +7305,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
 	  offset = debug_information [i].loc_offsets [j];
 	  next = section_begin + offset;
 	  voffset = debug_information [i].loc_views [j];
-	  if (voffset != vm1)
+	  if (voffset != (uint64_t) -1)
 	    vnext = section_begin + voffset;
 	  else
 	    vnext = NULL;
@@ -7416,32 +7324,28 @@ display_debug_loc (struct dwarf_section *section, void *file)
 	  else
 	    {
 	      if (start < next)
-		warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
-		      (unsigned long) (start - section_begin),
-		      (unsigned long) offset,
-		      section->name);
+		warn (_("There is a hole [%#tx - %#" PRIx64 "]"
+			" in %s section.\n"),
+		      start - section_begin, offset, section->name);
 	      else if (start > next)
-		warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
-		      (unsigned long) (start - section_begin),
-		      (unsigned long) offset,
-		      section->name);
+		warn (_("There is an overlap [%#tx - %#" PRIx64 "]"
+			" in %s section.\n"),
+		      start - section_begin, offset, section->name);
 	    }
 	  start = next;
 	  vstart = vnext;
 
 	  if (offset >= bytes)
 	    {
-	      warn (_("Offset 0x%lx is bigger than %s section size.\n"),
-		    (unsigned long) offset,
-		    section->name);
+	      warn (_("Offset %#" PRIx64 " is bigger than %s section size.\n"),
+		    offset, section->name);
 	      continue;
 	    }
 
 	  if (vnext && voffset >= bytes)
 	    {
-	      warn (_("View Offset 0x%lx is bigger than %s section size.\n"),
-		    (unsigned long) voffset,
-		    section->name);
+	      warn (_("View Offset %#" PRIx64 " is bigger than %s section size.\n"),
+		    voffset, section->name);
 	      continue;
 	    }
 
@@ -7497,8 +7401,8 @@ display_debug_str (struct dwarf_section *section,
 		   void *file ATTRIBUTE_UNUSED)
 {
   unsigned char *start = section->start;
-  dwarf_vma bytes = section->size;
-  dwarf_vma addr = section->address;
+  uint64_t bytes = section->size;
+  uint64_t addr = section->address;
 
   if (bytes == 0)
     {
@@ -7516,7 +7420,7 @@ display_debug_str (struct dwarf_section *section,
 
       lbytes = (bytes > 16 ? 16 : bytes);
 
-      printf ("  0x%8.8lx ", (unsigned long) addr);
+      printf ("  0x%8.8" PRIx64 " ", addr);
 
       for (j = 0; j < 16; j++)
 	{
@@ -7586,11 +7490,11 @@ display_debug_aranges (struct dwarf_section *section,
       unsigned char *hdrptr;
       DWARF2_Internal_ARange arange;
       unsigned char *addr_ranges;
-      dwarf_vma length;
-      dwarf_vma address;
-      dwarf_vma     sec_off;
+      uint64_t length;
+      uint64_t address;
+      uint64_t sec_off;
       unsigned char address_size;
-      unsigned int  offset_size;
+      unsigned int offset_size;
       unsigned char *end_ranges;
 
       hdrptr = start;
@@ -7607,10 +7511,9 @@ display_debug_aranges (struct dwarf_section *section,
 
       if (arange.ar_length > (size_t) (end - hdrptr))
 	{
-	  warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
-		section->name,
-		(unsigned long) sec_off,
-		dwarf_vmatoa ("x", arange.ar_length));
+	  warn (_("Debug info is corrupted, %s header at %#" PRIx64
+		  " has length %#" PRIx64 "\n"),
+		section->name, sec_off, arange.ar_length);
 	  break;
 	}
       end_ranges = hdrptr + arange.ar_length;
@@ -7622,8 +7525,9 @@ display_debug_aranges (struct dwarf_section *section,
       if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE
 	  && num_debug_info_entries > 0
 	  && find_debug_info_for_offset (arange.ar_info_offset) == NULL)
-	warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"),
-	      (unsigned long) arange.ar_info_offset, section->name);
+	warn (_(".debug_info offset of %#" PRIx64
+		" in %s section does not point to a CU header.\n"),
+	      arange.ar_info_offset, section->name);
 
       SAFE_BYTE_GET_AND_INC (arange.ar_pointer_size, hdrptr, 1, end_ranges);
       SAFE_BYTE_GET_AND_INC (arange.ar_segment_size, hdrptr, 1, end_ranges);
@@ -7639,11 +7543,10 @@ display_debug_aranges (struct dwarf_section *section,
 	  break;
 	}
 
-      printf (_("  Length:                   %ld\n"),
-	      (long) arange.ar_length);
+      printf (_("  Length:                   %" PRId64 "\n"), arange.ar_length);
       printf (_("  Version:                  %d\n"), arange.ar_version);
-      printf (_("  Offset into .debug_info:  0x%lx\n"),
-	      (unsigned long) arange.ar_info_offset);
+      printf (_("  Offset into .debug_info:  0x%" PRIx64 "\n"),
+	      arange.ar_info_offset);
       printf (_("  Pointer Size:             %d\n"), arange.ar_pointer_size);
       printf (_("  Segment Size:             %d\n"), arange.ar_segment_size);
 
@@ -7684,8 +7587,8 @@ display_debug_aranges (struct dwarf_section *section,
 	  SAFE_BYTE_GET_AND_INC (length, addr_ranges, address_size,
 				 end_ranges);
 	  printf ("    ");
-	  print_dwarf_vma (address, address_size);
-	  print_dwarf_vma (length, address_size);
+	  print_hex (address, address_size);
+	  print_hex (length, address_size);
 	  putchar ('\n');
 	}
 
@@ -7746,8 +7649,9 @@ display_debug_addr (struct dwarf_section *section,
       {
 	/* PR 17531: file: cf38d01b.  */
 	if (debug_information[i].addr_base >= section->size)
-	  warn (_("Corrupt address base (%lx) found in debug section %u\n"),
-		(unsigned long) debug_information[i].addr_base, i);
+	  warn (_("Corrupt address base (%#" PRIx64 ")"
+		  " found in debug section %u\n"),
+		debug_information[i].addr_base, i);
 	else
 	  debug_addr_info [count++] = debug_information + i;
       }
@@ -7763,23 +7667,23 @@ display_debug_addr (struct dwarf_section *section,
       unsigned int idx;
       unsigned int address_size = debug_addr_info [i]->pointer_size;
 
-      printf (_("  For compilation unit at offset 0x%s:\n"),
-	      dwarf_vmatoa ("x", debug_addr_info [i]->cu_offset));
+      printf (_("  For compilation unit at offset 0x%" PRIx64 ":\n"),
+	      debug_addr_info [i]->cu_offset);
 
       printf (_("\tIndex\tAddress\n"));
       entry = section->start + debug_addr_info [i]->addr_base;
       if (debug_addr_info [i]->dwarf_version >= 5)
 	{
-	  size_t           header_size = entry - header;
-	  unsigned char *  curr_header = header;
-	  dwarf_vma        length;
-	  int              version;
-	  int              segment_selector_size;
+	  size_t header_size = entry - header;
+	  unsigned char *curr_header = header;
+	  uint64_t length;
+	  int version;
+	  int segment_selector_size;
 
 	  if (header_size != 8 && header_size != 16)
 	    {
-	      warn (_("Corrupt %s section: expecting header size of 8 or 16, but found %ld instead\n"),
-		    section->name, (long) header_size);
+	      warn (_("Corrupt %s section: expecting header size of 8 or 16, but found %zd instead\n"),
+		    section->name, header_size);
 	      return 0;
 	    }
 
@@ -7803,9 +7707,9 @@ display_debug_addr (struct dwarf_section *section,
       idx = 0;
       while (entry < end)
 	{
-	  dwarf_vma base = byte_get (entry, address_size);
+	  uint64_t base = byte_get (entry, address_size);
 	  printf (_("\t%d:\t"), idx);
-	  print_dwarf_vma (base, address_size);
+	  print_hex (base, address_size);
 	  printf ("\n");
 	  entry += address_size;
 	  idx++;
@@ -7834,7 +7738,7 @@ display_debug_str_offsets (struct dwarf_section *section,
   unsigned char *start = section->start;
   unsigned char *end = start + section->size;
   unsigned char *curr = start;
-  dwarf_vma debug_str_offsets_hdr_len;
+  uint64_t debug_str_offsets_hdr_len;
 
   const char *suffix = strrchr (section->name, '.');
   bool dwo = suffix && strcmp (suffix, ".dwo") == 0;
@@ -7848,8 +7752,8 @@ display_debug_str_offsets (struct dwarf_section *section,
 
   while (curr < end)
     {
-      dwarf_vma length;
-      dwarf_vma entry_length;
+      uint64_t length;
+      uint64_t entry_length;
 
       SAFE_BYTE_GET_AND_INC (length, curr, 4, end);
       /* FIXME: We assume that this means 64-bit DWARF is being used.  */
@@ -7874,17 +7778,17 @@ display_debug_str_offsets (struct dwarf_section *section,
 	  curr   = section->start;
 	  entries_end = end;
 
-	  printf (_("    Length: %#lx\n"), (unsigned long) length);
+	  printf (_("    Length: %#" PRIx64 "\n"), length);
 	  printf (_("       Index   Offset [String]\n"));
 	}
       else
 	{
-	  if (length <= (dwarf_vma) (end - curr))
+	  if (length <= (size_t) (end - curr))
 	    entries_end = curr + length;
 	  else
 	    {
-	      warn (_("Section %s is too small %#lx\n"),
-		    section->name, (unsigned long) section->size);
+	      warn (_("Section %s is too small %#" PRIx64 "\n"),
+		    section->name, section->size);
 	      entries_end = end;
 	    }
 
@@ -7898,17 +7802,17 @@ display_debug_str_offsets (struct dwarf_section *section,
 	  if (padding != 0)
 	    warn (_("Unexpected value in str_offset header's padding field: %#x\n"), padding);
 
-	  printf (_("    Length: %#lx\n"), (unsigned long) length);
-	  printf (_("    Version: %#lx\n"), (unsigned long) version);
+	  printf (_("    Length: %#" PRIx64 "\n"), length);
+	  printf (_("    Version: %#x\n"), version);
 	  printf (_("       Index   Offset [String]\n"));
 	}
 
       for (idx = 0; curr < entries_end; idx++)
 	{
-	  dwarf_vma offset;
+	  uint64_t offset;
 	  const unsigned char * string;
 
-	  if ((dwarf_vma) (entries_end - curr) < entry_length)
+	  if ((size_t) (entries_end - curr) < entry_length)
 	    /* Not enough space to read one entry_length, give up.  */
 	    return 0;
 
@@ -7919,8 +7823,9 @@ display_debug_str_offsets (struct dwarf_section *section,
 	  else
 	    string = fetch_indirect_string (offset);
 
-	  printf ("    %8lu %8s %s\n", idx, dwarf_vmatoa ("x", offset),
-		  string);
+	  printf ("    %8lu ", idx);
+	  print_hex (offset, entry_length);
+	  printf (" %s\n", string);
 	}
     }
 
@@ -7933,7 +7838,7 @@ display_debug_str_offsets (struct dwarf_section *section,
 struct range_entry
 {
   /* The debug_information[x].range_lists[y] value.  */
-  dwarf_vma ranges_offset;
+  uint64_t ranges_offset;
 
   /* Original debug_information to find parameters of the data.  */
   debug_info *debug_info_p;
@@ -7946,8 +7851,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 dwarf_vma a = a_re->ranges_offset;
-  const dwarf_vma b = b_re->ranges_offset;
+  const uint64_t a = a_re->ranges_offset;
+  const uint64_t b = b_re->ranges_offset;
 
   return (a > b) - (b > a);
 }
@@ -7956,13 +7861,13 @@ static void
 display_debug_ranges_list (unsigned char *  start,
 			   unsigned char *  finish,
 			   unsigned int     pointer_size,
-			   dwarf_vma        offset,
-			   dwarf_vma        base_address)
+			   uint64_t         offset,
+			   uint64_t         base_address)
 {
   while (start < finish)
     {
-      dwarf_vma begin;
-      dwarf_vma end;
+      uint64_t begin;
+      uint64_t end;
 
       SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
       if (start >= finish)
@@ -7970,7 +7875,7 @@ display_debug_ranges_list (unsigned char *  start,
       SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
 
       printf ("    ");
-      print_dwarf_vma (offset, 4);
+      print_hex (offset, 4);
 
       if (begin == 0 && end == 0)
 	{
@@ -7983,14 +7888,14 @@ display_debug_ranges_list (unsigned char *  start,
 	  && !is_max_address (end, pointer_size))
 	{
 	  base_address = end;
-	  print_dwarf_vma (begin, pointer_size);
-	  print_dwarf_vma (end, pointer_size);
+	  print_hex (begin, pointer_size);
+	  print_hex (end, pointer_size);
 	  printf ("(base address)\n");
 	  continue;
 	}
 
-      print_dwarf_vma (begin + base_address, pointer_size);
-      print_dwarf_vma (end + base_address, pointer_size);
+      print_hex (begin + base_address, pointer_size);
+      print_hex (end + base_address, pointer_size);
 
       if (begin == end)
 	fputs (_("(start == end)"), stdout);
@@ -8005,8 +7910,8 @@ static unsigned char *
 display_debug_rnglists_list (unsigned char * start,
 			     unsigned char * finish,
 			     unsigned int    pointer_size,
-			     dwarf_vma       offset,
-			     dwarf_vma       base_address,
+			     uint64_t        offset,
+			     uint64_t        base_address,
 			     unsigned int    offset_size)
 {
   unsigned char *next = start;
@@ -8019,20 +7924,20 @@ display_debug_rnglists_list (unsigned char * start,
 
   while (1)
     {
-      dwarf_vma off = offset + (start - next);
+      uint64_t off = offset + (start - next);
       enum dwarf_range_list_entry rlet;
       /* Initialize it due to a false compiler warning.  */
-      dwarf_vma begin = -1, length, end = -1;
+      uint64_t begin = -1, length, end = -1;
 
       if (start >= finish)
 	{
-	  warn (_("Range list starting at offset 0x%s is not terminated.\n"),
-		dwarf_vmatoa ("x", offset));
+	  warn (_("Range list starting at offset %#" PRIx64
+		  " is not terminated.\n"), offset);
 	  break;
 	}
 
       printf ("    ");
-      print_dwarf_vma (off, 4);
+      print_hex (off, 4);
 
       SAFE_BYTE_GET_AND_INC (rlet, start, 1, finish);
 
@@ -8043,11 +7948,11 @@ display_debug_rnglists_list (unsigned char * start,
 	  break;
 	case DW_RLE_base_addressx:
 	  READ_ULEB (base_address, start, finish);
-	  print_dwarf_vma (base_address, pointer_size);
+	  print_hex (base_address, pointer_size);
 	  printf (_("(base address index) "));
 	  base_address = fetch_indexed_addr ((base_address * pointer_size)
 			                     + debug_addr_section_hdr_len, pointer_size);
-	  print_dwarf_vma (base_address, pointer_size);
+	  print_hex (base_address, pointer_size);
 	  printf (_("(base address)\n"));
 	  break;
 	case DW_RLE_startx_endx:
@@ -8071,7 +7976,7 @@ display_debug_rnglists_list (unsigned char * start,
 	  break;
 	case DW_RLE_base_address:
 	  SAFE_BYTE_GET_AND_INC (base_address, start, pointer_size, finish);
-	  print_dwarf_vma (base_address, pointer_size);
+	  print_hex (base_address, pointer_size);
 	  printf (_("(base address)\n"));
 	  break;
 	case DW_RLE_start_end:
@@ -8101,13 +8006,13 @@ display_debug_rnglists_list (unsigned char * start,
 	  end += base_address;
 	}
 
-      print_dwarf_vma (begin, pointer_size);
-      print_dwarf_vma (end, pointer_size);
+      print_hex (begin, pointer_size);
+      print_hex (end, pointer_size);
 
       if (begin == end)
-	fputs (_("(start == end)"), stdout);
+	fputs (_(" (start == end)"), stdout);
       else if (begin > end)
-	fputs (_("(start > end)"), stdout);
+	fputs (_(" (start > end)"), stdout);
 
       putchar ('\n');
     }
@@ -8118,21 +8023,21 @@ display_debug_rnglists_list (unsigned char * start,
 static int
 display_debug_rnglists (struct dwarf_section *section)
 {
-  unsigned char *       start = section->start;
-  unsigned char *       finish = start + section->size;
+  unsigned char *start = section->start;
+  unsigned char *finish = start + section->size;
 
   while (start < finish)
     {
-      unsigned char * table_start;
-      dwarf_vma       offset = start - section->start;
-      unsigned char * end;
-      dwarf_vma       initial_length;
-      unsigned char   segment_selector_size;
-      unsigned int    offset_entry_count;
-      unsigned int    i;
-      unsigned short  version;
-      unsigned char   address_size = 0;
-      unsigned char   offset_size;
+      unsigned char *table_start;
+      uint64_t offset = start - section->start;
+      unsigned char *end;
+      uint64_t initial_length;
+      unsigned char segment_selector_size;
+      unsigned int offset_entry_count;
+      unsigned int i;
+      unsigned short version;
+      unsigned char address_size = 0;
+      unsigned char offset_size;
 
       /* Get and check the length of the block.  */
       SAFE_BYTE_GET_AND_INC (initial_length, start, 4, finish);
@@ -8155,8 +8060,10 @@ display_debug_rnglists (struct dwarf_section *section)
 	    initial_length = finish - start;
 	  else
 	    {
-	      warn (_("The length field (0x%lx) in the debug_rnglists header is wrong - the section is too small\n"),
-		    (long) initial_length);
+	      warn (_("The length field (%#" PRIx64
+		      ") in the debug_rnglists header is wrong"
+		      " - the section is too small\n"),
+		    initial_length);
 	      return 0;
 	    }
 	}
@@ -8169,8 +8076,8 @@ display_debug_rnglists (struct dwarf_section *section)
       SAFE_BYTE_GET_AND_INC (segment_selector_size, start, 1, finish);
       SAFE_BYTE_GET_AND_INC (offset_entry_count, start, 4, finish);
 
-      printf (_(" Table at Offset: 0x%s:\n"), dwarf_vmatoa ("x", offset));
-      printf (_("  Length:          0x%s\n"), dwarf_vmatoa ("x", initial_length));
+      printf (_(" Table at Offset: 0x%" PRIx64 ":\n"), offset);
+      printf (_("  Length:          0x%" PRIx64 "\n"), initial_length);
       printf (_("  DWARF version:   %u\n"), version);
       printf (_("  Address size:    %u\n"), address_size);
       printf (_("  Segment size:    %u\n"), segment_selector_size);
@@ -8196,26 +8103,15 @@ display_debug_rnglists (struct dwarf_section *section)
 
       if (offset_entry_count != 0)
 	{
-	  printf (_("\n   Offsets starting at 0x%lx:\n"), (long)(start - section->start));
-	  if (offset_size == 8)
-	    {
-	      for (i = 0; i < offset_entry_count; i++)
-		{
-		  dwarf_vma entry;
+	  printf (_("\n   Offsets starting at 0x%tx:\n"),
+		  start - section->start);
 
-		  SAFE_BYTE_GET_AND_INC (entry, start, 8, finish);
-		  printf (_("    [%6u] 0x%s\n"), i, dwarf_vmatoa ("x", entry));
-		}
-	    }
-	  else
+	  for (i = 0; i < offset_entry_count; i++)
 	    {
-	      for (i = 0; i < offset_entry_count; i++)
-		{
-		  uint32_t entry;
+	      uint64_t entry;
 
-		  SAFE_BYTE_GET_AND_INC (entry, start, 4, finish);
-		  printf (_("    [%6u] 0x%x\n"), i, entry);
-		}
+	      SAFE_BYTE_GET_AND_INC (entry, start, offset_size, finish);
+	      printf (_("    [%6u] 0x%" PRIx64 "\n"), i, entry);
 	    }
 	}
       else
@@ -8223,11 +8119,11 @@ display_debug_rnglists (struct dwarf_section *section)
 
       for (i = 0; i < offset_entry_count; i++)
 	{
-	  dwarf_vma indx = start - table_start;
+	  uint64_t indx = start - table_start;
 
 	  offset = start - section->start;
-	  printf (_("\n  Offset: %lx, Index: 0x%s\n"),
-		  (long) offset, dwarf_vmatoa ("x", indx));
+	  printf (_("\n  Offset: %" PRIx64 ", Index: 0x%" PRIx64 "\n"),
+		  offset, indx);
 	  printf (_("    Offset   Begin    End\n"));
 	  start = display_debug_rnglists_list
 	    (start, end, address_size, offset, 0, offset_size);
@@ -8249,18 +8145,18 @@ static int
 display_debug_ranges (struct dwarf_section *section,
 		      void *file ATTRIBUTE_UNUSED)
 {
-  unsigned char *       start = section->start;
-  unsigned char *       last_start = start;
-  dwarf_vma             bytes = section->size;
-  unsigned char *       section_begin = start;
-  unsigned char *       finish = start + bytes;
-  unsigned int          num_range_list, i;
-  struct range_entry *  range_entries;
-  struct range_entry *  range_entry_fill;
-  int                   is_rnglists = strstr (section->name, "debug_rnglists") != NULL;
+  unsigned char *start = section->start;
+  unsigned char *last_start = start;
+  uint64_t bytes = section->size;
+  unsigned char *section_begin = start;
+  unsigned char *finish = start + bytes;
+  unsigned int num_range_list, i;
+  struct range_entry *range_entries;
+  struct range_entry *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;
-  dwarf_vma             last_offset = 0;
+  unsigned char address_size = 0;
+  uint64_t last_offset = 0;
 
   if (bytes == 0)
     {
@@ -8313,8 +8209,8 @@ display_debug_ranges (struct dwarf_section *section,
 	 range_entry_compar);
 
   if (dwarf_check != 0 && range_entries[0].ranges_offset != 0)
-    warn (_("Range lists in %s section start at 0x%lx\n"),
-	  section->name, (unsigned long) range_entries[0].ranges_offset);
+    warn (_("Range lists in %s section start at %#" PRIx64 "\n"),
+	  section->name, range_entries[0].ranges_offset);
 
   putchar ('\n');
   printf (_("    Offset   Begin    End\n"));
@@ -8324,9 +8220,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;
-      dwarf_vma offset;
+      uint64_t offset;
       unsigned char *next;
-      dwarf_vma base_address;
+      uint64_t base_address;
 
       pointer_size = (is_rnglists ? address_size : debug_info_p->pointer_size);
       offset = range_entry->ranges_offset;
@@ -8335,15 +8231,15 @@ display_debug_ranges (struct dwarf_section *section,
       /* PR 17512: file: 001-101485-0.001:0.1.  */
       if (pointer_size < 2 || pointer_size > 8)
 	{
-	  warn (_("Corrupt pointer size (%d) in debug entry at offset %8.8lx\n"),
-		pointer_size, (unsigned long) offset);
+	  warn (_("Corrupt pointer size (%d) in debug entry at offset %#" PRIx64 "\n"),
+		pointer_size, offset);
 	  continue;
 	}
 
       if (offset > (size_t) (finish - section_begin))
 	{
-	  warn (_("Corrupt offset (%#8.8lx) in range entry %u\n"),
-		(unsigned long) offset, i);
+	  warn (_("Corrupt offset (%#" PRIx64 ") in range entry %u\n"),
+		offset, i);
 	  continue;
 	}
 
@@ -8361,16 +8257,14 @@ display_debug_ranges (struct dwarf_section *section,
       if (dwarf_check != 0 && i > 0)
 	{
 	  if (start < next)
-	    warn (_("There is a hole [0x%lx - 0x%lx] in %s section.\n"),
-		  (unsigned long) (start - section_begin),
-		  (unsigned long) (next - section_begin), section->name);
+	    warn (_("There is a hole [%#tx - %#tx] in %s section.\n"),
+		  start - section_begin, next - section_begin, section->name);
 	  else if (start > next)
 	    {
 	      if (next == last_start)
 		continue;
-	      warn (_("There is an overlap [0x%lx - 0x%lx] in %s section.\n"),
-		    (unsigned long) (start - section_begin),
-		    (unsigned long) (next - section_begin), section->name);
+	      warn (_("There is an overlap [%#tx - %#tx] in %s section.\n"),
+		    start - section_begin, next - section_begin, section->name);
 	    }
 	}
 
@@ -8398,10 +8292,10 @@ typedef struct Frame_Chunk
   char *augmentation;
   unsigned int code_factor;
   int data_factor;
-  dwarf_vma pc_begin;
-  dwarf_vma pc_range;
+  uint64_t pc_begin;
+  uint64_t pc_range;
   unsigned int cfa_reg;
-  dwarf_vma cfa_offset;
+  uint64_t cfa_offset;
   unsigned int ra;
   unsigned char fde_encoding;
   unsigned char cfa_exp;
@@ -8838,7 +8732,7 @@ frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_reg
       printf ("\n");
     }
 
-  print_dwarf_vma (fc->pc_begin, eh_addr_size);
+  print_hex (fc->pc_begin, eh_addr_size);
   if (fc->cfa_exp)
     strcpy (tmp, "exp");
   else
@@ -8887,12 +8781,12 @@ frame_display_row (Frame_Chunk *fc, int *need_col_headers, unsigned int *max_reg
 static unsigned char *
 read_cie (unsigned char *start, unsigned char *end,
 	  Frame_Chunk **p_cie, int *p_version,
-	  dwarf_size_type *p_aug_len, unsigned char **p_aug)
+	  uint64_t *p_aug_len, unsigned char **p_aug)
 {
   int version;
   Frame_Chunk *fc;
   unsigned char *augmentation_data = NULL;
-  dwarf_size_type augmentation_data_len = 0;
+  uint64_t augmentation_data_len = 0;
 
   * p_cie = NULL;
   /* PR 17512: file: 001-228113-0.004.  */
@@ -8977,9 +8871,9 @@ read_cie (unsigned char *start, unsigned char *end,
       /* PR 17512: file: 11042-2589-0.004.  */
       if (augmentation_data_len > (size_t) (end - start))
 	{
-	  warn (_("Augmentation data too long: 0x%s, expected at most %#lx\n"),
-		dwarf_vmatoa ("x", augmentation_data_len),
-		(unsigned long) (end - start));
+	  warn (_("Augmentation data too long: %#" PRIx64
+		  ", expected at most %#tx\n"),
+		augmentation_data_len, end - start);
 	  goto fail;
 	}
       start += augmentation_data_len;
@@ -9058,7 +8952,7 @@ display_data (size_t printed, const unsigned char *data, size_t len)
    If do_wide is not enabled, then formats the output to fit into 80 columns.  */
 
 static void
-display_augmentation_data (const unsigned char * data, dwarf_size_type len)
+display_augmentation_data (const unsigned char * data, uint64_t len)
 {
   size_t i;
 
@@ -9087,13 +8981,13 @@ display_debug_frames (struct dwarf_section *section,
     {
       unsigned char *saved_start;
       unsigned char *block_end;
-      dwarf_vma length;
-      dwarf_vma cie_id;
+      uint64_t length;
+      uint64_t cie_id;
       Frame_Chunk *fc;
       Frame_Chunk *cie;
       int need_col_headers = 1;
       unsigned char *augmentation_data = NULL;
-      dwarf_size_type augmentation_data_len = 0;
+      uint64_t augmentation_data_len = 0;
       unsigned int encoded_ptr_size = saved_eh_addr_size;
       unsigned int offset_size;
       bool all_nops;
@@ -9105,8 +8999,8 @@ display_debug_frames (struct dwarf_section *section,
 
       if (length == 0)
 	{
-	  printf ("\n%08lx ZERO terminator\n\n",
-		    (unsigned long)(saved_start - section_start));
+	  printf ("\n%08tx ZERO terminator\n\n",
+		    saved_start - section_start);
 	  /* Skip any zero terminators that directly follow.
 	     A corrupt section size could have loaded a whole
 	     slew of zero filled memory bytes.  eg
@@ -9126,9 +9020,8 @@ display_debug_frames (struct dwarf_section *section,
 
       if (length > (size_t) (end - start))
 	{
-	  warn ("Invalid length 0x%s in FDE at %#08lx\n",
-		dwarf_vmatoa_1 (NULL, length, offset_size),
-		(unsigned long) (saved_start - section_start));
+	  warn ("Invalid length %#" PRIx64 " in FDE at %#tx\n",
+		length, saved_start - section_start);
 	  block_end = end;
 	}
       else
@@ -9160,9 +9053,9 @@ display_debug_frames (struct dwarf_section *section,
 	  if (fc->fde_encoding)
 	    encoded_ptr_size = size_of_encoded_value (fc->fde_encoding);
 
-	  printf ("\n%08lx ", (unsigned long) (saved_start - section_start));
-	  print_dwarf_vma (length, fc->ptr_size);
-	  print_dwarf_vma (cie_id, offset_size);
+	  printf ("\n%08tx ", saved_start - section_start);
+	  print_hex (length, fc->ptr_size);
+	  print_hex (cie_id, offset_size);
 
 	  if (do_debug_frames_interp)
 	    {
@@ -9193,18 +9086,18 @@ display_debug_frames (struct dwarf_section *section,
 	{
 	  unsigned char *look_for;
 	  unsigned long segment_selector;
-	  dwarf_vma cie_off;
+	  uint64_t cie_off;
 
 	  cie_off = cie_id;
 	  if (is_eh)
 	    {
-	      dwarf_vma sign = (dwarf_vma) 1 << (offset_size * 8 - 1);
+	      uint64_t sign = (uint64_t) 1 << (offset_size * 8 - 1);
 	      cie_off = (cie_off ^ sign) - sign;
 	      cie_off = start - 4 - section_start - cie_off;
 	    }
 
 	  look_for = section_start + cie_off;
-	  if (cie_off <= (dwarf_vma) (saved_start - section_start))
+	  if (cie_off <= (size_t) (saved_start - section_start))
 	    {
 	      for (cie = chunks; cie ; cie = cie->next)
 		if (cie->chunk_start == look_for)
@@ -9232,7 +9125,7 @@ display_debug_frames (struct dwarf_section *section,
 		    }
 		  if (length != 0 && length <= (size_t) (end - cie_scan))
 		    {
-		      dwarf_vma c_id;
+		      uint64_t c_id;
 		      unsigned char *cie_end = cie_scan + length;
 
 		      SAFE_BYTE_GET_AND_INC (c_id, cie_scan, off_size,
@@ -9348,10 +9241,9 @@ display_debug_frames (struct dwarf_section *section,
 	      /* PR 17512 file: 722-8446-0.004 and PR 22386.  */
 	      if (augmentation_data_len > (size_t) (block_end - start))
 		{
-		  warn (_("Augmentation data too long: 0x%s, "
-			  "expected at most %#lx\n"),
-			dwarf_vmatoa ("x", augmentation_data_len),
-			(unsigned long) (block_end - start));
+		  warn (_("Augmentation data too long: %#" PRIx64 ", "
+			  "expected at most %#tx\n"),
+			augmentation_data_len, block_end - start);
 		  start = block_end;
 		  augmentation_data = NULL;
 		  augmentation_data_len = 0;
@@ -9359,14 +9251,13 @@ display_debug_frames (struct dwarf_section *section,
 	      start += augmentation_data_len;
 	    }
 
-	  printf ("\n%08lx %s %s FDE ",
-		  (unsigned long)(saved_start - section_start),
-		  dwarf_vmatoa_1 (NULL, length, fc->ptr_size),
-		  dwarf_vmatoa_1 (NULL, cie_id, offset_size));
+	  printf ("\n%08tx ", saved_start - section_start);
+	  print_hex (length, fc->ptr_size);
+	  print_hex (cie_id, offset_size);
+	  printf ("FDE ");
 
 	  if (cie->chunk_start)
-	    printf ("cie=%08lx",
-		    (unsigned long) (cie->chunk_start - section_start));
+	    printf ("cie=%08tx", cie->chunk_start - section_start);
 	  else
 	    /* Ideally translate "invalid " to 8 chars, trailing space
 	       is optional.  */
@@ -9376,9 +9267,10 @@ display_debug_frames (struct dwarf_section *section,
 	  if (fc->segment_size)
 	    printf ("%04lx:", segment_selector);
 
-	  printf ("%s..%s\n",
-		  dwarf_vmatoa_1 (NULL, fc->pc_begin, fc->ptr_size),
-		  dwarf_vmatoa_1 (NULL, fc->pc_begin + fc->pc_range, fc->ptr_size));
+	  print_hex_ns (fc->pc_begin, fc->ptr_size);
+	  printf ("..");
+	  print_hex_ns (fc->pc_begin + fc->pc_range, fc->ptr_size);
+	  printf ("\n");
 
 	  if (! do_debug_frames_interp && augmentation_data_len)
 	    {
@@ -9548,9 +9440,9 @@ display_debug_frames (struct dwarf_section *section,
 	     are various functions, notably frame_space_needed() that assume that
 	     reg is an unsigned int.  */
 	  unsigned int reg;
-	  dwarf_signed_vma l;
-	  dwarf_vma ofs;
-	  dwarf_vma vma;
+	  int64_t l;
+	  uint64_t ofs;
+	  uint64_t vma;
 	  const char *reg_prefix = "";
 
 	  op = *start++;
@@ -9570,11 +9462,13 @@ display_debug_frames (struct dwarf_section *section,
 	      if (do_debug_frames_interp)
 		frame_display_row (fc, &need_col_headers, &max_regs);
 	      else
-		printf ("  DW_CFA_advance_loc: %d to %s\n",
-			opa * fc->code_factor,
-			dwarf_vmatoa_1 (NULL,
-					fc->pc_begin + opa * fc->code_factor,
-					fc->ptr_size));
+		{
+		  printf ("  DW_CFA_advance_loc: %d to ",
+			opa * fc->code_factor);
+		  print_hex_ns (fc->pc_begin + opa * fc->code_factor,
+				fc->ptr_size);
+		  printf ("\n");
+		}
 	      fc->pc_begin += opa * fc->code_factor;
 	      break;
 
@@ -9621,8 +9515,11 @@ display_debug_frames (struct dwarf_section *section,
 	      if (do_debug_frames_interp)
 		frame_display_row (fc, &need_col_headers, &max_regs);
 	      else
-		printf ("  DW_CFA_set_loc: %s\n",
-			dwarf_vmatoa_1 (NULL, vma, fc->ptr_size));
+		{
+		  printf ("  DW_CFA_set_loc: ");
+		  print_hex_ns (vma, fc->ptr_size);
+		  printf ("\n");
+		}
 	      fc->pc_begin = vma;
 	      break;
 
@@ -9631,11 +9528,13 @@ display_debug_frames (struct dwarf_section *section,
 	      if (do_debug_frames_interp)
 		frame_display_row (fc, &need_col_headers, &max_regs);
 	      else
-		printf ("  DW_CFA_advance_loc1: %ld to %s\n",
-			(unsigned long) (ofs * fc->code_factor),
-			dwarf_vmatoa_1 (NULL,
-					fc->pc_begin + ofs * fc->code_factor,
-					fc->ptr_size));
+		{
+		  printf ("  DW_CFA_advance_loc1: %" PRId64 " to ",
+			  ofs * fc->code_factor);
+		  print_hex_ns (fc->pc_begin + ofs * fc->code_factor,
+				fc->ptr_size);
+		  printf ("\n");
+		}
 	      fc->pc_begin += ofs * fc->code_factor;
 	      break;
 
@@ -9644,11 +9543,13 @@ display_debug_frames (struct dwarf_section *section,
 	      if (do_debug_frames_interp)
 		frame_display_row (fc, &need_col_headers, &max_regs);
 	      else
-		printf ("  DW_CFA_advance_loc2: %ld to %s\n",
-			(unsigned long) (ofs * fc->code_factor),
-			dwarf_vmatoa_1 (NULL,
-					fc->pc_begin + ofs * fc->code_factor,
-					fc->ptr_size));
+		{
+		  printf ("  DW_CFA_advance_loc2: %" PRId64 " to ",
+			  ofs * fc->code_factor);
+		  print_hex_ns (fc->pc_begin + ofs * fc->code_factor,
+				fc->ptr_size);
+		  printf ("\n");
+		}
 	      fc->pc_begin += ofs * fc->code_factor;
 	      break;
 
@@ -9657,11 +9558,13 @@ display_debug_frames (struct dwarf_section *section,
 	      if (do_debug_frames_interp)
 		frame_display_row (fc, &need_col_headers, &max_regs);
 	      else
-		printf ("  DW_CFA_advance_loc4: %ld to %s\n",
-			(unsigned long) (ofs * fc->code_factor),
-			dwarf_vmatoa_1 (NULL,
-					fc->pc_begin + ofs * fc->code_factor,
-					fc->ptr_size));
+		{
+		  printf ("  DW_CFA_advance_loc4: %" PRId64 " to ",
+			  ofs * fc->code_factor);
+		  print_hex_ns (fc->pc_begin + ofs * fc->code_factor,
+				fc->ptr_size);
+		  printf ("\n");
+		}
 	      fc->pc_begin += ofs * fc->code_factor;
 	      break;
 
@@ -9912,9 +9815,9 @@ display_debug_frames (struct dwarf_section *section,
 	      if (reg >= fc->ncols)
 		reg_prefix = bad_reg;
 	      if (! do_debug_frames_interp || *reg_prefix != '\0')
-		printf ("  DW_CFA_offset_extended_sf: %s%s at cfa%+ld\n",
+		printf ("  DW_CFA_offset_extended_sf: %s%s at cfa%+" PRId64 "\n",
 			reg_prefix, regname (reg, 0),
-			(long)(l * fc->data_factor));
+			l * fc->data_factor);
 	      if (*reg_prefix == '\0')
 		{
 		  fc->col_type[reg] = DW_CFA_offset;
@@ -9928,9 +9831,9 @@ display_debug_frames (struct dwarf_section *section,
 	      if (reg >= fc->ncols)
 		reg_prefix = bad_reg;
 	      if (! do_debug_frames_interp || *reg_prefix != '\0')
-		printf ("  DW_CFA_val_offset_sf: %s%s is cfa%+ld\n",
+		printf ("  DW_CFA_val_offset_sf: %s%s is cfa%+" PRId64 "\n",
 			reg_prefix, regname (reg, 0),
-			(long)(l * fc->data_factor));
+			l * fc->data_factor);
 	      if (*reg_prefix == '\0')
 		{
 		  fc->col_type[reg] = DW_CFA_val_offset;
@@ -9945,8 +9848,8 @@ display_debug_frames (struct dwarf_section *section,
 	      fc->cfa_offset = l;
 	      fc->cfa_exp = 0;
 	      if (! do_debug_frames_interp)
-		printf ("  DW_CFA_def_cfa_sf: %s ofs %ld\n",
-			regname (fc->cfa_reg, 0), (long) l);
+		printf ("  DW_CFA_def_cfa_sf: %s ofs %" PRId64 "\n",
+			regname (fc->cfa_reg, 0), l);
 	      break;
 
 	    case DW_CFA_def_cfa_offset_sf:
@@ -9954,7 +9857,7 @@ display_debug_frames (struct dwarf_section *section,
 	      l *= fc->data_factor;
 	      fc->cfa_offset = l;
 	      if (! do_debug_frames_interp)
-		printf ("  DW_CFA_def_cfa_offset_sf: %ld\n", (long) l);
+		printf ("  DW_CFA_def_cfa_offset_sf: %" PRId64 "\n", l);
 	      break;
 
 	    case DW_CFA_MIPS_advance_loc8:
@@ -9962,11 +9865,13 @@ display_debug_frames (struct dwarf_section *section,
 	      if (do_debug_frames_interp)
 		frame_display_row (fc, &need_col_headers, &max_regs);
 	      else
-		printf ("  DW_CFA_MIPS_advance_loc8: %ld to %s\n",
-			(unsigned long) (ofs * fc->code_factor),
-			dwarf_vmatoa_1 (NULL,
-					fc->pc_begin + ofs * fc->code_factor,
-					fc->ptr_size));
+		{
+		  printf ("  DW_CFA_MIPS_advance_loc8: %" PRId64 " to ",
+			  ofs * fc->code_factor);
+		  print_hex_ns (fc->pc_begin + ofs * fc->code_factor,
+				fc->ptr_size);
+		  printf ("\n");
+		}
 	      fc->pc_begin += ofs * fc->code_factor;
 	      break;
 
@@ -9988,9 +9893,10 @@ display_debug_frames (struct dwarf_section *section,
 	      if (reg >= fc->ncols)
 		reg_prefix = bad_reg;
 	      if (! do_debug_frames_interp || *reg_prefix != '\0')
-		printf ("  DW_CFA_GNU_negative_offset_extended: %s%s at cfa%+ld\n",
+		printf ("  DW_CFA_GNU_negative_offset_extended: %s%s "
+			"at cfa%+" PRId64 "\n",
 			reg_prefix, regname (reg, 0),
-			(long)(l * fc->data_factor));
+			l * fc->data_factor);
 	      if (*reg_prefix == '\0')
 		{
 		  fc->col_type[reg] = DW_CFA_offset;
@@ -10067,7 +9973,7 @@ static int
 display_debug_names (struct dwarf_section *section, void *file)
 {
   unsigned char *hdrptr = section->start;
-  dwarf_vma unit_length;
+  uint64_t unit_length;
   unsigned char *unit_start;
   const unsigned char *const section_end = section->start + section->size;
   unsigned char *unit_end;
@@ -10106,17 +10012,16 @@ display_debug_names (struct dwarf_section *section, void *file)
 	  || unit_length < 2 + 2 + 4 * 7)
 	{
 	too_short:
-	  warn (_("Debug info is corrupted, %s header at %#lx has length %s\n"),
-		section->name,
-		(unsigned long) (unit_start - section->start),
-		dwarf_vmatoa ("x", unit_length));
+	  warn (_("Debug info is corrupted, %s header at %#tx"
+		  " has length %#" PRIx64 "\n"),
+		section->name, unit_start - section->start, unit_length);
 	  return 0;
 	}
       unit_end = hdrptr + unit_length;
 
       /* Get and check the version number.  */
       SAFE_BYTE_GET_AND_INC (dwarf_version, hdrptr, 2, unit_end);
-      printf (_("Version %ld\n"), (long) dwarf_version);
+      printf (_("Version %d\n"), (int) dwarf_version);
 
       /* Prior versions did not exist, and future versions may not be
 	 backwards compatible.  */
@@ -10189,7 +10094,7 @@ display_debug_names (struct dwarf_section *section, void *file)
 	  uint64_t cu_offset;
 
 	  SAFE_BYTE_GET_AND_INC (cu_offset, hdrptr, offset_size, unit_end);
-	  printf (_("[%3u] 0x%lx\n"), i, (unsigned long) cu_offset);
+	  printf ("[%3u] 0x%" PRIx64 "\n", i, cu_offset);
 	}
       putchar ('\n');
 
@@ -10202,7 +10107,7 @@ display_debug_names (struct dwarf_section *section, void *file)
 	  uint64_t tu_offset;
 
 	  SAFE_BYTE_GET_AND_INC (tu_offset, hdrptr, offset_size, unit_end);
-	  printf (_("[%3u] 0x%lx\n"), i, (unsigned long) tu_offset);
+	  printf ("[%3u] 0x%" PRIx64 "\n", i, tu_offset);
 	}
       putchar ('\n');
 
@@ -10216,7 +10121,7 @@ display_debug_names (struct dwarf_section *section, void *file)
 
 	  SAFE_BYTE_GET_AND_INC (signature, hdrptr, 8, unit_end);
 	  printf (_("[%3u] "), i);
-	  print_dwarf_vma (signature, 8);
+	  print_hex (signature, 8);
 	  putchar ('\n');
 	}
       putchar ('\n');
@@ -10226,11 +10131,9 @@ display_debug_names (struct dwarf_section *section, void *file)
 		       + abbrev_table_size);
       if (xtra > (size_t) (unit_end - hdrptr))
 	{
-	  warn (_("Entry pool offset (0x%lx) exceeds unit size 0x%lx "
-		  "for unit 0x%lx in the debug_names\n"),
-		(long) xtra,
-		(long) (unit_end - unit_start),
-		(long) (unit_start - section->start));
+	  warn (_("Entry pool offset (%#" PRIx64 ") exceeds unit size %#tx "
+		  "for unit %#tx in the debug_names\n"),
+		xtra, unit_end - unit_start, unit_start - section->start);
 	  return 0;
 	}
       const uint32_t *const hash_table_buckets = (uint32_t *) hdrptr;
@@ -10257,7 +10160,7 @@ display_debug_names (struct dwarf_section *section, void *file)
 	}
       printf (ngettext ("Used %zu of %lu bucket.\n",
 			"Used %zu of %lu buckets.\n",
-			bucket_count),
+			(unsigned long) bucket_count),
 	      buckets_filled, (unsigned long) bucket_count);
 
       if (bucket_count != 0)
@@ -10284,20 +10187,20 @@ display_debug_names (struct dwarf_section *section, void *file)
 		}
 	      hash_prev = hash_this;
 	    }
-	  printf (_("Out of %lu items there are %zu bucket clashes"
+	  printf (_("Out of %" PRIu64 " items there are %zu bucket clashes"
 		    " (longest of %zu entries).\n"),
-		  (unsigned long) name_count, hash_clash_count, longest_clash);
+		  name_count, hash_clash_count, longest_clash);
 
 	  if (name_count != buckets_filled + hash_clash_count)
-	    warn (_("The name_count (%lu) is not the same as the used bucket_count (%lu) + the hash clash count (%lu)"),
-		  (unsigned long) name_count,
-		  (unsigned long) buckets_filled,
-		  (unsigned long) hash_clash_count);
+	    warn (_("The name_count (%" PRIu64 ")"
+		    " is not the same as the used bucket_count"
+		    " (%zu) + the hash clash count (%zu)"),
+		  name_count, buckets_filled, hash_clash_count);
 	}
 
       struct abbrev_lookup_entry
       {
-	dwarf_vma abbrev_tag;
+	uint64_t abbrev_tag;
 	unsigned char *abbrev_lookup_ptr;
       };
       struct abbrev_lookup_entry *abbrev_lookup = NULL;
@@ -10307,7 +10210,7 @@ display_debug_names (struct dwarf_section *section, void *file)
       unsigned char *abbrevptr = abbrev_table;
       for (;;)
 	{
-	  dwarf_vma abbrev_tag;
+	  uint64_t abbrev_tag;
 
 	  READ_ULEB (abbrev_tag, abbrevptr, abbrev_table_end);
 	  if (abbrev_tag == 0)
@@ -10327,9 +10230,9 @@ display_debug_names (struct dwarf_section *section, void *file)
 	       entry++)
 	    if (entry->abbrev_tag == abbrev_tag)
 	      {
-		warn (_("Duplicate abbreviation tag %lu "
-			"in unit 0x%lx in the debug_names\n"),
-		      (long) abbrev_tag, (long) (unit_start - section->start));
+		warn (_("Duplicate abbreviation tag %" PRIu64
+			" in unit %#tx in the debug_names section\n"),
+		      abbrev_tag, unit_start - section->start);
 		break;
 	      }
 	  entry = &abbrev_lookup[abbrev_lookup_used++];
@@ -10340,7 +10243,7 @@ display_debug_names (struct dwarf_section *section, void *file)
 	  SKIP_ULEB (abbrevptr, abbrev_table_end);
 	  for (;;)
 	    {
-	      dwarf_vma xindex, form;
+	      uint64_t xindex, form;
 
 	      READ_ULEB (xindex, abbrevptr, abbrev_table_end);
 	      READ_ULEB (form, abbrevptr, abbrev_table_end);
@@ -10372,11 +10275,11 @@ display_debug_names (struct dwarf_section *section, void *file)
 	     first entry for real printing etc.  */
 	  int tagno = -2;
 	  /* Initialize it due to a false compiler warning.  */
-	  dwarf_vma second_abbrev_tag = -1;
+	  uint64_t second_abbrev_tag = -1;
 	  for (;;)
 	    {
-	      dwarf_vma abbrev_tag;
-	      dwarf_vma dwarf_tag;
+	      uint64_t abbrev_tag;
+	      uint64_t dwarf_tag;
 	      const struct abbrev_lookup_entry *entry;
 
 	      READ_ULEB (abbrev_tag, entryptr, unit_end);
@@ -10390,9 +10293,9 @@ display_debug_names (struct dwarf_section *section, void *file)
 	      if (abbrev_tag == 0)
 		break;
 	      if (tagno >= 0)
-		printf ("%s<%lu>",
+		printf ("%s<%" PRIu64 ">",
 			(tagno == 0 && second_abbrev_tag == 0 ? " " : "\n\t"),
-			(unsigned long) abbrev_tag);
+			abbrev_tag);
 
 	      for (entry = abbrev_lookup;
 		   entry < abbrev_lookup + abbrev_lookup_used;
@@ -10401,10 +10304,10 @@ display_debug_names (struct dwarf_section *section, void *file)
 		  break;
 	      if (entry >= abbrev_lookup + abbrev_lookup_used)
 		{
-		  warn (_("Undefined abbreviation tag %lu "
-			  "in unit 0x%lx in the debug_names\n"),
-			(long) abbrev_tag,
-			(long) (unit_start - section->start));
+		  warn (_("Undefined abbreviation tag %" PRId64
+			  " in unit %#tx in the debug_names section\n"),
+			abbrev_tag,
+			unit_start - section->start);
 		  break;
 		}
 	      abbrevptr = entry->abbrev_lookup_ptr;
@@ -10413,7 +10316,7 @@ display_debug_names (struct dwarf_section *section, void *file)
 		printf (" %s", get_TAG_name (dwarf_tag));
 	      for (;;)
 		{
-		  dwarf_vma xindex, form;
+		  uint64_t xindex, form;
 
 		  READ_ULEB (xindex, abbrevptr, abbrev_table_end);
 		  READ_ULEB (form, abbrevptr, abbrev_table_end);
@@ -10489,8 +10392,9 @@ display_debug_links (struct dwarf_section *  section,
 
       if (crc_offset + 4 < section->size)
 	{
-	  warn (_("There are %#lx extraneous bytes at the end of the section\n"),
-		(long)(section->size - (crc_offset + 4)));
+	  warn (_("There are %#" PRIx64
+		  " extraneous bytes at the end of the section\n"),
+		section->size - (crc_offset + 4));
 	  return 0;
 	}
     }
@@ -10541,7 +10445,7 @@ display_gdb_index (struct dwarf_section *section,
     }
 
   version = byte_get_little_endian (start, 4);
-  printf (_("Version %ld\n"), (long) version);
+  printf (_("Version %lu\n"), (unsigned long) version);
 
   /* Prior versions are obsolete, and future versions may not be
      backwards compatible.  */
@@ -10600,9 +10504,8 @@ display_gdb_index (struct dwarf_section *section,
       uint64_t cu_offset = byte_get_little_endian (cu_list + i * 16, 8);
       uint64_t cu_length = byte_get_little_endian (cu_list + i * 16 + 8, 8);
 
-      printf (_("[%3u] 0x%lx - 0x%lx\n"), i,
-	      (unsigned long) cu_offset,
-	      (unsigned long) (cu_offset + cu_length - 1));
+      printf ("[%3u] 0x%" PRIx64 " - 0x%" PRIx64 "\n",
+	      i, cu_offset, cu_offset + cu_length - 1);
     }
 
   printf (_("\nTU table:\n"));
@@ -10612,10 +10515,9 @@ display_gdb_index (struct dwarf_section *section,
       uint64_t type_offset = byte_get_little_endian (tu_list + i * 24 + 8, 8);
       uint64_t signature = byte_get_little_endian (tu_list + i * 24 + 16, 8);
 
-      printf (_("[%3u] 0x%lx 0x%lx "), i,
-	      (unsigned long) tu_offset,
-	      (unsigned long) type_offset);
-      print_dwarf_vma (signature, 8);
+      printf ("[%3u] 0x%" PRIx64 " 0x%" PRIx64 " ",
+	      i, tu_offset, type_offset);
+      print_hex (signature, 8);
       printf ("\n");
     }
 
@@ -10626,9 +10528,9 @@ display_gdb_index (struct dwarf_section *section,
       uint64_t high = byte_get_little_endian (address_table + i * 20 + 8, 8);
       uint32_t cu_index = byte_get_little_endian (address_table + i + 20 + 16, 4);
 
-      print_dwarf_vma (low, 8);
-      print_dwarf_vma (high, 8);
-      printf (_("%lu\n"), (unsigned long) cu_index);
+      print_hex (low, 8);
+      print_hex (high, 8);
+      printf ("%" PRIu32 "\n", cu_index);
     }
 
   printf (_("\nSymbol table:\n"));
@@ -10690,7 +10592,7 @@ display_gdb_index (struct dwarf_section *section,
 	      /* Convert to TU number if it's for a type unit.  */
 	      if (cu >= cu_list_elements)
 		printf ("%cT%lu", num_cus > 1 ? '\t' : ' ',
-			(unsigned long) (cu - cu_list_elements));
+			(unsigned long) cu - cu_list_elements);
 	      else
 		printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu);
 
@@ -10801,7 +10703,7 @@ process_cu_tu_index (struct dwarf_section *section, int do_display)
   unsigned int nslots;
   unsigned int i;
   unsigned int j;
-  dwarf_vma signature;
+  uint64_t signature;
   size_t total;
 
   /* PR 17512: file: 002-168123-0.004.  */
@@ -10872,8 +10774,8 @@ process_cu_tu_index (struct dwarf_section *section, int do_display)
 		}
 
 	      if (do_display)
-		printf (_("  [%3d] Signature:  0x%s  Sections: "),
-			i, dwarf_vmatoa ("x", signature));
+		printf (_("  [%3d] Signature:  0x%" PRIx64 "  Sections: "),
+			i, signature);
 	      for (;;)
 		{
 		  if (shndx_list >= limit)
@@ -10986,8 +10888,7 @@ process_cu_tu_index (struct dwarf_section *section, int do_display)
 
 	      prow = poffsets + (row - 1) * ncols * 4;
 	      if (do_display)
-		printf (_("  [%3d] 0x%s"),
-			i, dwarf_vmatoa ("x", signature));
+		printf ("  [%3d] 0x%" PRIx64, i, signature);
 	      for (j = 0; j < ncols; j++)
 		{
 		  unsigned char *p = prow + j * 4;
@@ -11045,8 +10946,7 @@ process_cu_tu_index (struct dwarf_section *section, int do_display)
 	      prow = psizes + (row - 1) * ncols * 4;
 
 	      if (do_display)
-		printf (_("  [%3d] 0x%s"),
-			i, dwarf_vmatoa ("x", signature));
+		printf ("  [%3d] 0x%" PRIx64, i, signature);
 
 	      for (j = 0; j < ncols; j++)
 		{
@@ -11191,8 +11091,8 @@ xcmalloc (size_t nmemb, size_t size)
   if (nmemb >= ~(size_t) 0 / size)
     {
       fprintf (stderr,
-	       _("Attempt to allocate an array with an excessive number of elements: 0x%lx\n"),
-	       (long) nmemb);
+	       _("Attempt to allocate an array with an excessive number of elements: %#zx\n"),
+	       nmemb);
       xexit (1);
     }
 
@@ -11209,8 +11109,8 @@ xcrealloc (void *ptr, size_t nmemb, size_t size)
   /* Check for overflow.  */
   if (nmemb >= ~(size_t) 0 / size)
     {
-      error (_("Attempt to re-allocate an array with an excessive number of elements: 0x%lx\n"),
-	     (long) nmemb);
+      error (_("Attempt to re-allocate an array with an excessive number of elements: %#zx\n"),
+	     nmemb);
       xexit (1);
     }
 
@@ -11225,8 +11125,8 @@ xcalloc2 (size_t nmemb, size_t size)
   /* Check for overflow.  */
   if (nmemb >= ~(size_t) 0 / size)
     {
-      error (_("Attempt to allocate a zero'ed array with an excessive number of elements: 0x%lx\n"),
-	     (long) nmemb);
+      error (_("Attempt to allocate a zero'ed array with an excessive number of elements: %#zx\n"),
+	     nmemb);
       xexit (1);
     }
 
diff --git a/binutils/dwarf.h b/binutils/dwarf.h
index d21e6c1b080..bb6128e3b5b 100644
--- a/binutils/dwarf.h
+++ b/binutils/dwarf.h
@@ -20,18 +20,14 @@
 
 #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;
-
 /* Structure found in the .debug_line section.  */
 typedef struct
 {
-  dwarf_vma	 li_length;
+  uint64_t	 li_length;
   unsigned short li_version;
   unsigned char  li_address_size;
   unsigned char  li_segment_size;
-  dwarf_vma      li_prologue_length;
+  uint64_t	 li_prologue_length;
   unsigned char  li_min_insn_length;
   unsigned char  li_max_ops_per_insn;
   unsigned char  li_default_is_stmt;
@@ -45,19 +41,19 @@ DWARF2_Internal_LineInfo;
 /* Structure found in .debug_pubnames section.  */
 typedef struct
 {
-  dwarf_vma	 pn_length;
+  uint64_t	 pn_length;
   unsigned short pn_version;
-  dwarf_vma	 pn_offset;
-  dwarf_vma	 pn_size;
+  uint64_t	 pn_offset;
+  uint64_t	 pn_size;
 }
 DWARF2_Internal_PubNames;
 
 /* Structure found in .debug_info section.  */
 typedef struct
 {
-  dwarf_vma	 cu_length;
+  uint64_t	 cu_length;
   unsigned short cu_version;
-  dwarf_vma	 cu_abbrev_offset;
+  uint64_t	 cu_abbrev_offset;
   unsigned char  cu_pointer_size;
   enum dwarf_unit_type cu_unit_type;
 }
@@ -66,9 +62,9 @@ DWARF2_Internal_CompUnit;
 /* Structure found in .debug_aranges section.  */
 typedef struct
 {
-  dwarf_vma	 ar_length;
+  uint64_t	 ar_length;
   unsigned short ar_version;
-  dwarf_vma	 ar_info_offset;
+  uint64_t	 ar_info_offset;
   unsigned char  ar_pointer_size;
   unsigned char  ar_segment_size;
 }
@@ -143,8 +139,8 @@ struct dwarf_section
      file containing the section.  */
   const char *                     filename;
   unsigned char *                  start;
-  dwarf_vma                        address;
-  dwarf_size_type                  size;
+  uint64_t                         address;
+  uint64_t                         size;
   enum dwarf_section_display_enum  abbrev_sec;
   /* Used by clients to help them implement the reloc_at callback.  */
   void *                           reloc_info;
@@ -170,32 +166,32 @@ typedef struct
   unsigned int   pointer_size;
   unsigned int   offset_size;
   int            dwarf_version;
-  dwarf_vma	 cu_offset;
-  dwarf_vma	 base_address;
+  uint64_t	 cu_offset;
+  uint64_t	 base_address;
   /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
      is used with the form DW_FORM_GNU_addr_index.  */
-  dwarf_vma	 addr_base;
+  uint64_t	 addr_base;
   /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
      is used when calculating ranges.  */
-  dwarf_vma	 ranges_base;
+  uint64_t	 ranges_base;
   /* This is an array of offsets to the location list table.  */
-  dwarf_vma *    loc_offsets;
+  uint64_t *	 loc_offsets;
   /* This is an array of offsets to the location view table.  */
-  dwarf_vma *    loc_views;
+  uint64_t *	 loc_views;
   int *          have_frame_base;
 
   /* Information for associating location lists with CUs.  */
   unsigned int   num_loc_offsets;
   unsigned int   max_loc_offsets;
   unsigned int   num_loc_views;
-  dwarf_vma      loclists_base;
+  uint64_t	 loclists_base;
 
   /* List of .debug_ranges offsets seen in this .debug_info.  */
-  dwarf_vma *    range_lists;
+  uint64_t *	 range_lists;
   unsigned int   num_range_lists;
   unsigned int   max_range_lists;
-  dwarf_vma      rnglists_base;
-  dwarf_vma      str_offsets_base;
+  uint64_t	 rnglists_base;
+  uint64_t	 str_offsets_base;
 }
 debug_info;
 
@@ -268,10 +264,10 @@ extern void * xcrealloc (void *, size_t, size_t);
 /* A callback into the client.  Returns TRUE if there is a
    relocation against the given debug section at the given
    offset.  */
-extern bool reloc_at (struct dwarf_section *, dwarf_vma);
+extern bool reloc_at (struct dwarf_section *, uint64_t);
 
-extern dwarf_vma read_leb128 (unsigned char *, const unsigned char *const,
-			      bool, unsigned int *, int *);
+extern uint64_t read_leb128 (unsigned char *, const unsigned char *const,
+			     bool, unsigned int *, int *);
 
 #if HAVE_LIBDEBUGINFOD
 extern unsigned char * get_build_id (void *);
@@ -307,7 +303,7 @@ report_leb_status (int status)
 #define READ_ULEB(var, start, end)				\
   do								\
     {								\
-      dwarf_vma _val;						\
+      uint64_t _val;						\
       unsigned int _len;					\
       int _status;						\
 								\
@@ -323,7 +319,7 @@ report_leb_status (int status)
 #define READ_SLEB(var, start, end)				\
   do								\
     {								\
-      dwarf_signed_vma _val;					\
+      int64_t _val;						\
       unsigned int _len;					\
       int _status;						\
 								\
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 9259c76c716..188c286e294 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -4043,7 +4043,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
 }
 
 bool
-reloc_at (struct dwarf_section * dsec, dwarf_vma offset)
+reloc_at (struct dwarf_section * dsec, uint64_t offset)
 {
   arelent ** relocs;
   arelent * rp;
diff --git a/binutils/readelf.c b/binutils/readelf.c
index dc571f9fa20..1ec25239938 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -13372,14 +13372,14 @@ display_lto_symtab (Filedata *           filedata,
 	      unsigned int sym_type = * ext_data ++;
 	      unsigned int sec_kind = * ext_data ++;
 
-	      printf ("  %10s %10s %11s %08lx  %08lx %9s %08lx _",
+	      printf ("  %10s %10s %11s %08" PRIx64 "  %08" PRIx64 " %9s %08x _",
 		      * comdat_key == 0 ? "-" : (char *) comdat_key,
 		      get_lto_kind (kind),
 		      get_lto_visibility (visibility),
-		      (long) size,
-		      (long) slot,
+		      size,
+		      slot,
 		      get_lto_sym_type (sym_type),
-		      (long) sec_kind);
+		      sec_kind);
 	      print_symbol (6, (const char *) sym_name);
 	    }
 	  else
@@ -13391,12 +13391,12 @@ display_lto_symtab (Filedata *           filedata,
 	}
       else
 	{
-	  printf ("  %10s %10s %11s %08lx  %08lx _",
+	  printf ("  %10s %10s %11s %08" PRIx64 "  %08" PRIx64 " _",
 		  * comdat_key == 0 ? "-" : (char *) comdat_key,
 		  get_lto_kind (kind),
 		  get_lto_visibility (visibility),
-		  (long) size,
-		  (long) slot);
+		  size,
+		  slot);
 	  print_symbol (21, (const char *) sym_name);
 	}
       putchar ('\n');
@@ -14808,7 +14808,7 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
    section NAME at OFFSET bytes.  */
 
 bool
-reloc_at (struct dwarf_section * dsec, dwarf_vma offset)
+reloc_at (struct dwarf_section * dsec, uint64_t offset)
 {
   Elf_Internal_Rela * relocs;
   Elf_Internal_Rela * rp;
@@ -15119,13 +15119,13 @@ get_section_contents (Elf_Internal_Shdr * section, Filedata * filedata)
 /* Uncompresses a section that was compressed using zlib, in place.  */
 
 static bool
-uncompress_section_contents (unsigned char **   buffer,
-			     dwarf_size_type    uncompressed_size,
-			     dwarf_size_type *  size)
+uncompress_section_contents (unsigned char **buffer,
+			     uint64_t uncompressed_size,
+			     uint64_t *size)
 {
-  dwarf_size_type compressed_size = *size;
-  unsigned char * compressed_buffer = *buffer;
-  unsigned char * uncompressed_buffer;
+  uint64_t compressed_size = *size;
+  unsigned char *compressed_buffer = *buffer;
+  unsigned char *uncompressed_buffer;
   z_stream strm;
   int rc;
 
@@ -15198,8 +15198,8 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
 
   if (decompress_dumps)
     {
-      dwarf_size_type new_size = num_bytes;
-      dwarf_size_type uncompressed_size = 0;
+      uint64_t new_size = num_bytes;
+      uint64_t uncompressed_size = 0;
 
       if ((section->sh_flags & SHF_COMPRESSED) != 0)
 	{
@@ -15414,8 +15414,8 @@ dump_section_as_bytes (Elf_Internal_Shdr *section,
 
   if (decompress_dumps)
     {
-      dwarf_size_type new_size = section_size;
-      dwarf_size_type uncompressed_size = 0;
+      uint64_t new_size = section_size;
+      uint64_t uncompressed_size = 0;
 
       if ((section->sh_flags & SHF_COMPRESSED) != 0)
 	{
@@ -15792,8 +15792,8 @@ load_specific_debug_section (enum dwarf_section_display_enum  debug,
   else
     {
       unsigned char *start = section->start;
-      dwarf_size_type size = sec->sh_size;
-      dwarf_size_type uncompressed_size = 0;
+      uint64_t size = sec->sh_size;
+      uint64_t uncompressed_size = 0;
 
       if ((sec->sh_flags & SHF_COMPRESSED) != 0)
 	{
diff --git a/binutils/sysdep.h b/binutils/sysdep.h
index f2991c7e7ac..ecb1d1a069a 100644
--- a/binutils/sysdep.h
+++ b/binutils/sysdep.h
@@ -120,14 +120,6 @@ extern char **environ;
 
 #include <limits.h>
 
-#if SIZEOF_LONG_LONG > SIZEOF_LONG
-/* We can't use any bfd types here since readelf may define BFD64 and
-   objdump may not.  */
-#define HOST_WIDEST_INT	long long
-#else
-#define HOST_WIDEST_INT long
-#endif
-
 #define POISON_BFD_BOOLEAN 1
 
 #endif /* _BIN_SYSDEP_H */

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-13  6:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-13  6:43 Make dwarf_vma uint64_t Alan Modra

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).