public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/5] bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
  2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
  2017-02-17  0:18 ` [PATCH 2/5] bfd: Rename real_{ftell, fseek, fopen} Pedro Alves
@ 2017-02-17  0:18 ` Pedro Alves
  2017-02-17  0:18 ` [PATCH 3/5] bfd: Rename warn_deprecated Pedro Alves
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  0:18 UTC (permalink / raw)
  To: binutils

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-16  Pedro Alves  <palves@redhat.com>

	* dwarf2.c, elf-attrs.c, elf32-nds32.c: Adjust all callers.
	* libbfd.c (read_unsigned_leb128): Rename to ...
	(_bfd_read_unsigned_leb128): ... this.
	(read_signed_leb128): Rename to ...
	(_bfd_read_signed_leb128): ... this.
	(safe_read_leb128): Rename to ...
	(_bfd_safe_read_leb128): ... this.
	* libbfd-in.h (read_unsigned_leb128): Rename to ...
	(_bfd_read_unsigned_leb128): ... this.
	(read_signed_leb128): Rename to ...
	(_bfd_read_signed_leb128): ... this.
	(safe_read_leb128): Rename to ...
	(_bfd_safe_read_leb128): ... this.
	* libbfd.h: Renegerate.
---
 bfd/dwarf2.c      | 87 ++++++++++++++++++++++++++++++++++++-------------------
 bfd/elf-attrs.c   |  8 ++---
 bfd/elf32-nds32.c |  4 +--
 bfd/libbfd-in.h   |  8 ++---
 bfd/libbfd.c      | 22 +++++++-------
 bfd/libbfd.h      |  8 ++---
 6 files changed, 82 insertions(+), 55 deletions(-)

diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 9bb8126..25a9ebc 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -920,15 +920,18 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash)
       /* Read in abbrev header.  */
       cur_abbrev->number = abbrev_number;
       cur_abbrev->tag = (enum dwarf_tag)
-	safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+	_bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+			       FALSE, abbrev_end);
       abbrev_ptr += bytes_read;
       cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr, abbrev_end);
       abbrev_ptr += 1;
 
       /* Now read in declarations.  */
-      abbrev_name = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+      abbrev_name = _bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+					   FALSE, abbrev_end);
       abbrev_ptr += bytes_read;
-      abbrev_form = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+      abbrev_form = _bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+					   FALSE, abbrev_end);
       abbrev_ptr += bytes_read;
 
       while (abbrev_name)
@@ -963,9 +966,11 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash)
 	    = (enum dwarf_attribute) abbrev_name;
 	  cur_abbrev->attrs[cur_abbrev->num_attrs++].form
 	    = (enum dwarf_form) abbrev_form;
-	  abbrev_name = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+	  abbrev_name = _bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+					       FALSE, abbrev_end);
 	  abbrev_ptr += bytes_read;
-	  abbrev_form = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+	  abbrev_form = _bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+					       FALSE, abbrev_end);
 	  abbrev_ptr += bytes_read;
 	}
 
@@ -983,7 +988,8 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash)
       if ((unsigned int) (abbrev_ptr - stash->dwarf_abbrev_buffer)
 	  >= stash->dwarf_abbrev_size)
 	break;
-      abbrev_number = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+      abbrev_number = _bfd_safe_read_leb128 (abfd, abbrev_ptr,
+					     &bytes_read, FALSE, abbrev_end);
       abbrev_ptr += bytes_read;
       if (lookup_abbrev (abbrev_number, abbrevs) != NULL)
 	break;
@@ -1104,7 +1110,8 @@ read_attribute_value (struct attribute *  attr,
       blk = (struct dwarf_block *) bfd_alloc (abfd, amt);
       if (blk == NULL)
 	return NULL;
-      blk->size = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end);
+      blk->size = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					 FALSE, info_ptr_end);
       info_ptr += bytes_read;
       blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size);
       info_ptr += blk->size;
@@ -1133,11 +1140,13 @@ read_attribute_value (struct attribute *  attr,
       attr->u.val = 1;
       break;
     case DW_FORM_sdata:
-      attr->u.sval = safe_read_leb128 (abfd, info_ptr, &bytes_read, TRUE, info_ptr_end);
+      attr->u.sval = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					    TRUE, info_ptr_end);
       info_ptr += bytes_read;
       break;
     case DW_FORM_udata:
-      attr->u.val = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end);
+      attr->u.val = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					   FALSE, info_ptr_end);
       info_ptr += bytes_read;
       break;
     case DW_FORM_ref1:
@@ -1161,11 +1170,13 @@ read_attribute_value (struct attribute *  attr,
       info_ptr += 8;
       break;
     case DW_FORM_ref_udata:
-      attr->u.val = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end);
+      attr->u.val = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					   FALSE, info_ptr_end);
       info_ptr += bytes_read;
       break;
     case DW_FORM_indirect:
-      form = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end);
+      form = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+				    FALSE, info_ptr_end);
       info_ptr += bytes_read;
       info_ptr = read_attribute_value (attr, form, unit, info_ptr, info_ptr_end);
       break;
@@ -1918,11 +1929,13 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 
       table->files[table->num_files].name = cur_file;
       table->files[table->num_files].dir =
-	safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+	_bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
       line_ptr += bytes_read;
-      table->files[table->num_files].time = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+      table->files[table->num_files].time
+	= _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
       line_ptr += bytes_read;
-      table->files[table->num_files].size = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+      table->files[table->num_files].size
+	= _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
       line_ptr += bytes_read;
       table->num_files++;
     }
@@ -1986,7 +1999,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 	  else switch (op_code)
 	    {
 	    case DW_LNS_extended_op:
-	      exop_len = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+	      exop_len = _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+						FALSE, line_end);
 	      line_ptr += bytes_read;
 	      extended_op = read_1_byte (abfd, line_ptr, line_end);
 	      line_ptr += 1;
@@ -2027,19 +2041,23 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 		    }
 		  table->files[table->num_files].name = cur_file;
 		  table->files[table->num_files].dir =
-		    safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+		    _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					   FALSE, line_end);
 		  line_ptr += bytes_read;
 		  table->files[table->num_files].time =
-		    safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+		    _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					   FALSE, line_end);
 		  line_ptr += bytes_read;
 		  table->files[table->num_files].size =
-		    safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+		    _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					   FALSE, line_end);
 		  line_ptr += bytes_read;
 		  table->num_files++;
 		  break;
 		case DW_LNE_set_discriminator:
 		  discriminator =
-		    safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+		    _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					   FALSE, line_end);
 		  line_ptr += bytes_read;
 		  break;
 		case DW_LNE_HP_source_file_correlation:
@@ -2068,12 +2086,14 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 	    case DW_LNS_advance_pc:
 	      if (lh.maximum_ops_per_insn == 1)
 		address += (lh.minimum_instruction_length
-			    * safe_read_leb128 (abfd, line_ptr, &bytes_read,
-						FALSE, line_end));
+			    * _bfd_safe_read_leb128 (abfd, line_ptr,
+						     &bytes_read,
+						     FALSE, line_end));
 	      else
 		{
-		  bfd_vma adjust = safe_read_leb128 (abfd, line_ptr, &bytes_read,
-						     FALSE, line_end);
+		  bfd_vma adjust = _bfd_safe_read_leb128 (abfd, line_ptr,
+							  &bytes_read,
+							  FALSE, line_end);
 		  address = ((op_index + adjust) / lh.maximum_ops_per_insn
 			     * lh.minimum_instruction_length);
 		  op_index = (op_index + adjust) % lh.maximum_ops_per_insn;
@@ -2081,7 +2101,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 	      line_ptr += bytes_read;
 	      break;
 	    case DW_LNS_advance_line:
-	      line += safe_read_leb128 (abfd, line_ptr, &bytes_read, TRUE, line_end);
+	      line += _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					     TRUE, line_end);
 	      line_ptr += bytes_read;
 	      break;
 	    case DW_LNS_set_file:
@@ -2090,7 +2111,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 
 		/* The file and directory tables are 0
 		   based, the references are 1 based.  */
-		file = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+		file = _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					      FALSE, line_end);
 		line_ptr += bytes_read;
 		if (filename)
 		  free (filename);
@@ -2098,7 +2120,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 		break;
 	      }
 	    case DW_LNS_set_column:
-	      column = safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+	      column = _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+					      FALSE, line_end);
 	      line_ptr += bytes_read;
 	      break;
 	    case DW_LNS_negate_stmt:
@@ -2128,7 +2151,8 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash)
 	      /* Unknown standard opcode, ignore it.  */
 	      for (i = 0; i < lh.standard_opcode_lengths[op_code]; i++)
 		{
-		  (void) safe_read_leb128 (abfd, line_ptr, &bytes_read, FALSE, line_end);
+		  (void) _bfd_safe_read_leb128 (abfd, line_ptr, &bytes_read,
+						FALSE, line_end);
 		  line_ptr += bytes_read;
 		}
 	      break;
@@ -2562,7 +2586,8 @@ find_abstract_instance_name (struct comp_unit *unit,
       info_ptr_end = unit->end_ptr;
     }
 
-  abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end);
+  abbrev_number = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					 FALSE, info_ptr_end);
   info_ptr += bytes_read;
 
   if (abbrev_number)
@@ -2702,7 +2727,8 @@ scan_unit_for_symbols (struct comp_unit *unit)
       if (info_ptr >= info_ptr_end)
 	goto fail;
 
-      abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, info_ptr_end);
+      abbrev_number = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					     FALSE, info_ptr_end);
       info_ptr += bytes_read;
 
       if (! abbrev_number)
@@ -3018,7 +3044,8 @@ parse_comp_unit (struct dwarf2_debug *stash,
   if (! abbrevs)
     return NULL;
 
-  abbrev_number = safe_read_leb128 (abfd, info_ptr, &bytes_read, FALSE, end_ptr);
+  abbrev_number = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read,
+					 FALSE, end_ptr);
   info_ptr += bytes_read;
   if (! abbrev_number)
     {
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index f7bfce9..def1345 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -493,7 +493,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
 	      bfd_vma subsection_len;
 	      bfd_byte *end;
 
-	      tag = safe_read_leb128 (abfd, p, &n, FALSE, p_end);
+	      tag = _bfd_safe_read_leb128 (abfd, p, &n, FALSE, p_end);
 	      p += n;
 	      if (p < p_end - 4)
 		subsection_len = bfd_get_32 (abfd, p);
@@ -517,13 +517,13 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
 		    {
 		      int type;
 
-		      tag = safe_read_leb128 (abfd, p, &n, FALSE, end);
+		      tag = _bfd_safe_read_leb128 (abfd, p, &n, FALSE, end);
 		      p += n;
 		      type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag);
 		      switch (type & (ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL))
 			{
 			case ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL:
-			  val = safe_read_leb128 (abfd, p, &n, FALSE, end);
+			  val = _bfd_safe_read_leb128 (abfd, p, &n, FALSE, end);
 			  p += n;
 			  bfd_elf_add_obj_attr_int_string (abfd, vendor, tag,
 							   val, (char *) p);
@@ -535,7 +535,7 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
 			  p += strlen ((char *)p) + 1;
 			  break;
 			case ATTR_TYPE_FLAG_INT_VAL:
-			  val = safe_read_leb128 (abfd, p, &n, FALSE, end);
+			  val = _bfd_safe_read_leb128 (abfd, p, &n, FALSE, end);
 			  p += n;
 			  bfd_elf_add_obj_attr_int (abfd, vendor, tag, val);
 			  break;
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index 3d510a0..9828160 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -8696,8 +8696,8 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec,
 	      unsigned long before, between;
 	      bfd_byte *endp, *p;
 
-	      val = read_unsigned_leb128 (abfd, contents + irel->r_offset,
-					  &len);
+	      val = _bfd_read_unsigned_leb128 (abfd, contents + irel->r_offset,
+					       &len);
 
 	      before = get_nds32_elf_blank_total (&blank_t, irel->r_addend, 0);
 	      between = get_nds32_elf_blank_total (&blank_t,
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index eb88611..2776d62 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -851,7 +851,7 @@ extern void bfd_section_already_linked_table_traverse
   (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
 		    void *), void *);
 
-extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
-extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
-extern bfd_vma safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
-				 bfd_boolean, const bfd_byte * const);
+extern bfd_vma _bfd_read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
+extern bfd_signed_vma _bfd_read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
+extern bfd_vma _bfd_safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
+				      bfd_boolean, const bfd_byte * const);
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 236818e..4a3e4c2 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -954,9 +954,9 @@ warn_deprecated (const char *what,
 /* Helper function for reading uleb128 encoded data.  */
 
 bfd_vma
-read_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
-		      bfd_byte *buf,
-		      unsigned int *bytes_read_ptr)
+_bfd_read_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
+			   bfd_byte *buf,
+			   unsigned int *bytes_read_ptr)
 {
   bfd_vma result;
   unsigned int num_read;
@@ -985,11 +985,11 @@ read_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
    No bytes will be read at address END or beyond.  */
 
 bfd_vma
-safe_read_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
-		  bfd_byte *data,
-		  unsigned int *length_return,
-		  bfd_boolean sign,
-		  const bfd_byte * const end)
+_bfd_safe_read_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
+		       bfd_byte *data,
+		       unsigned int *length_return,
+		       bfd_boolean sign,
+		       const bfd_byte * const end)
 {
   bfd_vma result = 0;
   unsigned int num_read = 0;
@@ -1021,9 +1021,9 @@ safe_read_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
 /* Helper function for reading sleb128 encoded data.  */
 
 bfd_signed_vma
-read_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
-		    bfd_byte *buf,
-		    unsigned int *bytes_read_ptr)
+_bfd_read_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
+			 bfd_byte *buf,
+			 unsigned int *bytes_read_ptr)
 {
   bfd_vma result;
   unsigned int shift;
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 2cbb0b0..3ea747d 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -856,10 +856,10 @@ extern void bfd_section_already_linked_table_traverse
   (bfd_boolean (*) (struct bfd_section_already_linked_hash_entry *,
 		    void *), void *);
 
-extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
-extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
-extern bfd_vma safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
-				 bfd_boolean, const bfd_byte * const);
+extern bfd_vma _bfd_read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
+extern bfd_signed_vma _bfd_read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
+extern bfd_vma _bfd_safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
+				      bfd_boolean, const bfd_byte * const);
 /* Extracted from libbfd.c.  */
 bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
 
-- 
2.5.5

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

* [PATCH 0/5] Rename a few internal symbols to avoid collisions
@ 2017-02-17  0:18 Pedro Alves
  2017-02-17  0:18 ` [PATCH 2/5] bfd: Rename real_{ftell, fseek, fopen} Pedro Alves
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  0:18 UTC (permalink / raw)
  To: binutils

Jan ran into a global symbol name conflict between GDB and BFD here:
  https://sourceware.org/ml/gdb-patches/2017-02/msg00299.html

The BFD symbols in question are not part of the BFD API, however they
need to have external linkage.  Given that BFD is a library, I think
that it's BFD that should be a bit more careful in the name of symbols
it exports.  I.e., to avoid naming conflicts with projects that use
BFD, these symbols should have names in BFD's "internal namespace",
i.e,. they should have a "_bfd_" prefix.

Playing with:
 $ nm -A libbfd.a | grep " T " | grep -v " bfd" | grep -v " _bfd"
 $ nm -A libbfd.a | grep " B " | grep -v " bfd" | grep -v " _bfd"
 $ nm -A libbfd.a | grep " D " | grep -v " bfd" | grep -v " _bfd"

I noticed quite a few others that need similar treatment.  This series
fixes a few easy glaring ones, though there's a lot more that could be
done [which I don't really plan on doing].

OK?

Pedro Alves (5):
  bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
  bfd: Rename real_{ftell, fseek, fopen}
  bfd: Rename warn_deprecated
  bfd: Rename bsd_write_armap and coff_write_armap
  bfd: Rename Chunk and S3Forced

 bfd/aout-target.h  |  2 +-
 bfd/aout-tic30.c   |  2 +-
 bfd/archive.c      | 20 ++++++------
 bfd/bfd-in.h       | 10 +++---
 bfd/bfd-in2.h      | 10 +++---
 bfd/bfdio.c        |  6 ++--
 bfd/cache.c        | 17 ++++++-----
 bfd/dwarf2.c       | 90 +++++++++++++++++++++++++++++++++++-------------------
 bfd/elf-attrs.c    |  8 ++---
 bfd/elf32-nds32.c  |  4 +--
 bfd/libbfd-in.h    | 24 +++++++--------
 bfd/libbfd.c       | 30 +++++++++---------
 bfd/libbfd.h       | 24 +++++++--------
 bfd/opncls.c       |  8 ++---
 bfd/srec.c         | 22 ++++++-------
 binutils/objcopy.c | 12 ++++----
 16 files changed, 159 insertions(+), 130 deletions(-)

-- 
2.5.5

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

* [PATCH 2/5] bfd: Rename real_{ftell, fseek, fopen}
  2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
@ 2017-02-17  0:18 ` Pedro Alves
  2017-02-17  0:18 ` [PATCH 1/5] bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128 Pedro Alves
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  0:18 UTC (permalink / raw)
  To: binutils

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-16  Pedro Alves  <palves@redhat.com>

	* bfdio.c (real_ftell): Rename to ...
	(_bfd_real_ftell): ... this.
	(real_fseek): Rename to ...
	(_bfd_real_fseek): ... this.
	(real_fopen): Rename to ...
	(_bfd_real_fopen): ... this.
	* libbfd-in.h (real_ftell): Rename to ...
	(_bfd_real_ftell): ... this.
	(real_fseek): Rename to ...
	(_bfd_real_fseek): ... this.
	(real_fopen): Rename to ...
	(_bfd_real_fopen): ... this.
	* cache.c, dwarf2.c, opncls.c: Adjust all callers.
	* libbfd.h: Regenerate.
---
 bfd/bfdio.c     |  6 +++---
 bfd/cache.c     | 17 +++++++++--------
 bfd/dwarf2.c    |  3 ++-
 bfd/libbfd-in.h |  6 +++---
 bfd/libbfd.h    |  6 +++---
 bfd/opncls.c    |  8 ++++----
 6 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index e73acdf..792ccda 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -41,7 +41,7 @@
 #endif
 
 file_ptr
-real_ftell (FILE *file)
+_bfd_real_ftell (FILE *file)
 {
 #if defined (HAVE_FTELLO64)
   return ftello64 (file);
@@ -53,7 +53,7 @@ real_ftell (FILE *file)
 }
 
 int
-real_fseek (FILE *file, file_ptr offset, int whence)
+_bfd_real_fseek (FILE *file, file_ptr offset, int whence)
 {
 #if defined (HAVE_FSEEKO64)
   return fseeko64 (file, offset, whence);
@@ -82,7 +82,7 @@ close_on_exec (FILE *file)
 }
 
 FILE *
-real_fopen (const char *filename, const char *modes)
+_bfd_real_fopen (const char *filename, const char *modes)
 {
 #ifdef VMS
   char *vms_attr;
diff --git a/bfd/cache.c b/bfd/cache.c
index 0f8a9d1..17bca8b 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -212,7 +212,7 @@ close_one (void)
       return TRUE;
     }
 
-  to_kill->where = real_ftell ((FILE *) to_kill->iostream);
+  to_kill->where = _bfd_real_ftell ((FILE *) to_kill->iostream);
 
   return bfd_cache_delete (to_kill);
 }
@@ -262,7 +262,8 @@ bfd_cache_lookup_worker (bfd *abfd, enum cache_flag flag)
   if (bfd_open_file (abfd) == NULL)
     ;
   else if (!(flag & CACHE_NO_SEEK)
-	   && real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0
+	   && _bfd_real_fseek ((FILE *) abfd->iostream,
+			       abfd->where, SEEK_SET) != 0
 	   && !(flag & CACHE_NO_SEEK_ERROR))
     bfd_set_error (bfd_error_system_call);
   else
@@ -280,7 +281,7 @@ cache_btell (struct bfd *abfd)
   FILE *f = bfd_cache_lookup (abfd, CACHE_NO_OPEN);
   if (f == NULL)
     return abfd->where;
-  return real_ftell (f);
+  return _bfd_real_ftell (f);
 }
 
 static int
@@ -289,7 +290,7 @@ cache_bseek (struct bfd *abfd, file_ptr offset, int whence)
   FILE *f = bfd_cache_lookup (abfd, whence != SEEK_CUR ? CACHE_NO_SEEK : CACHE_NORMAL);
   if (f == NULL)
     return -1;
-  return real_fseek (f, offset, whence);
+  return _bfd_real_fseek (f, offset, whence);
 }
 
 /* Note that archive entries don't have streams; they share their parent's.
@@ -609,15 +610,15 @@ bfd_open_file (bfd *abfd)
     {
     case read_direction:
     case no_direction:
-      abfd->iostream = real_fopen (abfd->filename, FOPEN_RB);
+      abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_RB);
       break;
     case both_direction:
     case write_direction:
       if (abfd->opened_once)
 	{
-	  abfd->iostream = real_fopen (abfd->filename, FOPEN_RUB);
+	  abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_RUB);
 	  if (abfd->iostream == NULL)
-	    abfd->iostream = real_fopen (abfd->filename, FOPEN_WUB);
+	    abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_WUB);
 	}
       else
 	{
@@ -647,7 +648,7 @@ bfd_open_file (bfd *abfd)
 	  if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
 	    unlink_if_ordinary (abfd->filename);
 #endif
-	  abfd->iostream = real_fopen (abfd->filename, FOPEN_WUB);
+	  abfd->iostream = _bfd_real_fopen (abfd->filename, FOPEN_WUB);
 	  abfd->opened_once = TRUE;
 	}
       break;
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 25a9ebc..722ee0d 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -906,7 +906,8 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash)
 
   abbrev_ptr = stash->dwarf_abbrev_buffer + offset;
   abbrev_end = stash->dwarf_abbrev_buffer + stash->dwarf_abbrev_size;
-  abbrev_number = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+  abbrev_number = _bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+					 FALSE, abbrev_end);
   abbrev_ptr += bytes_read;
 
   /* Loop until we reach an abbrev number of 0.  */
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 2776d62..99251e2 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -782,9 +782,9 @@ extern void _bfd_abort
 
 /* Manipulate a system FILE but using BFD's "file_ptr", rather than
    the system "off_t" or "off64_t", as the offset.  */
-extern file_ptr real_ftell (FILE *file);
-extern int real_fseek (FILE *file, file_ptr offset, int whence);
-extern FILE *real_fopen (const char *filename, const char *modes);
+extern file_ptr _bfd_real_ftell (FILE *file);
+extern int _bfd_real_fseek (FILE *file, file_ptr offset, int whence);
+extern FILE *_bfd_real_fopen (const char *filename, const char *modes);
 
 /* List of supported target vectors, and the default vector (if
    bfd_default_vector[0] is NULL, there is no default).  */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 3ea747d..f19b0db 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -787,9 +787,9 @@ extern void _bfd_abort
 
 /* Manipulate a system FILE but using BFD's "file_ptr", rather than
    the system "off_t" or "off64_t", as the offset.  */
-extern file_ptr real_ftell (FILE *file);
-extern int real_fseek (FILE *file, file_ptr offset, int whence);
-extern FILE *real_fopen (const char *filename, const char *modes);
+extern file_ptr _bfd_real_ftell (FILE *file);
+extern int _bfd_real_fseek (FILE *file, file_ptr offset, int whence);
+extern FILE *_bfd_real_fopen (const char *filename, const char *modes);
 
 /* List of supported target vectors, and the default vector (if
    bfd_default_vector[0] is NULL, there is no default).  */
diff --git a/bfd/opncls.c b/bfd/opncls.c
index b4d4dcf..2ab7dfe 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -219,7 +219,7 @@ bfd_fopen (const char *filename, const char *target, const char *mode, int fd)
     nbfd->iostream = fdopen (fd, mode);
   else
 #endif
-    nbfd->iostream = real_fopen (filename, mode);
+    nbfd->iostream = _bfd_real_fopen (filename, mode);
   if (nbfd->iostream == NULL)
     {
       bfd_set_error (bfd_error_system_call);
@@ -1288,7 +1288,7 @@ separate_debug_file_exists (const char *name, const unsigned long crc)
 
   BFD_ASSERT (name);
 
-  f = real_fopen (name, FOPEN_RB);
+  f = _bfd_real_fopen (name, FOPEN_RB);
   if (f == NULL)
     return FALSE;
 
@@ -1321,7 +1321,7 @@ separate_alt_debug_file_exists (const char *name,
 
   BFD_ASSERT (name);
 
-  f = real_fopen (name, FOPEN_RB);
+  f = _bfd_real_fopen (name, FOPEN_RB);
   if (f == NULL)
     return FALSE;
 
@@ -1704,7 +1704,7 @@ bfd_fill_in_gnu_debuglink_section (bfd *abfd,
      .gnu_debuglink section, we insist upon the user providing us with a
      correct-for-section-creation-time path, but this need not conform to
      the gdb location algorithm.  */
-  handle = real_fopen (filename, FOPEN_RB);
+  handle = _bfd_real_fopen (filename, FOPEN_RB);
   if (handle == NULL)
     {
       bfd_set_error (bfd_error_system_call);
-- 
2.5.5

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

* [PATCH 3/5] bfd: Rename warn_deprecated
  2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
  2017-02-17  0:18 ` [PATCH 2/5] bfd: Rename real_{ftell, fseek, fopen} Pedro Alves
  2017-02-17  0:18 ` [PATCH 1/5] bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128 Pedro Alves
@ 2017-02-17  0:18 ` Pedro Alves
  2017-02-17  0:24 ` [PATCH 5/5] bfd: Rename Chunk and S3Forced Pedro Alves
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  0:18 UTC (permalink / raw)
  To: binutils

Give this bfd-internal symbol with external linkage a _bfd_ prefix to
avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-16  Pedro Alves  <palves@redhat.com>

	* bfd-in.h (bfd_read, bfd_write): Adjust to rename.
	(warn_deprecated): Rename to ...
	(_bfd_warn_deprecated): ... this.
	* libbfd.c (warn_deprecated): Rename to ...
	(_bfd_warn_deprecated): ... this.
	* bfd-in2.h: Regenerate.
---
 bfd/bfd-in.h  | 10 +++++-----
 bfd/bfd-in2.h | 10 +++++-----
 bfd/libbfd.c  |  8 ++++----
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 98b69d0..98c1bc3 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -486,20 +486,20 @@ extern int bfd_stat (bfd *, struct stat *);
 /* Deprecated old routines.  */
 #if __GNUC__
 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__),	\
+  (_bfd_warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__),	\
    bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__),	\
+  (_bfd_warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__),	\
    bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #else
 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
+  (_bfd_warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
    bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
+  (_bfd_warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
    bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #endif
-extern void warn_deprecated (const char *, const char *, int, const char *);
+extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
 
 /* Cast from const char * to char * so that caller can assign to
    a char * without a warning.  */
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index f90bb8c..f17813a 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -493,20 +493,20 @@ extern int bfd_stat (bfd *, struct stat *);
 /* Deprecated old routines.  */
 #if __GNUC__
 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__),	\
+  (_bfd_warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__),	\
    bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__),	\
+  (_bfd_warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__),	\
    bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #else
 #define bfd_read(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
+  (_bfd_warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
    bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #define bfd_write(BUF, ELTSIZE, NITEMS, ABFD)				\
-  (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
+  (_bfd_warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
    bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
 #endif
-extern void warn_deprecated (const char *, const char *, int, const char *);
+extern void _bfd_warn_deprecated (const char *, const char *, int, const char *);
 
 /* Cast from const char * to char * so that caller can assign to
    a char * without a warning.  */
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 4a3e4c2..46bb232 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -927,10 +927,10 @@ bfd_generic_is_local_label_name (bfd *abfd, const char *name)
    old routines.  */
 
 void
-warn_deprecated (const char *what,
-		 const char *file,
-		 int line,
-		 const char *func)
+_bfd_warn_deprecated (const char *what,
+		      const char *file,
+		      int line,
+		      const char *func)
 {
   /* Poor man's tracking of functions we've already warned about.  */
   static size_t mask = 0;
-- 
2.5.5

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

* [PATCH 5/5] bfd: Rename Chunk and S3Forced
  2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
                   ` (2 preceding siblings ...)
  2017-02-17  0:18 ` [PATCH 3/5] bfd: Rename warn_deprecated Pedro Alves
@ 2017-02-17  0:24 ` Pedro Alves
  2017-02-17  0:24 ` [PATCH 4/5] bfd: Rename bsd_write_armap and coff_write_armap Pedro Alves
  2017-02-17  1:06 ` [PATCH 0/5] Rename a few internal symbols to avoid collisions Alan Modra
  5 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  0:24 UTC (permalink / raw)
  To: binutils

The direct references in objcopy kind of look like a hack to me, so
I'm calling these symbols internal too.  Certainly they aren't named
and documented as a public BFD symbol today anyway.

So ... give these bfd-internal symbols with external linkage a _bfd_
prefix to avoid collisions in the global symbol namespace.

While at it, give them names that more closely match the corresponding
option name that toggles them.

Also while at it, fix a few related comment typos.

gdb/ChangeLog:
2017-02-16  Pedro Alves  <palves@redhat.com>

	* srec.c (Chunk): Rename to ...
	(_bfd_srec_len): ... this.
	(S3Forced): Rename to ...
	(_bfd_srec_forceS3): ... this.
	* objcopy.c: Adjust all references.
---
 bfd/srec.c         | 22 +++++++++++-----------
 binutils/objcopy.c | 12 ++++++------
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/bfd/srec.c b/bfd/srec.c
index 5ebab79..6d9b9a4 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -129,12 +129,12 @@ static const char digs[] = "0123456789ABCDEF";
 /* The number of data bytes we actually fit onto a line on output.
    This variable can be modified by objcopy's --srec-len parameter.
    For a 0x75 byte record you should set --srec-len=0x70.  */
-unsigned int Chunk = DEFAULT_CHUNK;
+unsigned int _bfd_srec_len = DEFAULT_CHUNK;
 
 /* The type of srec output (free or forced to S3).
    This variable can be modified by objcopy's --srec-forceS3
    parameter.  */
-bfd_boolean S3Forced = FALSE;
+bfd_boolean _bfd_srec_forceS3 = FALSE;
 
 /* When writing an S-record file, the S-records can not be output as
    they are seen.  This structure is used to hold them in memory.  */
@@ -904,9 +904,9 @@ srec_set_section_contents (bfd *abfd,
 	return FALSE;
       memcpy ((void *) data, location, (size_t) bytes_to_do);
 
-      /* Ff S3Forced is TRUE then always select S3 records,
-	 regardless of the siez of the addresses.  */
-      if (S3Forced)
+      /* If _bfd_srec_forceS3 is TRUE then always select S3 records,
+	 regardless of the size of the addresses.  */
+      if (_bfd_srec_forceS3)
 	tdata->type = 3;
       else if ((section->lma + (offset + bytes_to_do) / opb - 1) <= 0xffff)
 	;  /* The default, S1, is OK.  */
@@ -1040,18 +1040,18 @@ srec_write_section (bfd *abfd,
      have three, and S3 (tdata->type == 3) records have four.
      The total length can't exceed 255, and a zero data length will
      spin for a long time.  */
-  if (Chunk == 0)
-    Chunk = 1;
-  else if (Chunk > MAXCHUNK - tdata->type - 2)
-    Chunk = MAXCHUNK - tdata->type - 2;
+  if (_bfd_srec_len == 0)
+    _bfd_srec_len = 1;
+  else if (_bfd_srec_len > MAXCHUNK - tdata->type - 2)
+    _bfd_srec_len = MAXCHUNK - tdata->type - 2;
 
   while (octets_written < list->size)
     {
       bfd_vma address;
       unsigned int octets_this_chunk = list->size - octets_written;
 
-      if (octets_this_chunk > Chunk)
-	octets_this_chunk = Chunk;
+      if (octets_this_chunk > _bfd_srec_len)
+	octets_this_chunk = _bfd_srec_len;
 
       address = list->where + octets_written / bfd_octets_per_byte (abfd);
 
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 2636ab4..9291b3a 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -491,14 +491,14 @@ extern char *program_name;
    -1 means if we should use argv[0] to decide.  */
 extern int is_strip;
 
-/* The maximum length of an S record.  This variable is declared in srec.c
+/* The maximum length of an S record.  This variable is defined in srec.c
    and can be modified by the --srec-len parameter.  */
-extern unsigned int Chunk;
+extern unsigned int _bfd_srec_len;
 
 /* Restrict the generation of Srecords to type S3 only.
-   This variable is declare in bfd/srec.c and can be toggled
+   This variable is defined in bfd/srec.c and can be toggled
    on by the --srec-forceS3 command line switch.  */
-extern bfd_boolean S3Forced;
+extern bfd_boolean _bfd_srec_forceS3;
 
 /* Forward declarations.  */
 static void setup_section (bfd *, asection *, void *);
@@ -4509,11 +4509,11 @@ copy_main (int argc, char *argv[])
 	  break;
 
 	case OPTION_SREC_LEN:
-	  Chunk = parse_vma (optarg, "--srec-len");
+	  _bfd_srec_len = parse_vma (optarg, "--srec-len");
 	  break;
 
 	case OPTION_SREC_FORCES3:
-	  S3Forced = TRUE;
+	  _bfd_srec_forceS3 = TRUE;
 	  break;
 
 	case OPTION_STRIP_SYMBOLS:
-- 
2.5.5

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

* [PATCH 4/5] bfd: Rename bsd_write_armap and coff_write_armap
  2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
                   ` (3 preceding siblings ...)
  2017-02-17  0:24 ` [PATCH 5/5] bfd: Rename Chunk and S3Forced Pedro Alves
@ 2017-02-17  0:24 ` Pedro Alves
  2017-02-17  1:06 ` [PATCH 0/5] Rename a few internal symbols to avoid collisions Alan Modra
  5 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  0:24 UTC (permalink / raw)
  To: binutils

Give these bfd-internal symbols with external linkage a _bfd_ prefix
to avoid collisions in the global symbol namespace.

bfd/ChangeLog:
2017-02-16  Pedro Alves  <palves@redhat.com>

	* archive.c (bsd_write_armap): Rename to ...
	(_bfd_bsd_write_armap): ... this.
	(coff_write_armap): Rename to ...
	(_bfd_coff_write_armap): ... this.
	* libbfd-in.h (bsd_write_armap): Rename to ...
	(_bfd_bsd_write_armap): ... this.
	(coff_write_armap): Rename to ...
	(_bfd_coff_write_armap): ... this.
	* aout-target.h, aout-tic30.c: Adjust all users.
	* libbfd.h: Regenerate.
---
 bfd/aout-target.h |  2 +-
 bfd/aout-tic30.c  |  2 +-
 bfd/archive.c     | 20 ++++++++++----------
 bfd/libbfd-in.h   | 10 +++++-----
 bfd/libbfd.h      | 10 +++++-----
 5 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index de954ca..9f77c95 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -373,7 +373,7 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
   _bfd_archive_bsd_construct_extended_name_table
 #endif
 #ifndef	MY_write_armap
-#define	MY_write_armap		bsd_write_armap
+#define	MY_write_armap		_bfd_bsd_write_armap
 #endif
 #ifndef MY_read_ar_hdr
 #define MY_read_ar_hdr		_bfd_generic_read_ar_hdr
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 66de656..29dad9f 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -828,7 +828,7 @@ tic30_aout_set_arch_mach (bfd *abfd,
   _bfd_archive_bsd_construct_extended_name_table
 #endif
 #ifndef	MY_write_armap
-#define	MY_write_armap			bsd_write_armap
+#define	MY_write_armap			_bfd_bsd_write_armap
 #endif
 #ifndef MY_read_ar_hdr
 #define MY_read_ar_hdr			_bfd_generic_read_ar_hdr
diff --git a/bfd/archive.c b/bfd/archive.c
index cb7f226..d96c866 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -2455,11 +2455,11 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength)
 }
 
 bfd_boolean
-bsd_write_armap (bfd *arch,
-		 unsigned int elength,
-		 struct orl *map,
-		 unsigned int orl_count,
-		 int stridx)
+_bfd_bsd_write_armap (bfd *arch,
+		      unsigned int elength,
+		      struct orl *map,
+		      unsigned int orl_count,
+		      int stridx)
 {
   int padit = stridx & 1;
   unsigned int ranlibsize = orl_count * BSD_SYMDEF_SIZE;
@@ -2679,11 +2679,11 @@ _bfd_archive_bsd_update_armap_timestamp (bfd *arch)
    symbol name n-1  */
 
 bfd_boolean
-coff_write_armap (bfd *arch,
-		  unsigned int elength,
-		  struct orl *map,
-		  unsigned int symbol_count,
-		  int stridx)
+_bfd_coff_write_armap (bfd *arch,
+		       unsigned int elength,
+		       struct orl *map,
+		       unsigned int symbol_count,
+		       int stridx)
 {
   /* The size of the ranlib is the number of exported symbols in the
      archive * the number of bytes in an int, + an int for the count.  */
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 99251e2..ad362dc 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -207,11 +207,11 @@ void bfd_bsd_truncate_arname
 void bfd_gnu_truncate_arname
   (bfd *abfd, const char *filename, char *hdr);
 
-bfd_boolean bsd_write_armap
+bfd_boolean _bfd_bsd_write_armap
   (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
    int stridx);
 
-bfd_boolean coff_write_armap
+bfd_boolean _bfd_coff_write_armap
   (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
    int stridx);
 
@@ -321,7 +321,7 @@ extern int _bfd_nocore_core_file_pid
 extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
   (bfd *, char **, bfd_size_type *, const char **);
 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
-#define _bfd_archive_bsd_write_armap bsd_write_armap
+#define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap
 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
 #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_bsd_openr_next_archived_file \
@@ -341,7 +341,7 @@ extern bfd_boolean _bfd_archive_bsd_update_armap_timestamp
 extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
   (bfd *, char **, bfd_size_type *, const char **);
 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
-#define _bfd_archive_coff_write_armap coff_write_armap
+#define _bfd_archive_coff_write_armap _bfd_coff_write_armap
 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
 #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_coff_openr_next_archived_file \
@@ -360,7 +360,7 @@ extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
 extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table
   (bfd *, char **, bfd_size_type *, const char **);
 #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
-#define _bfd_archive_bsd44_write_armap bsd_write_armap
+#define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap
 #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
 #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
 #define _bfd_archive_bsd44_openr_next_archived_file \
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index f19b0db..9869e15 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -212,11 +212,11 @@ void bfd_bsd_truncate_arname
 void bfd_gnu_truncate_arname
   (bfd *abfd, const char *filename, char *hdr);
 
-bfd_boolean bsd_write_armap
+bfd_boolean _bfd_bsd_write_armap
   (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
    int stridx);
 
-bfd_boolean coff_write_armap
+bfd_boolean _bfd_coff_write_armap
   (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count,
    int stridx);
 
@@ -326,7 +326,7 @@ extern int _bfd_nocore_core_file_pid
 extern bfd_boolean _bfd_archive_bsd_construct_extended_name_table
   (bfd *, char **, bfd_size_type *, const char **);
 #define _bfd_archive_bsd_truncate_arname bfd_bsd_truncate_arname
-#define _bfd_archive_bsd_write_armap bsd_write_armap
+#define _bfd_archive_bsd_write_armap _bfd_bsd_write_armap
 #define _bfd_archive_bsd_read_ar_hdr _bfd_generic_read_ar_hdr
 #define _bfd_archive_bsd_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_bsd_openr_next_archived_file \
@@ -346,7 +346,7 @@ extern bfd_boolean _bfd_archive_bsd_update_armap_timestamp
 extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
   (bfd *, char **, bfd_size_type *, const char **);
 #define _bfd_archive_coff_truncate_arname bfd_dont_truncate_arname
-#define _bfd_archive_coff_write_armap coff_write_armap
+#define _bfd_archive_coff_write_armap _bfd_coff_write_armap
 #define _bfd_archive_coff_read_ar_hdr _bfd_generic_read_ar_hdr
 #define _bfd_archive_coff_write_ar_hdr _bfd_generic_write_ar_hdr
 #define _bfd_archive_coff_openr_next_archived_file \
@@ -365,7 +365,7 @@ extern bfd_boolean _bfd_archive_coff_construct_extended_name_table
 extern bfd_boolean _bfd_archive_bsd44_construct_extended_name_table
   (bfd *, char **, bfd_size_type *, const char **);
 #define _bfd_archive_bsd44_truncate_arname bfd_bsd_truncate_arname
-#define _bfd_archive_bsd44_write_armap bsd_write_armap
+#define _bfd_archive_bsd44_write_armap _bfd_bsd_write_armap
 #define _bfd_archive_bsd44_read_ar_hdr _bfd_generic_read_ar_hdr
 #define _bfd_archive_bsd44_write_ar_hdr _bfd_bsd44_write_ar_hdr
 #define _bfd_archive_bsd44_openr_next_archived_file \
-- 
2.5.5

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

* Re: [PATCH 0/5] Rename a few internal symbols to avoid collisions
  2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
                   ` (4 preceding siblings ...)
  2017-02-17  0:24 ` [PATCH 4/5] bfd: Rename bsd_write_armap and coff_write_armap Pedro Alves
@ 2017-02-17  1:06 ` Alan Modra
  2017-02-17  2:16   ` Pedro Alves
  5 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2017-02-17  1:06 UTC (permalink / raw)
  To: Pedro Alves; +Cc: binutils

On Fri, Feb 17, 2017 at 12:17:55AM +0000, Pedro Alves wrote:
>   bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
>   bfd: Rename real_{ftell, fseek, fopen}
>   bfd: Rename warn_deprecated
>   bfd: Rename bsd_write_armap and coff_write_armap
>   bfd: Rename Chunk and S3Forced

OK, thanks.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [PATCH 0/5] Rename a few internal symbols to avoid collisions
  2017-02-17  1:06 ` [PATCH 0/5] Rename a few internal symbols to avoid collisions Alan Modra
@ 2017-02-17  2:16   ` Pedro Alves
  2017-02-17  2:30     ` Pedro Alves
  0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  2:16 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On 02/17/2017 01:06 AM, Alan Modra wrote:
> On Fri, Feb 17, 2017 at 12:17:55AM +0000, Pedro Alves wrote:
>>   bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
>>   bfd: Rename real_{ftell, fseek, fopen}
>>   bfd: Rename warn_deprecated
>>   bfd: Rename bsd_write_armap and coff_write_armap
>>   bfd: Rename Chunk and S3Forced
> 
> OK, thanks.
> 

Thanks, I pushed it, and the buildbot complained that I broke
the build...  There are a few instances of safe_read_leb128
in bfd/dwarf2.c that I didn't adjust.  I was puzzled,
since my tree builds cleanly.  But removing the .o files and
rebuilding the file triggers it.  Looks like I hit some
stale dependency.  :-/  Fixing...

Thanks,
Pedro Alves

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

* Re: [PATCH 0/5] Rename a few internal symbols to avoid collisions
  2017-02-17  2:16   ` Pedro Alves
@ 2017-02-17  2:30     ` Pedro Alves
  2017-02-17  2:53       ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2017-02-17  2:30 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On 02/17/2017 02:16 AM, Pedro Alves wrote:
> On 02/17/2017 01:06 AM, Alan Modra wrote:
>> On Fri, Feb 17, 2017 at 12:17:55AM +0000, Pedro Alves wrote:
>>>   bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128
>>>   bfd: Rename real_{ftell, fseek, fopen}
>>>   bfd: Rename warn_deprecated
>>>   bfd: Rename bsd_write_armap and coff_write_armap
>>>   bfd: Rename Chunk and S3Forced
>>
>> OK, thanks.
>>
> 
> Thanks, I pushed it, and the buildbot complained that I broke
> the build...  There are a few instances of safe_read_leb128
> in bfd/dwarf2.c that I didn't adjust.  I was puzzled,
> since my tree builds cleanly.  But removing the .o files and
> rebuilding the file triggers it.  Looks like I hit some
> stale dependency.  :-/  Fixing...

Ah, no, false alarm, actually.  master is fine.  It's simply that
there's one hunk that was accidentally left in patch #2 that should
have been in patch #1:

--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -906,7 +906,8 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash)
 
   abbrev_ptr = stash->dwarf_abbrev_buffer + offset;
   abbrev_end = stash->dwarf_abbrev_buffer + stash->dwarf_abbrev_size;
-  abbrev_number = safe_read_leb128 (abfd, abbrev_ptr, &bytes_read, FALSE, abbrev_end);
+  abbrev_number = _bfd_safe_read_leb128 (abfd, abbrev_ptr, &bytes_read,
+                                        FALSE, abbrev_end);
   abbrev_ptr += bytes_read;
 

So all the built slaves will fail to build patch #1.  They should go back
to normal automatically once they move past that commit.

Thanks,
Pedro Alves

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

* Re: [PATCH 0/5] Rename a few internal symbols to avoid collisions
  2017-02-17  2:30     ` Pedro Alves
@ 2017-02-17  2:53       ` Alan Modra
  0 siblings, 0 replies; 10+ messages in thread
From: Alan Modra @ 2017-02-17  2:53 UTC (permalink / raw)
  To: Pedro Alves; +Cc: binutils

On Fri, Feb 17, 2017 at 02:30:22AM +0000, Pedro Alves wrote:
> Ah, no, false alarm, actually.  master is fine.  It's simply that
> there's one hunk that was accidentally left in patch #2 that should
> have been in patch #1:

Yeah, it pays to compile each change incrementally, especially if
you've broken up a patch just for review.

-- 
Alan Modra
Australia Development Lab, IBM

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

end of thread, other threads:[~2017-02-17  2:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-17  0:18 [PATCH 0/5] Rename a few internal symbols to avoid collisions Pedro Alves
2017-02-17  0:18 ` [PATCH 2/5] bfd: Rename real_{ftell, fseek, fopen} Pedro Alves
2017-02-17  0:18 ` [PATCH 1/5] bfd: Rename read_{signed,unsigned}_leb128, safe_read_leb128 Pedro Alves
2017-02-17  0:18 ` [PATCH 3/5] bfd: Rename warn_deprecated Pedro Alves
2017-02-17  0:24 ` [PATCH 5/5] bfd: Rename Chunk and S3Forced Pedro Alves
2017-02-17  0:24 ` [PATCH 4/5] bfd: Rename bsd_write_armap and coff_write_armap Pedro Alves
2017-02-17  1:06 ` [PATCH 0/5] Rename a few internal symbols to avoid collisions Alan Modra
2017-02-17  2:16   ` Pedro Alves
2017-02-17  2:30     ` Pedro Alves
2017-02-17  2:53       ` 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).