diff mbox

bfd_asymbol_* macros

Message ID 20190918135342.GI3685@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Sept. 18, 2019, 1:53 p.m. UTC
The main point of this patch is to give bfd_get_section a better name,
bfd_asymbol_section.

bfd/
	* bfd-in.h (bfd_asymbol_section): Rename from bfd_get_section.
	(bfd_get_output_section): Delete.
	(bfd_asymbol_base): Delete.
	(bfd_asymbol_section, bfd_asymbol_value, bfd_asymbol_name),
	(bfd_asymbol_bfd, bfd_asymbol_flavour): Tidy.
	(bfd_set_asymbol_name): New macro.
	* bfd-in2.h: Regenerate.
	* aout-cris.c: Update throughout to use bfd_asymbol_section.
	* aoutx.h: Likewise.
	* cofflink.c: Likewise.
	* dwarf2.c: Likewise.
	* ecoff.c: Likewise.
	* elf.c: Likewise.
	* elf32-arm.c: Likewise.
	* elf32-mips.c: Likewise.
	* elf32-score.c: Likewise.
	* elf32-score7.c: Likewise.
	* elfn32-mips.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* linker.c: Likewise.
	* pdp11.c: Likewise.
	* elf64-mmix.c (mmix_elf_reloc): Expand bfd_get_output_section.
binutils/
	* nm.c: Update bfd_get_section to bfd_asymbol_section throughout.
	* objcopy.c: Likewise.
	* objdump.c: Likewise.
	* rdcoff.c: Likewise.
	* objcopy.c (create_new_symbol): Use bfd_set_asymbol_name.
	(filter_symbols): Likewise.
gas/
	* symbols.c (S_IS_LOCAL): Update bfd_get_section to
	bfd_asymbol_section.
gdb/
	* arm-tdep.c (arm_record_special_symbol): Update bfd_get_section
	to bfd_asymbol_section.
ld/
	* ldcref.c (check_reloc_refs): Update bfd_get_section to
	bfd_asymbol_section.
diff mbox

Patch

diff --git a/bfd/aout-cris.c b/bfd/aout-cris.c
index feed5ed585..31b003520d 100644
--- a/bfd/aout-cris.c
+++ b/bfd/aout-cris.c
@@ -169,14 +169,14 @@  MY (swap_ext_reloc_out) (bfd *abfd,
      from the abs section, or as a symbol which has an abs value.
      check for that here.  */
 
-  if (bfd_is_abs_section (bfd_get_section (sym)))
+  if (bfd_is_abs_section (bfd_asymbol_section (sym)))
     {
       r_extern = 0;
       r_index = N_ABS;
     }
   else if ((sym->flags & BSF_SECTION_SYM) == 0)
     {
-      if (bfd_is_und_section (bfd_get_section (sym))
+      if (bfd_is_und_section (bfd_asymbol_section (sym))
 	  /* Remember to check for weak symbols; they count as global.  */
 	  || (sym->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
 	r_extern = 1;
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index cd50b44e60..859153be10 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -1570,7 +1570,7 @@  translate_to_native_sym_flags (bfd *abfd,
      to another.  */
   sym_pointer->e_type[0] &= ~N_TYPE;
 
-  sec = bfd_get_section (cache_ptr);
+  sec = bfd_asymbol_section (cache_ptr);
   off = 0;
 
   if (sec == NULL)
@@ -2064,14 +2064,14 @@  NAME (aout, swap_ext_reloc_out) (bfd *abfd,
      Absolute symbols can come in in two ways, either as an offset
      from the abs section, or as a symbol which has an abs value.
      check for that here.  */
-  if (bfd_is_abs_section (bfd_get_section (sym)))
+  if (bfd_is_abs_section (bfd_asymbol_section (sym)))
     {
       r_extern = 0;
       r_index = N_ABS;
     }
   else if ((sym->flags & BSF_SECTION_SYM) == 0)
     {
-      if (bfd_is_und_section (bfd_get_section (sym))
+      if (bfd_is_und_section (bfd_asymbol_section (sym))
 	  || (sym->flags & BSF_GLOBAL) != 0)
 	r_extern = 1;
       else
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 6c72acb705..5a30344350 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -240,18 +240,15 @@  typedef unsigned long symindex;
 /* General purpose part of a symbol X;
    target specific parts are in libcoff.h, libaout.h, etc.  */
 
-#define bfd_get_section(x) ((x)->section)
-#define bfd_get_output_section(x) ((x)->section->output_section)
-#define bfd_set_section(x,y) ((x)->section) = (y)
-#define bfd_asymbol_base(x) ((x)->section->vma)
-#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value)
-#define bfd_asymbol_name(x) ((x)->name)
-/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/
-#define bfd_asymbol_bfd(x) ((x)->the_bfd)
-#define bfd_asymbol_flavour(x)			\
-  (((x)->flags & BSF_SYNTHETIC) != 0		\
+#define bfd_asymbol_section(sy) ((sy)->section)
+#define bfd_asymbol_value(sy) ((sy)->section->vma + (sy)->value)
+#define bfd_asymbol_name(sy) ((sy)->name)
+#define bfd_asymbol_bfd(sy) ((sy)->the_bfd)
+#define bfd_asymbol_flavour(sy)			\
+  (((sy)->flags & BSF_SYNTHETIC) != 0		\
    ? bfd_target_unknown_flavour			\
-   : bfd_asymbol_bfd (x)->xvec->flavour)
+   : (sy)->the_bfd->xvec->flavour)
+#define bfd_set_asymbol_name(sy, n) do { (sy)->name = (n); } while (0)
 
 /* A canonical archive symbol.  */
 /* This is a type pun with struct ranlib on purpose!  */
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 34d68c93b5..7bcc1ca77d 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -902,7 +902,7 @@  _bfd_coff_final_link (bfd *abfd,
 					bfd_asymbol_name(sym), FALSE, FALSE)
 		       == NULL))
 		  || (((flaginfo.info->discard == discard_sec_merge
-			&& (bfd_get_section (sym)->flags & SEC_MERGE)
+			&& (bfd_asymbol_section (sym)->flags & SEC_MERGE)
 			&& ! bfd_link_relocatable (flaginfo.info))
 		       || flaginfo.info->discard == discard_l)
 		      && bfd_is_local_label_name (sub, bfd_asymbol_name(sym))))
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index ed6dcd48c7..575b082e1d 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -2736,7 +2736,7 @@  lookup_symbol_in_function_table (struct comp_unit *unit,
   bfd_vma best_fit_len = 0;
   struct arange *arange;
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_get_section (sym);
+  asection *sec = bfd_asymbol_section (sym);
 
   for (each_func = unit->function_table;
        each_func;
@@ -2784,7 +2784,7 @@  lookup_symbol_in_variable_table (struct comp_unit *unit,
 				 unsigned int *linenumber_ptr)
 {
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_get_section (sym);
+  asection *sec = bfd_asymbol_section (sym);
   struct varinfo* each;
 
   for (each = unit->variable_table; each; each = each->prev_var)
@@ -4048,7 +4048,7 @@  info_hash_lookup_funcinfo (struct info_hash_table *hash_table,
   struct info_list_node *node;
   struct arange *arange;
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_get_section (sym);
+  asection *sec = bfd_asymbol_section (sym);
 
   for (node = lookup_info_hash_table (hash_table, name);
        node;
@@ -4096,7 +4096,7 @@  info_hash_lookup_varinfo (struct info_hash_table *hash_table,
 			  unsigned int *linenumber_ptr)
 {
   const char *name = bfd_asymbol_name (sym);
-  asection *sec = bfd_get_section (sym);
+  asection *sec = bfd_asymbol_section (sym);
   struct varinfo* each;
   struct info_list_node *node;
 
@@ -4695,7 +4695,7 @@  _bfd_dwarf2_find_nearest_line (bfd *abfd,
   if (do_line)
     {
       BFD_ASSERT (section == NULL && offset == 0 && functionname_ptr == NULL);
-      section = bfd_get_section (symbol);
+      section = bfd_asymbol_section (symbol);
       addr = symbol->value;
     }
   else
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 1e6f4d219c..c06fa5ec7f 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -2312,7 +2312,7 @@  ecoff_get_extr (asymbol *sym, EXTR *esym)
      symbol.  */
   if ((esym->asym.sc == scUndefined
        || esym->asym.sc == scSUndefined)
-      && ! bfd_is_und_section (bfd_get_section (sym)))
+      && ! bfd_is_und_section (bfd_asymbol_section (sym)))
     esym->asym.sc = scAbs;
 
   /* Adjust the FDR index for the symbol by that used for the input
@@ -2719,7 +2719,7 @@  _bfd_ecoff_write_object_contents (bfd *abfd)
 		    { _RCONST, RELOC_SECTION_RCONST }
 		  };
 
-		  name = bfd_get_section_name (abfd, bfd_get_section (sym));
+		  name = bfd_get_section_name (abfd, bfd_asymbol_section (sym));
 
 		  for (j = 0; j < ARRAY_SIZE (section_symndx); j++)
 		    if (streq (name, section_symndx[j].name))
diff --git a/bfd/elf.c b/bfd/elf.c
index ecd348e1a5..1a1eed9085 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4057,8 +4057,8 @@  sym_is_global (bfd *abfd, asymbol *sym)
     return (*bed->elf_backend_sym_is_global) (abfd, sym);
 
   return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
-	  || bfd_is_und_section (bfd_get_section (sym))
-	  || bfd_is_com_section (bfd_get_section (sym)));
+	  || bfd_is_und_section (bfd_asymbol_section (sym))
+	  || bfd_is_com_section (bfd_asymbol_section (sym)));
 }
 
 /* Filter global symbols of ABFD to include in the import library.  All
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b675fc60c1..e29a60abf1 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -16076,7 +16076,7 @@  arm_elf_find_function (bfd *	     abfd,
 		    BFD_ARM_SPECIAL_SYM_TYPE_ANY))
 	    continue;
 	  /* Fall through.  */
-	  if (bfd_get_section (&q->symbol) == section
+	  if (bfd_asymbol_section (&q->symbol) == section
 	      && q->symbol.value >= low_func
 	      && q->symbol.value <= offset)
 	    {
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 9f8f2bdc26..74300a11e9 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -2281,8 +2281,8 @@  mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
     return (sym->flags & BSF_SECTION_SYM) == 0;
   else
     return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
-	    || bfd_is_und_section (bfd_get_section (sym))
-	    || bfd_is_com_section (bfd_get_section (sym)));
+	    || bfd_is_und_section (bfd_asymbol_section (sym))
+	    || bfd_is_com_section (bfd_asymbol_section (sym)));
 }
 
 /* Set the right machine number for a MIPS ELF file.  */
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 6390309f52..1bbf64fe6d 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -596,8 +596,8 @@  score_elf_got15_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 		       bfd *output_bfd, char **error_message)
 {
   if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
-      || bfd_is_und_section (bfd_get_section (symbol))
-      || bfd_is_com_section (bfd_get_section (symbol)))
+      || bfd_is_und_section (bfd_asymbol_section (symbol))
+      || bfd_is_com_section (bfd_asymbol_section (symbol)))
     /* The relocation is against a global symbol.  */
     return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
 				  input_section, output_bfd,
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index ea0ccd04e9..51a5fb106d 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -497,8 +497,8 @@  score_elf_got15_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 		       bfd *output_bfd, char **error_message)
 {
   if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
-      || bfd_is_und_section (bfd_get_section (symbol))
-      || bfd_is_com_section (bfd_get_section (symbol)))
+      || bfd_is_und_section (bfd_asymbol_section (symbol))
+      || bfd_is_com_section (bfd_asymbol_section (symbol)))
     /* The relocation is against a global symbol.  */
     return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
 				  input_section, output_bfd,
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index 839bd45b4a..18ed456c2b 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -1315,7 +1315,7 @@  mmix_elf_reloc (bfd *abfd,
   else
     relocation = symbol->value;
 
-  reloc_target_output_section = bfd_get_output_section (symbol);
+  reloc_target_output_section = bfd_asymbol_section (symbol)->output_section;
 
   /* Here the variable relocation holds the final address of the symbol we
      are relocating against, plus any addend.  */
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 58d66ce63c..8927e9825b 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -3841,8 +3841,8 @@  mips_elf_sym_is_global (bfd *abfd ATTRIBUTE_UNUSED, asymbol *sym)
     return (sym->flags & BSF_SECTION_SYM) == 0;
   else
     return ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0
-	    || bfd_is_und_section (bfd_get_section (sym))
-	    || bfd_is_com_section (bfd_get_section (sym)));
+	    || bfd_is_und_section (bfd_asymbol_section (sym))
+	    || bfd_is_com_section (bfd_asymbol_section (sym)));
 }
 
 /* Set the right machine number for a MIPS ELF file.  */
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index fd44505da4..7132b6bc73 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -8042,7 +8042,7 @@  aarch64_elf_find_function (bfd *          abfd,
 		  (q->symbol.name, BFD_AARCH64_SPECIAL_SYM_TYPE_ANY)))
 	    continue;
 	  /* Fall through.  */
-	  if (bfd_get_section (&q->symbol) == section
+	  if (bfd_asymbol_section (&q->symbol) == section
 	      && q->symbol.value >= low_func && q->symbol.value <= offset)
 	    {
 	      func = (asymbol *) q;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index e3054043df..8ad5268520 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -2531,8 +2531,8 @@  _bfd_mips_elf_got16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
 			   bfd *output_bfd, char **error_message)
 {
   if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
-      || bfd_is_und_section (bfd_get_section (symbol))
-      || bfd_is_com_section (bfd_get_section (symbol)))
+      || bfd_is_und_section (bfd_asymbol_section (symbol))
+      || bfd_is_com_section (bfd_asymbol_section (symbol)))
     /* The relocation is against a global symbol.  */
     return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data,
 					input_section, output_bfd,
diff --git a/bfd/linker.c b/bfd/linker.c
index 8aec0d2358..2518371f24 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1163,9 +1163,9 @@  generic_link_add_symbol_list (bfd *abfd,
 		       | BSF_GLOBAL
 		       | BSF_CONSTRUCTOR
 		       | BSF_WEAK)) != 0
-	  || bfd_is_und_section (bfd_get_section (p))
-	  || bfd_is_com_section (bfd_get_section (p))
-	  || bfd_is_ind_section (bfd_get_section (p)))
+	  || bfd_is_und_section (bfd_asymbol_section (p))
+	  || bfd_is_com_section (bfd_asymbol_section (p))
+	  || bfd_is_ind_section (bfd_asymbol_section (p)))
 	{
 	  const char *name;
 	  const char *string;
@@ -1191,7 +1191,7 @@  generic_link_add_symbol_list (bfd *abfd,
 
 	  bh = NULL;
 	  if (! (_bfd_generic_link_add_one_symbol
-		 (info, abfd, name, p->flags, bfd_get_section (p),
+		 (info, abfd, name, p->flags, bfd_asymbol_section (p),
 		  p->value, string, FALSE, FALSE, &bh)))
 	    return FALSE;
 	  h = (struct generic_link_hash_entry *) bh;
@@ -1218,15 +1218,15 @@  generic_link_add_symbol_list (bfd *abfd,
 	  if (info->output_bfd->xvec == abfd->xvec)
 	    {
 	      if (h->sym == NULL
-		  || (! bfd_is_und_section (bfd_get_section (p))
-		      && (! bfd_is_com_section (bfd_get_section (p))
-			  || bfd_is_und_section (bfd_get_section (h->sym)))))
+		  || (! bfd_is_und_section (bfd_asymbol_section (p))
+		      && (! bfd_is_com_section (bfd_asymbol_section (p))
+			  || bfd_is_und_section (bfd_asymbol_section (h->sym)))))
 		{
 		  h->sym = p;
 		  /* BSF_OLD_COMMON is a hack to support COFF reloc
 		     reading, and it should go away when the COFF
 		     linker is switched to the new version.  */
-		  if (bfd_is_com_section (bfd_get_section (p)))
+		  if (bfd_is_com_section (bfd_asymbol_section (p)))
 		    p->flags |= BSF_OLD_COMMON;
 		}
 	    }
@@ -2026,9 +2026,9 @@  _bfd_generic_link_output_symbols (bfd *output_bfd,
 			 | BSF_GLOBAL
 			 | BSF_CONSTRUCTOR
 			 | BSF_WEAK)) != 0
-	  || bfd_is_und_section (bfd_get_section (sym))
-	  || bfd_is_com_section (bfd_get_section (sym))
-	  || bfd_is_ind_section (bfd_get_section (sym)))
+	  || bfd_is_und_section (bfd_asymbol_section (sym))
+	  || bfd_is_com_section (bfd_asymbol_section (sym))
+	  || bfd_is_ind_section (bfd_asymbol_section (sym)))
 	{
 	  if (sym->udata.p != NULL)
 	    h = (struct generic_link_hash_entry *) sym->udata.p;
@@ -2044,7 +2044,7 @@  _bfd_generic_link_output_symbols (bfd *output_bfd,
 		 the relocs in the output format being used.  */
 	      h = NULL;
 	    }
-	  else if (bfd_is_und_section (bfd_get_section (sym)))
+	  else if (bfd_is_und_section (bfd_asymbol_section (sym)))
 	    h = ((struct generic_link_hash_entry *)
 		 bfd_wrapped_link_hash_lookup (output_bfd, info,
 					       bfd_asymbol_name (sym),
@@ -2601,15 +2601,15 @@  default_indirect_link_order (bfd *output_bfd,
 			     | BSF_GLOBAL
 			     | BSF_CONSTRUCTOR
 			     | BSF_WEAK)) != 0
-	      || bfd_is_und_section (bfd_get_section (sym))
-	      || bfd_is_com_section (bfd_get_section (sym))
-	      || bfd_is_ind_section (bfd_get_section (sym)))
+	      || bfd_is_und_section (bfd_asymbol_section (sym))
+	      || bfd_is_com_section (bfd_asymbol_section (sym))
+	      || bfd_is_ind_section (bfd_asymbol_section (sym)))
 	    {
 	      /* sym->udata may have been set by
 		 generic_link_add_symbol_list.  */
 	      if (sym->udata.p != NULL)
 		h = (struct bfd_link_hash_entry *) sym->udata.p;
-	      else if (bfd_is_und_section (bfd_get_section (sym)))
+	      else if (bfd_is_und_section (bfd_asymbol_section (sym)))
 		h = bfd_wrapped_link_hash_lookup (output_bfd, info,
 						  bfd_asymbol_name (sym),
 						  FALSE, FALSE, TRUE);
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index f7f3128409..238f5144d4 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -1352,7 +1352,7 @@  translate_to_native_sym_flags (bfd *abfd,
      to another.  */
   sym_pointer->e_type[0] &= ~N_TYPE;
 
-  sec = bfd_get_section (cache_ptr);
+  sec = bfd_asymbol_section (cache_ptr);
   off = 0;
 
   if (sec == NULL)
diff --git a/binutils/nm.c b/binutils/nm.c
index 67b7ac7b12..0bded07391 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -592,8 +592,8 @@  numeric_forward (const void *P_x, const void *P_y)
   if (x == NULL || y == NULL)
     bfd_fatal (bfd_get_filename (sort_bfd));
 
-  xs = bfd_get_section (x);
-  ys = bfd_get_section (y);
+  xs = bfd_asymbol_section (x);
+  ys = bfd_asymbol_section (y);
 
   if (bfd_is_und_section (xs))
     {
@@ -645,8 +645,8 @@  size_forward1 (const void *P_x, const void *P_y)
   if (x == NULL || y == NULL)
     bfd_fatal (bfd_get_filename (sort_bfd));
 
-  xs = bfd_get_section (x);
-  ys = bfd_get_section (y);
+  xs = bfd_asymbol_section (x);
+  ys = bfd_asymbol_section (y);
 
   if (bfd_is_und_section (xs))
     abort ();
@@ -774,7 +774,7 @@  sort_symbols_by_size (bfd *abfd, bfd_boolean is_dynamic, void *minisyms,
       else
 	next = NULL;
 
-      sec = bfd_get_section (sym);
+      sec = bfd_asymbol_section (sym);
 
       /* Synthetic symbols don't have a full type set of data available, thus
 	 we can't rely on that information for the symbol size.  Ditto for
@@ -788,7 +788,7 @@  sort_symbols_by_size (bfd *abfd, bfd_boolean is_dynamic, void *minisyms,
       else
 	{
 	  if (from + size < fromend
-	      && sec == bfd_get_section (next))
+	      && sec == bfd_asymbol_section (next))
 	    sz = valueof (next) - valueof (sym);
 	  else
 	    sz = (bfd_get_section_vma (abfd, sec)
@@ -895,7 +895,7 @@  print_symbol (bfd *        abfd,
       if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
 	version_string = bfd_get_symbol_version_string (abfd, sym, &hidden);
 
-      if (bfd_is_und_section (bfd_get_section (sym)))
+      if (bfd_is_und_section (bfd_asymbol_section (sym)))
 	hidden = TRUE;
 
       if (version_string && *version_string != '\0')
@@ -931,7 +931,7 @@  print_symbol (bfd *        abfd,
 	  lineno_cache_bfd = abfd;
 	}
 
-      if (bfd_is_und_section (bfd_get_section (sym)))
+      if (bfd_is_und_section (bfd_asymbol_section (sym)))
 	{
 	  static asection **secs;
 	  static arelent ***relocs;
@@ -1001,10 +1001,10 @@  print_symbol (bfd *        abfd,
 		}
 	    }
 	}
-      else if (bfd_get_section (sym)->owner == abfd)
+      else if (bfd_asymbol_section (sym)->owner == abfd)
 	{
 	  if ((bfd_find_line (abfd, syms, sym, &filename, &lineno)
-	       || bfd_find_nearest_line (abfd, bfd_get_section (sym),
+	       || bfd_find_nearest_line (abfd, bfd_asymbol_section (sym),
 					 syms, sym->value, &filename,
 					 &functionname, &lineno))
 	      && filename != NULL
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index ebb99339aa..ce4a4afa55 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1465,7 +1465,7 @@  create_new_symbol (struct addsym_node *ptr, bfd *obfd)
 {
   asymbol *sym = bfd_make_empty_symbol (obfd);
 
-  bfd_asymbol_name (sym) = ptr->symdef;
+  bfd_set_asymbol_name (sym, ptr->symdef);
   sym->value = ptr->symval;
   sym->flags = ptr->flags;
   if (ptr->section)
@@ -1503,7 +1503,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
       bfd_boolean rem_leading_char;
       bfd_boolean add_leading_char;
 
-      undefined = bfd_is_und_section (bfd_get_section (sym));
+      undefined = bfd_is_und_section (bfd_asymbol_section (sym));
 
       if (add_sym_list)
 	{
@@ -1521,7 +1521,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 	  if (new_name == name
 	      && (flags & BSF_SECTION_SYM) != 0)
 	    new_name = (char *) find_section_rename (name, NULL);
-	  bfd_asymbol_name (sym) = new_name;
+	  bfd_set_asymbol_name (sym, new_name);
 	  name = new_name;
 	}
 
@@ -1532,7 +1532,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 	    || (remove_leading_char
 		&& ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0
 		    || undefined
-		    || bfd_is_com_section (bfd_get_section (sym)))));
+		    || bfd_is_com_section (bfd_asymbol_section (sym)))));
 
       /* Check if we will add a new leading character.  */
       add_leading_char =
@@ -1545,14 +1545,14 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
       if (rem_leading_char && add_leading_char && !prefix_symbols_string)
 	{
 	  name[0] = bfd_get_symbol_leading_char (obfd);
-	  bfd_asymbol_name (sym) = name;
+	  bfd_set_asymbol_name (sym, name);
 	  rem_leading_char = FALSE;
 	  add_leading_char = FALSE;
 	}
 
       /* Remove leading char.  */
       if (rem_leading_char)
-	bfd_asymbol_name (sym) = ++name;
+	bfd_set_asymbol_name (sym, ++name);
 
       /* Add new leading char and/or prefix.  */
       if (add_leading_char || prefix_symbols_string)
@@ -1571,7 +1571,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 	    }
 
 	  strcpy (ptr, name);
-	  bfd_asymbol_name (sym) = n;
+	  bfd_set_asymbol_name (sym, n);
 	  name = n;
 	}
 
@@ -1579,7 +1579,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 	keep = FALSE;
       else if ((flags & BSF_KEEP) != 0		/* Used in relocation.  */
 	       || ((flags & BSF_SECTION_SYM) != 0
-		   && ((*bfd_get_section (sym)->symbol_ptr_ptr)->flags
+		   && ((*bfd_asymbol_section (sym)->symbol_ptr_ptr)->flags
 		       & BSF_KEEP) != 0))
 	{
 	  keep = TRUE;
@@ -1587,7 +1587,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 	}
       else if (relocatable			/* Relocatable file.  */
 	       && ((flags & (BSF_GLOBAL | BSF_WEAK)) != 0
-		   || bfd_is_com_section (bfd_get_section (sym))))
+		   || bfd_is_com_section (bfd_asymbol_section (sym))))
 	keep = TRUE;
       else if (bfd_decode_symclass (sym) == 'I')
 	/* Global symbols in $idata sections need to be retained
@@ -1598,13 +1598,13 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
       else if ((flags & BSF_GLOBAL) != 0	/* Global symbol.  */
 	       || (flags & BSF_WEAK) != 0
 	       || undefined
-	       || bfd_is_com_section (bfd_get_section (sym)))
+	       || bfd_is_com_section (bfd_asymbol_section (sym)))
 	keep = strip_symbols != STRIP_UNNEEDED;
       else if ((flags & BSF_DEBUGGING) != 0)	/* Debugging symbol.  */
 	keep = (strip_symbols != STRIP_DEBUG
 		&& strip_symbols != STRIP_UNNEEDED
 		&& ! convert_debugging);
-      else if (bfd_coff_get_comdat_section (abfd, bfd_get_section (sym)))
+      else if (bfd_coff_get_comdat_section (abfd, bfd_asymbol_section (sym)))
 	/* COMDAT sections store special information in local
 	   symbols, so we cannot risk stripping any of them.  */
 	keep = TRUE;
@@ -1637,7 +1637,7 @@  filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
 	      || is_specified_symbol (name, keep_specific_htab)))
 	keep = TRUE;
 
-      if (keep && is_strip_section (abfd, bfd_get_section (sym)))
+      if (keep && is_strip_section (abfd, bfd_asymbol_section (sym)))
 	keep = FALSE;
 
       if (keep)
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 00541cbec5..4a7c8f9a74 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -995,7 +995,7 @@  objdump_print_symname (bfd *abfd, struct disassemble_info *inf,
   if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0)
     version_string = bfd_get_symbol_version_string (abfd, sym, &hidden);
 
-  if (bfd_is_und_section (bfd_get_section (sym)))
+  if (bfd_is_und_section (bfd_asymbol_section (sym)))
     hidden = TRUE;
 
   name = sanitize_string (name);
@@ -1351,7 +1351,7 @@  objdump_print_addr (bfd_vma vma,
       /* Adjust the vma to the reloc.  */
       vma += bfd_asymbol_value (sym);
 
-      if (bfd_is_und_section (bfd_get_section (sym)))
+      if (bfd_is_und_section (bfd_asymbol_section (sym)))
 	skip_find = TRUE;
     }
 
@@ -2234,7 +2234,7 @@  disassemble_bytes (struct disassemble_info * inf,
 		    {
 		      asection *sym_sec;
 
-		      sym_sec = bfd_get_section (*q->sym_ptr_ptr);
+		      sym_sec = bfd_asymbol_section (*q->sym_ptr_ptr);
 		      sym_name = bfd_get_section_name (aux->abfd, sym_sec);
 		      if (sym_name == NULL || *sym_name == '\0')
 			sym_name = "*unknown*";
diff --git a/binutils/rdcoff.c b/binutils/rdcoff.c
index 7e585691eb..cbb5db1b94 100644
--- a/binutils/rdcoff.c
+++ b/binutils/rdcoff.c
@@ -816,7 +816,7 @@  parse_coff (bfd *abfd, asymbol **syms, long symcount, void *dhandle)
 		  else
 		    base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1;
 
-		  addr = bfd_get_section_vma (abfd, bfd_get_section (sym));
+		  addr = bfd_get_section_vma (abfd, bfd_asymbol_section (sym));
 
 		  ++linenos;
 
diff --git a/gas/symbols.c b/gas/symbols.c
index 918028f875..34ec145ad0 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -2310,14 +2310,14 @@  S_IS_LOCAL (symbolS *s)
   if ((flags & BSF_LOCAL) && (flags & BSF_GLOBAL))
     abort ();
 
-  if (bfd_get_section (s->bsym) == reg_section)
+  if (bfd_asymbol_section (s->bsym) == reg_section)
     return 1;
 
   if (flag_strip_local_absolute
       /* Keep BSF_FILE symbols in order to allow debuggers to identify
 	 the source file even when the object file is stripped.  */
       && (flags & (BSF_GLOBAL | BSF_FILE)) == 0
-      && bfd_get_section (s->bsym) == absolute_section)
+      && bfd_asymbol_section (s->bsym) == absolute_section)
     return 1;
 
   name = S_GET_NAME (s);
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 0650485bf0..5c494c8ed2 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -8575,7 +8575,7 @@  arm_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile,
     data = arm_objfile_data_key.emplace (objfile,
 					 objfile->obfd->section_count);
   arm_mapping_symbol_vec &map
-    = data->section_maps[bfd_get_section (sym)->index];
+    = data->section_maps[bfd_asymbol_section (sym)->index];
 
   new_map_sym.value = sym->value;
   new_map_sym.type = name[1];
diff --git a/ld/ldcref.c b/ld/ldcref.c
index 12cb2942e6..fff852a89a 100644
--- a/ld/ldcref.c
+++ b/ld/ldcref.c
@@ -705,14 +705,14 @@  check_reloc_refs (bfd *abfd, asection *sec, void *iarg)
       if (q->sym_ptr_ptr != NULL
 	  && *q->sym_ptr_ptr != NULL
 	  && ((global
-	       && (bfd_is_und_section (bfd_get_section (*q->sym_ptr_ptr))
-		   || bfd_is_com_section (bfd_get_section (*q->sym_ptr_ptr))
+	       && (bfd_is_und_section (bfd_asymbol_section (*q->sym_ptr_ptr))
+		   || bfd_is_com_section (bfd_asymbol_section (*q->sym_ptr_ptr))
 		   || ((*q->sym_ptr_ptr)->flags & (BSF_GLOBAL
 						   | BSF_WEAK)) != 0))
 	      || (!global
 		  && ((*q->sym_ptr_ptr)->flags & (BSF_LOCAL
 						  | BSF_SECTION_SYM)) != 0
-		  && bfd_get_section (*q->sym_ptr_ptr) == info->defsec))
+		  && bfd_asymbol_section (*q->sym_ptr_ptr) == info->defsec))
 	  && (symname != NULL
 	      ? strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0
 	      : ((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0))