diff mbox

[1/8] Rename read_unsigned_leb128 to gdb_read_unsigned_leb128

Message ID 148693097396.9024.2288256732840761882.stgit@host1.jankratochvil.net
State New
Headers show

Commit Message

Jan Kratochvil Feb. 12, 2017, 8:22 p.m. UTC
Hi,

read_unsigned_leb128 needs to be used outside of dwarf2read.c, removing its
static qualifier.  But then it would clash with bfd/libbfd.c
read_unsigned_leb128 global function of the same name.

Jan


gdb/ChangeLog
2017-01-20  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (read_unsigned_leb128): Rename to ...
	(gdb_read_unsigned_leb128): ... here, update all cases.
---
 gdb/dwarf2read.c |  103 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 54 insertions(+), 49 deletions(-)

Comments

Pedro Alves Feb. 16, 2017, 3:23 p.m. UTC | #1
On 02/12/2017 08:22 PM, Jan Kratochvil wrote:
> Hi,
> 
> read_unsigned_leb128 needs to be used outside of dwarf2read.c, removing its
> static qualifier.  But then it would clash with bfd/libbfd.c
> read_unsigned_leb128 global function of the same name.

Can't we just use bfd's version?  How is gdb's version different?

Thanks,
Pedro Alves
Jan Kratochvil Feb. 16, 2017, 7:40 p.m. UTC | #2
On Thu, 16 Feb 2017 16:23:51 +0100, Pedro Alves wrote:
> Can't we just use bfd's version?

bfd's version is in libbfd.c:
/* Assorted BFD support routines, only used internally.
and libbfd.h:
/* libbfd.h -- Declarations used by bfd library *implementation*.
   (This include file is not for users of the library.)

And I think GDB is a user of libbfd library.

(One could argue libbfd should use visibility and/or C++ namespaces but for
historical reasons libbfd does not use either.)

I do not mind any solution, I have just complied with the libbfd policy.


Jan
Pedro Alves Feb. 16, 2017, 8 p.m. UTC | #3
On 02/16/2017 07:40 PM, Jan Kratochvil wrote:
> On Thu, 16 Feb 2017 16:23:51 +0100, Pedro Alves wrote:
>> Can't we just use bfd's version?
> 
> bfd's version is in libbfd.c:
> /* Assorted BFD support routines, only used internally.
> and libbfd.h:
> /* libbfd.h -- Declarations used by bfd library *implementation*.
>    (This include file is not for users of the library.)
> 
> And I think GDB is a user of libbfd library.
> 
> (One could argue libbfd should use visibility and/or C++ namespaces but for
> historical reasons libbfd does not use either.)
> 
> I do not mind any solution, I have just complied with the libbfd policy.
> 

Bah, there are copies of leb128 reading code all over the toolchain.
binutils/ has read_leb128, gold/ has read_unsigned_LEB_128, gcc
has a copy or two as well.  And then the bfd version (and gdb's
version, which seems to have been copied from bfd's) needs a bfd
pointer, but it's not really necessary.  Cleaning this all
up quickly falls out of scope, so...

Patch is OK.
Pedro Alves Feb. 16, 2017, 10:54 p.m. UTC | #4
On 02/16/2017 08:00 PM, Pedro Alves wrote:
> On 02/16/2017 07:40 PM, Jan Kratochvil wrote:
>> On Thu, 16 Feb 2017 16:23:51 +0100, Pedro Alves wrote:
>>> Can't we just use bfd's version?
>>
>> bfd's version is in libbfd.c:
>> /* Assorted BFD support routines, only used internally.
>> and libbfd.h:
>> /* libbfd.h -- Declarations used by bfd library *implementation*.
>>    (This include file is not for users of the library.)
>>
>> And I think GDB is a user of libbfd library.
>>
>> (One could argue libbfd should use visibility and/or C++ namespaces but for
>> historical reasons libbfd does not use either.)
>>
>> I do not mind any solution, I have just complied with the libbfd policy.
>>
> 
> Bah, there are copies of leb128 reading code all over the toolchain.
> binutils/ has read_leb128, gold/ has read_unsigned_LEB_128, gcc
> has a copy or two as well.  And then the bfd version (and gdb's
> version, which seems to have been copied from bfd's) needs a bfd
> pointer, but it's not really necessary.  Cleaning this all
> up quickly falls out of scope, so...
> 
> Patch is OK.

Actually, I think visibility wouldn't work given bfd is linked
statically.  And C++ namespaces are out of question obviously
given bfd is written in C.  That leaves avoiding namespace
collision by renaming something, but I think that given
that it's bfd that is a library, that it should be bfd
that should have its internal-with-external-linkage symbols
renamed, giving them a "_bfd_" prefix, as other internal
symbols have.  I quickly hacked up a mini-series to rename these
plus a few others I noticed by playing with nm + grep.  I'll
post it to binutils@ in a bit.

Thanks,
Pedro Alves
Pedro Alves Feb. 17, 2017, 1:28 a.m. UTC | #5
On 02/16/2017 10:54 PM, Pedro Alves wrote:

> Actually, I think visibility wouldn't work given bfd is linked
> statically.  And C++ namespaces are out of question obviously
> given bfd is written in C.  That leaves avoiding namespace
> collision by renaming something, but I think that given
> that it's bfd that is a library, that it should be bfd
> that should have its internal-with-external-linkage symbols
> renamed, giving them a "_bfd_" prefix, as other internal
> symbols have.  I quickly hacked up a mini-series to rename these
> plus a few others I noticed by playing with nm + grep.  I'll
> post it to binutils@ in a bit.

FYI, this is now done, and merged to master:
  https://sourceware.org/ml/binutils/2017-02/msg00165.html

Thanks,
Pedro Alves
Jan Kratochvil Feb. 19, 2017, 9:25 p.m. UTC | #6
On Thu, 16 Feb 2017 23:54:15 +0100, Pedro Alves wrote:
> Actually, I think visibility wouldn't work given bfd is linked statically.

Yes, that is a binutils-gdb project management bug.  That way all the library
bugs have to be backported by distros twice (to binutils and gdb).


> And C++ namespaces are out of question obviously given bfd is written in C.

Another bug. :-)


> I quickly hacked up a mini-series to rename these
> plus a few others I noticed by playing with nm + grep.

OK, thanks, dropped this patch.


Jan
diff mbox

Patch

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 774ed73..bf381a7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1509,7 +1509,8 @@  static const char *read_indirect_string (bfd *, const gdb_byte *,
 
 static const char *read_indirect_string_from_dwz (struct dwz_file *, LONGEST);
 
-static ULONGEST read_unsigned_leb128 (bfd *, const gdb_byte *, unsigned int *);
+static ULONGEST gdb_read_unsigned_leb128 (bfd *, const gdb_byte *,
+					  unsigned int *);
 
 static LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *);
 
@@ -7195,7 +7196,7 @@  peek_abbrev_code (bfd *abfd, const gdb_byte *info_ptr)
 {
   unsigned int bytes_read;
 
-  return read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+  return gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 }
 
 /* Read the initial uleb128 in the die at INFO_PTR in compilation unit CU.
@@ -7211,7 +7212,7 @@  peek_die_abbrev (const gdb_byte *info_ptr, unsigned int *bytes_read,
   unsigned int abbrev_number;
   struct abbrev_info *abbrev;
 
-  abbrev_number = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
+  abbrev_number = gdb_read_unsigned_leb128 (abfd, info_ptr, bytes_read);
 
   if (abbrev_number == 0)
     return NULL;
@@ -7341,7 +7342,7 @@  skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
 	  break;
 	case DW_FORM_exprloc:
 	case DW_FORM_block:
-	  info_ptr += read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+	  info_ptr += gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 	  info_ptr += bytes_read;
 	  break;
 	case DW_FORM_block1:
@@ -7361,7 +7362,7 @@  skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr,
 	  info_ptr = safe_skip_leb128 (info_ptr, buffer_end);
 	  break;
 	case DW_FORM_indirect:
-	  form = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+	  form = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 	  info_ptr += bytes_read;
 	  /* We need to continue parsing from here, so just go back to
 	     the top.  */
@@ -15212,7 +15213,7 @@  read_full_die_1 (const struct die_reader_specs *reader,
   bfd *abfd = reader->abfd;
 
   offset.sect_off = info_ptr - reader->buffer;
-  abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+  abbrev_number = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
   info_ptr += bytes_read;
   if (!abbrev_number)
     {
@@ -15356,7 +15357,7 @@  abbrev_table_read_table (struct dwarf2_section_info *section,
 
   dwarf2_read_section (objfile, section);
   abbrev_ptr = section->buffer + offset.sect_off;
-  abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+  abbrev_number = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
   abbrev_ptr += bytes_read;
 
   allocated_attrs = ATTR_ALLOC_CHUNK;
@@ -15369,16 +15370,17 @@  abbrev_table_read_table (struct dwarf2_section_info *section,
 
       /* read in abbrev header */
       cur_abbrev->number = abbrev_number;
-      cur_abbrev->tag
-	= (enum dwarf_tag) read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      cur_abbrev->tag = (enum dwarf_tag) gdb_read_unsigned_leb128 (abfd,
+								   abbrev_ptr,
+								   &bytes_read);
       abbrev_ptr += bytes_read;
       cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr);
       abbrev_ptr += 1;
 
       /* now read in declarations */
-      abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
       abbrev_ptr += bytes_read;
-      abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
       abbrev_ptr += bytes_read;
       while (abbrev_name)
 	{
@@ -15393,9 +15395,9 @@  abbrev_table_read_table (struct dwarf2_section_info *section,
 	    = (enum dwarf_attribute) abbrev_name;
 	  cur_attrs[cur_abbrev->num_attrs++].form
 	    = (enum dwarf_form) abbrev_form;
-	  abbrev_name = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_name = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
-	  abbrev_form = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+	  abbrev_form = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
 	  abbrev_ptr += bytes_read;
 	}
 
@@ -15416,7 +15418,7 @@  abbrev_table_read_table (struct dwarf2_section_info *section,
          table is reached.  */
       if ((unsigned int) (abbrev_ptr - section->buffer) >= section->size)
 	break;
-      abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
+      abbrev_number = gdb_read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
       abbrev_ptr += bytes_read;
       if (abbrev_table_lookup_abbrev (abbrev_table, abbrev_number) != NULL)
 	break;
@@ -16321,7 +16323,7 @@  read_attribute_value (const struct die_reader_specs *reader,
     case DW_FORM_exprloc:
     case DW_FORM_block:
       blk = dwarf_alloc_block (cu);
-      blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+      blk->size = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       blk->data = read_n_bytes (abfd, info_ptr, blk->size);
       info_ptr += blk->size;
@@ -16351,7 +16353,7 @@  read_attribute_value (const struct die_reader_specs *reader,
       info_ptr += bytes_read;
       break;
     case DW_FORM_udata:
-      DW_UNSND (attr) = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+      DW_UNSND (attr) = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       break;
     case DW_FORM_ref1:
@@ -16380,11 +16382,12 @@  read_attribute_value (const struct die_reader_specs *reader,
       break;
     case DW_FORM_ref_udata:
       DW_UNSND (attr) = (cu->header.offset.sect_off
-			 + read_unsigned_leb128 (abfd, info_ptr, &bytes_read));
+			 + gdb_read_unsigned_leb128 (abfd, info_ptr,
+						     &bytes_read));
       info_ptr += bytes_read;
       break;
     case DW_FORM_indirect:
-      form = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+      form = gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       info_ptr = read_attribute_value (reader, attr, form, info_ptr);
       break;
@@ -16411,7 +16414,7 @@  read_attribute_value (const struct die_reader_specs *reader,
 	}
       {
 	ULONGEST str_index =
-	  read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
+	  gdb_read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
 
 	DW_STRING (attr) = read_str_index (reader, str_index);
 	DW_STRING_IS_CANONICAL (attr) = 0;
@@ -16761,8 +16764,8 @@  read_indirect_string (bfd *abfd, const gdb_byte *buf,
 }
 
 static ULONGEST
-read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf,
-		      unsigned int *bytes_read_ptr)
+gdb_read_unsigned_leb128 (bfd *abfd, const gdb_byte *buf,
+			  unsigned int *bytes_read_ptr)
 {
   ULONGEST result;
   unsigned int num_read;
@@ -16859,7 +16862,8 @@  read_addr_index_from_leb128 (struct dwarf2_cu *cu, const gdb_byte *info_ptr,
 			     unsigned int *bytes_read)
 {
   bfd *abfd = cu->objfile->obfd;
-  unsigned int addr_index = read_unsigned_leb128 (abfd, info_ptr, bytes_read);
+  unsigned int addr_index = gdb_read_unsigned_leb128 (abfd, info_ptr,
+						      bytes_read);
 
   return read_addr_index (cu, addr_index);
 }
@@ -17428,11 +17432,11 @@  dwarf_decode_line_header (unsigned int offset, struct dwarf2_cu *cu)
       unsigned int dir_index, mod_time, length;
 
       line_ptr += bytes_read;
-      dir_index = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      dir_index = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      mod_time = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      mod_time = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
-      length = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+      length = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
       line_ptr += bytes_read;
 
       add_file_name (lh, cur_file, dir_index, mod_time, length);
@@ -17893,7 +17897,7 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	  else switch (op_code)
 	    {
 	    case DW_LNS_extended_op:
-	      extended_len = read_unsigned_leb128 (abfd, line_ptr,
+	      extended_len = gdb_read_unsigned_leb128 (abfd, line_ptr,
 						   &bytes_read);
 	      line_ptr += bytes_read;
 	      extended_end = line_ptr + extended_len;
@@ -17928,13 +17932,13 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 						   &bytes_read);
                     line_ptr += bytes_read;
                     dir_index =
-                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                      gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     mod_time =
-                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                      gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     length =
-                      read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+                      gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
                     line_ptr += bytes_read;
                     add_file_name (lh, cur_file, dir_index, mod_time, length);
                   }
@@ -17946,7 +17950,7 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 		     (non-prologue) line we want to coalesce them.
 		     PR 17276.  */
 		  state_machine.discriminator
-		    = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+		    = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		  state_machine.line_has_non_zero_discriminator
 		    |= state_machine.discriminator != 0;
 		  line_ptr += bytes_read;
@@ -17973,7 +17977,7 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	    case DW_LNS_advance_pc:
 	      {
 		CORE_ADDR adjust
-		  = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+		  = gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		CORE_ADDR addr_adj;
 
 		addr_adj = (((state_machine.op_index + adjust)
@@ -18006,7 +18010,7 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 		struct file_entry *fe;
 		const char *dir = NULL;
 
-		state_machine.file = read_unsigned_leb128 (abfd, line_ptr,
+		state_machine.file = gdb_read_unsigned_leb128 (abfd, line_ptr,
 							   &bytes_read);
 		line_ptr += bytes_read;
 		if (state_machine.file == 0
@@ -18028,7 +18032,7 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 	      }
 	      break;
 	    case DW_LNS_set_column:
-	      (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	      (void) gdb_read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 	      line_ptr += bytes_read;
 	      break;
 	    case DW_LNS_negate_stmt:
@@ -18073,7 +18077,8 @@  dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
 
 		for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++)
 		  {
-		    (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+		    (void) gdb_read_unsigned_leb128 (abfd, line_ptr,
+						     &bytes_read);
 		    line_ptr += bytes_read;
 		  }
 	      }
@@ -20644,7 +20649,7 @@  decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 	  break;
 
 	case DW_OP_regx:
-	  unsnd = read_unsigned_leb128 (NULL, (data + i), &bytes_read);
+	  unsnd = gdb_read_unsigned_leb128 (NULL, (data + i), &bytes_read);
 	  i += bytes_read;
 	  stack[++stacki] = unsnd;
 	  if (i < size)
@@ -20693,7 +20698,7 @@  decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 	  break;
 
 	case DW_OP_constu:
-	  stack[++stacki] = read_unsigned_leb128 (NULL, (data + i),
+	  stack[++stacki] = gdb_read_unsigned_leb128 (NULL, (data + i),
 						  &bytes_read);
 	  i += bytes_read;
 	  break;
@@ -20714,7 +20719,7 @@  decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
 	  break;
 
 	case DW_OP_plus_uconst:
-	  stack[stacki] += read_unsigned_leb128 (NULL, (data + i),
+	  stack[stacki] += gdb_read_unsigned_leb128 (NULL, (data + i),
 						 &bytes_read);
 	  i += bytes_read;
 	  break;
@@ -21118,7 +21123,7 @@  skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end,
       break;
 
     case DW_FORM_block:
-      bytes += read_unsigned_leb128 (abfd, bytes, &bytes_read);
+      bytes += gdb_read_unsigned_leb128 (abfd, bytes, &bytes_read);
       bytes += bytes_read;
       break;
 
@@ -21182,7 +21187,7 @@  skip_unknown_opcode (unsigned int opcode,
     }
 
   defn = opcode_definitions[opcode];
-  arg = read_unsigned_leb128 (abfd, defn, &bytes_read);
+  arg = gdb_read_unsigned_leb128 (abfd, defn, &bytes_read);
   defn += bytes_read;
 
   for (i = 0; i < arg; ++i)
@@ -21251,7 +21256,7 @@  dwarf_parse_macro_header (const gdb_byte **opcode_definitions,
 	      opcode = read_1_byte (abfd, mac_ptr);
 	      ++mac_ptr;
 	      opcode_definitions[opcode] = mac_ptr;
-	      arg = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	      arg = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
 	      mac_ptr += arg;
 	    }
@@ -21329,7 +21334,7 @@  dwarf_decode_macro_bytes (bfd *abfd,
             const char *body;
 	    int is_define;
 
-	    line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    line = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
 	    if (macinfo_type == DW_MACRO_GNU_define
@@ -21395,9 +21400,9 @@  dwarf_decode_macro_bytes (bfd *abfd,
             unsigned int bytes_read;
             int line, file;
 
-            line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+            line = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
-            file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+            file = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
             mac_ptr += bytes_read;
 
 	    if ((line == 0 && !at_commandline)
@@ -21516,7 +21521,7 @@  dwarf_decode_macro_bytes (bfd *abfd,
 
 	      /* This reads the constant, but since we don't recognize
 		 any vendor extensions, we ignore it.  */
-	      read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	      gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
 	      read_direct_string (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
@@ -21640,7 +21645,7 @@  dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  {
 	    unsigned int bytes_read;
 
-	    read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 	    read_direct_string (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
@@ -21652,9 +21657,9 @@  dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	    unsigned int bytes_read;
 	    int line, file;
 
-	    line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    line = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
-	    file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    file = gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 
 	    current_file = macro_start_file (file, line, current_file, lh);
@@ -21672,7 +21677,7 @@  dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	  {
 	    unsigned int bytes_read;
 
-	    read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	    gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	    mac_ptr += bytes_read;
 	    mac_ptr += offset_size;
 	  }
@@ -21692,7 +21697,7 @@  dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
 	    {
 	      unsigned int bytes_read;
 
-	      read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+	      gdb_read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;
 	      read_direct_string (abfd, mac_ptr, &bytes_read);
 	      mac_ptr += bytes_read;