Don't use bfd_get_* macro to set bfd fields

* aoutx.h (slurp_symbol_table): Don't set symcount using bfd_get
	macros.
	* pdp11.c (slurp_symbol_table): Likewise.
	* som.c (som_slurp_symbol_table): Likewise.
	* coff-ppc.c (ppc_bfd_coff_final_link): Likewise.
	* coffcode.h (coff_slurp_symbol_table): Likewise.
	* cofflink.c (_bfd_coff_final_link): Likewise.
	* ecoff.c (ecoff_slurp_symbolic_header): Likewise.
	(_bfd_ecoff_slurp_symbolic_info): Likewise.
	(_bfd_ecoff_slurp_symbol_table): Likewise.
	(_bfd_ecoff_bfd_final_link): Likewise.
	* elf.c (_bfd_elf_canonicalize_symtab): Likewise.
	* elflink.c (elf_link_output_symstrtab): Likewise.
	(bfd_elf_final_link): Likewise.
	* peicode.h (pe_ILF_build_a_bfd): Likewise.
	* xcofflink.c (_bfd_xcoff_bfd_final_link): Likewise.
	* aoutx.h (some_aout_object_p, slurp_symbol_table): Don't set
	start_address or symcount using bfd_get macros.
	* coffgen.c (coff_real_object_p): Likewise.
	* pdp11.c (some_aout_object_p, slurp_symbol_table): Likewise.
	* som.c (som_object_setup, som_slurp_symbol_table): Likewise.
	* elfcore.h (elf_core_file_p): Don't set start_address using
	bfd_get macro.
	* elf.c (_bfd_elf_canonicalize_dynamic_symtab): Don't set dynsymcount
	using bfd_get macro.
	* bfd.c (bfd_set_file_flags): Don't set flags using bfd_get macro.
	* linker.c (bfd_generic_link_read_symbols): Don't set outsymbols
	or symcount using bfd_get macros.
	(_bfd_generic_final_link, generic_add_output_symbol): Likewise.
	* syms.c (bfd_set_symtab): Likewise.
	* vms-alpha.c (alpha_vms_bfd_final_link): Likewise.
	* archive.c (do_slurp_bsd_armap): Don't set has_armap using
	bfd_has_map macro.
	(do_slurp_coff_armap, bfd_slurp_armap): Likewise.
	* archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise.
	* coff-rs6000.c (_bfd_xcoff_slurp_armap): Likewise.
	* coff64-rs6000.c (xcoff64_slurp_armap): Likewise.
	* ecoff.c (_bfd_ecoff_slurp_armap): Likewise.
	* som.c (som_slurp_armap): Likewise.
This commit is contained in:
Alan Modra 2019-09-18 15:07:33 +09:30
parent 01c2b26160
commit ed48ec2e6e
22 changed files with 103 additions and 63 deletions

View File

@ -1,3 +1,45 @@
2019-09-18 Alan Modra <amodra@gmail.com>
* aoutx.h (slurp_symbol_table): Don't set symcount using bfd_get
macros.
* pdp11.c (slurp_symbol_table): Likewise.
* som.c (som_slurp_symbol_table): Likewise.
* coff-ppc.c (ppc_bfd_coff_final_link): Likewise.
* coffcode.h (coff_slurp_symbol_table): Likewise.
* cofflink.c (_bfd_coff_final_link): Likewise.
* ecoff.c (ecoff_slurp_symbolic_header): Likewise.
(_bfd_ecoff_slurp_symbolic_info): Likewise.
(_bfd_ecoff_slurp_symbol_table): Likewise.
(_bfd_ecoff_bfd_final_link): Likewise.
* elf.c (_bfd_elf_canonicalize_symtab): Likewise.
* elflink.c (elf_link_output_symstrtab): Likewise.
(bfd_elf_final_link): Likewise.
* peicode.h (pe_ILF_build_a_bfd): Likewise.
* xcofflink.c (_bfd_xcoff_bfd_final_link): Likewise.
* aoutx.h (some_aout_object_p, slurp_symbol_table): Don't set
start_address or symcount using bfd_get macros.
* coffgen.c (coff_real_object_p): Likewise.
* pdp11.c (some_aout_object_p, slurp_symbol_table): Likewise.
* som.c (som_object_setup, som_slurp_symbol_table): Likewise.
* elfcore.h (elf_core_file_p): Don't set start_address using
bfd_get macro.
* elf.c (_bfd_elf_canonicalize_dynamic_symtab): Don't set dynsymcount
using bfd_get macro.
* bfd.c (bfd_set_file_flags): Don't set flags using bfd_get macro.
* linker.c (bfd_generic_link_read_symbols): Don't set outsymbols
or symcount using bfd_get macros.
(_bfd_generic_final_link, generic_add_output_symbol): Likewise.
* syms.c (bfd_set_symtab): Likewise.
* vms-alpha.c (alpha_vms_bfd_final_link): Likewise.
* archive.c (do_slurp_bsd_armap): Don't set has_armap using
bfd_has_map macro.
(do_slurp_coff_armap, bfd_slurp_armap): Likewise.
* archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise.
* coff-rs6000.c (_bfd_xcoff_slurp_armap): Likewise.
* coff64-rs6000.c (xcoff64_slurp_armap): Likewise.
* ecoff.c (_bfd_ecoff_slurp_armap): Likewise.
* som.c (som_slurp_armap): Likewise.
2019-09-18 Alan Modra <amodra@gmail.com>
* archures.c (bfd_get_arch): Make param const.

View File

@ -511,10 +511,10 @@ NAME (aout, some_aout_object_p) (bfd *abfd,
was called. */
abort ();
bfd_get_start_address (abfd) = execp->a_entry;
abfd->start_address = execp->a_entry;
obj_aout_symbols (abfd) = NULL;
bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
abfd->symcount = execp->a_syms / sizeof (struct external_nlist);
/* The default relocation entry size is that of traditional V7 Unix. */
obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
@ -1782,7 +1782,7 @@ NAME (aout, slurp_symbol_table) (bfd *abfd)
return FALSE;
}
bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
abfd->symcount = obj_aout_external_sym_count (abfd);
obj_aout_symbols (abfd) = cached;

View File

@ -1013,7 +1013,7 @@ do_slurp_bsd_armap (bfd *abfd)
/* FIXME, we should provide some way to free raw_ardata when
we are done using the strings from it. For now, it seems
to be allocated on an objalloc anyway... */
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
return TRUE;
}
@ -1105,7 +1105,7 @@ do_slurp_coff_armap (bfd *abfd)
/* Pad to an even boundary if you have to. */
ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
bfd_release (abfd, raw_armap);
/* Check for a second archive header (as used by PE). */
@ -1188,7 +1188,7 @@ bfd_slurp_armap (bfd *abfd)
return do_slurp_bsd_armap (abfd);
}
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}

View File

@ -66,7 +66,7 @@ _bfd_archive_64_bit_slurp_armap (bfd *abfd)
if (! CONST_STRNEQ (nextname, "/SYM64/ "))
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -137,7 +137,7 @@ _bfd_archive_64_bit_slurp_armap (bfd *abfd)
/* Pad to an even boundary if you have to. */
ardata->first_file_filepos += (ardata->first_file_filepos) % 2;
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
bfd_release (abfd, raw_armap);
return TRUE;

View File

@ -1418,7 +1418,7 @@ bfd_set_file_flags (bfd *abfd, flagword flags)
return FALSE;
}
bfd_get_file_flags (abfd) = flags;
abfd->flags = flags;
if ((flags & bfd_applicable_file_flags (abfd)) != flags)
{
bfd_set_error (bfd_error_invalid_operation);

View File

@ -2420,9 +2420,9 @@ ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
_bfd_stringtab_free (flaginfo.strtab);
/* Setting bfd_get_symcount to 0 will cause write_object_contents to
/* Setting symcount to 0 will cause write_object_contents to
not try to write out the symbols. */
bfd_get_symcount (abfd) = 0;
abfd->symcount = 0;
return TRUE;

View File

@ -1243,7 +1243,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
if (xcoff_ardata (abfd) == NULL)
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -1255,7 +1255,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
GET_VALUE_IN_FIELD (off, xcoff_ardata (abfd)->symoff, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -1310,7 +1310,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
GET_VALUE_IN_FIELD (off, xcoff_ardata_big (abfd)->symoff, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -1373,7 +1373,7 @@ _bfd_xcoff_slurp_armap (bfd *abfd)
}
bfd_ardata (abfd)->symdef_count = c;
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
return TRUE;
}

View File

@ -1906,7 +1906,7 @@ xcoff64_slurp_armap (bfd *abfd)
if (xcoff_ardata (abfd) == NULL)
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -1914,7 +1914,7 @@ xcoff64_slurp_armap (bfd *abfd)
(const char **) NULL, 10);
if (off == 0)
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -1976,7 +1976,7 @@ xcoff64_slurp_armap (bfd *abfd)
}
bfd_ardata (abfd)->symdef_count = c;
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
return TRUE;
}

View File

@ -4809,7 +4809,7 @@ coff_slurp_symbol_table (bfd * abfd)
obj_symbols (abfd) = cached_area;
obj_raw_syments (abfd) = native_symbols;
bfd_get_symcount (abfd) = number_of_symbols;
abfd->symcount = number_of_symbols;
obj_convert (abfd) = table_ptr;
/* Slurp the line tables for each section too. */
{

View File

@ -257,14 +257,14 @@ coff_real_object_p (bfd *abfd,
if ((internal_f->f_flags & F_EXEC) != 0)
abfd->flags |= D_PAGED;
bfd_get_symcount (abfd) = internal_f->f_nsyms;
abfd->symcount = internal_f->f_nsyms;
if (internal_f->f_nsyms)
abfd->flags |= HAS_SYMS;
if (internal_a != (struct internal_aouthdr *) NULL)
bfd_get_start_address (abfd) = internal_a->entry;
abfd->start_address = internal_a->entry;
else
bfd_get_start_address (abfd) = 0;
abfd->start_address = 0;
/* Set up the tdata area. ECOFF uses its own routine, and overrides
abfd->flags. */
@ -309,7 +309,7 @@ coff_real_object_p (bfd *abfd,
fail2:
abfd->tdata.any = tdata_save;
abfd->flags = oflags;
bfd_get_start_address (abfd) = ostart;
abfd->start_address = ostart;
return (const bfd_target *) NULL;
}

View File

@ -1186,9 +1186,9 @@ _bfd_coff_final_link (bfd *abfd,
_bfd_stringtab_free (flaginfo.strtab);
/* Setting bfd_get_symcount to 0 will cause write_object_contents to
/* Setting symcount to 0 will cause write_object_contents to
not try to write out the symbols. */
bfd_get_symcount (abfd) = 0;
abfd->symcount = 0;
return TRUE;

View File

@ -446,7 +446,7 @@ ecoff_slurp_symbolic_header (bfd *abfd)
/* See whether there is a symbolic header. */
if (ecoff_data (abfd)->sym_filepos == 0)
{
bfd_get_symcount (abfd) = 0;
abfd->symcount = 0;
return TRUE;
}
@ -479,8 +479,7 @@ ecoff_slurp_symbolic_header (bfd *abfd)
}
/* Now we can get the correct number of symbols. */
bfd_get_symcount (abfd) = (internal_symhdr->isymMax
+ internal_symhdr->iextMax);
abfd->symcount = internal_symhdr->isymMax + internal_symhdr->iextMax;
if (raw != NULL)
free (raw);
@ -521,7 +520,7 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
return TRUE;
if (ecoff_data (abfd)->sym_filepos == 0)
{
bfd_get_symcount (abfd) = 0;
abfd->symcount = 0;
return TRUE;
}
@ -965,7 +964,7 @@ _bfd_ecoff_slurp_symbol_table (bfd *abfd)
the symbol count and warning the user. */
if (internal_ptr - internal < (ptrdiff_t) bfd_get_symcount (abfd))
{
bfd_get_symcount (abfd) = internal_ptr - internal;
abfd->symcount = internal_ptr - internal;
_bfd_error_handler
/* xgettext:c-format */
(_("%pB: warning: isymMax (%ld) is greater than ifdMax (%ld)"),
@ -2905,7 +2904,7 @@ _bfd_ecoff_slurp_armap (bfd *abfd)
&& nextname[ARMAP_OBJECT_ENDIAN_INDEX] != ARMAP_LITTLE_ENDIAN)
|| ! strneq (nextname + ARMAP_END_INDEX, ARMAP_END, sizeof ARMAP_END - 1))
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -3018,7 +3017,7 @@ _bfd_ecoff_slurp_armap (bfd *abfd)
/* Pad to an even boundary. */
ardata->first_file_filepos += ardata->first_file_filepos % 2;
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
return TRUE;
}
@ -4459,7 +4458,7 @@ _bfd_ecoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
}
}
bfd_get_symcount (abfd) = symhdr->iextMax + symhdr->isymMax;
abfd->symcount = symhdr->iextMax + symhdr->isymMax;
ecoff_data (abfd)->linker = TRUE;

View File

@ -8405,7 +8405,7 @@ _bfd_elf_canonicalize_symtab (bfd *abfd, asymbol **allocation)
long symcount = bed->s->slurp_symbol_table (abfd, allocation, FALSE);
if (symcount >= 0)
bfd_get_symcount (abfd) = symcount;
abfd->symcount = symcount;
return symcount;
}
@ -8417,7 +8417,7 @@ _bfd_elf_canonicalize_dynamic_symtab (bfd *abfd,
long symcount = bed->s->slurp_symbol_table (abfd, allocation, TRUE);
if (symcount >= 0)
bfd_get_dynamic_symcount (abfd) = symcount;
abfd->dynsymcount = symcount;
return symcount;
}

View File

@ -305,7 +305,7 @@ elf_core_file_p (bfd *abfd)
}
/* Save the entry point from the ELF header. */
bfd_get_start_address (abfd) = i_ehdrp->e_entry;
abfd->start_address = i_ehdrp->e_entry;
return abfd->xvec;
wrong:

View File

@ -9481,7 +9481,7 @@ elf_link_output_symstrtab (struct elf_final_link_info *flinfo,
hash_table->strtab[hash_table->strtabcount].destshndx_index
= flinfo->symshndxbuf ? bfd_get_symcount (flinfo->output_bfd) : 0;
bfd_get_symcount (flinfo->output_bfd) += 1;
flinfo->output_bfd->symcount += 1;
hash_table->strtabcount += 1;
return 1;
@ -12012,7 +12012,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
/* Figure out the file positions for everything but the symbol table
and the relocs. We set symcount to force assign_section_numbers
to create a symbol table. */
bfd_get_symcount (abfd) = info->strip != strip_all || emit_relocs;
abfd->symcount = info->strip != strip_all || emit_relocs;
BFD_ASSERT (! abfd->output_has_begun);
if (! _bfd_elf_compute_section_file_positions (abfd, info))
goto error_return;
@ -12057,7 +12057,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
.symtab, .strtab, and non-loaded reloc sections. We start the
.symtab section at the current file position, and write directly
to it. We build the .strtab section in memory. */
bfd_get_symcount (abfd) = 0;
abfd->symcount = 0;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
/* sh_name is set in prep_headers. */
symtab_hdr->sh_type = SHT_SYMTAB;

View File

@ -810,14 +810,13 @@ bfd_generic_link_read_symbols (bfd *abfd)
symsize = bfd_get_symtab_upper_bound (abfd);
if (symsize < 0)
return FALSE;
bfd_get_outsymbols (abfd) = (struct bfd_symbol **) bfd_alloc (abfd,
symsize);
abfd->outsymbols = bfd_alloc (abfd, symsize);
if (bfd_get_outsymbols (abfd) == NULL && symsize != 0)
return FALSE;
symcount = bfd_canonicalize_symtab (abfd, bfd_get_outsymbols (abfd));
if (symcount < 0)
return FALSE;
bfd_get_symcount (abfd) = symcount;
abfd->symcount = symcount;
}
return TRUE;
@ -1824,8 +1823,8 @@ _bfd_generic_final_link (bfd *abfd, struct bfd_link_info *info)
size_t outsymalloc;
struct generic_write_global_symbol_info wginfo;
bfd_get_outsymbols (abfd) = NULL;
bfd_get_symcount (abfd) = 0;
abfd->outsymbols = NULL;
abfd->symcount = 0;
outsymalloc = 0;
/* Mark all sections which will be included in the output file. */
@ -1958,12 +1957,12 @@ generic_add_output_symbol (bfd *output_bfd, size_t *psymalloc, asymbol *sym)
newsyms = (asymbol **) bfd_realloc (bfd_get_outsymbols (output_bfd), amt);
if (newsyms == NULL)
return FALSE;
bfd_get_outsymbols (output_bfd) = newsyms;
output_bfd->outsymbols = newsyms;
}
bfd_get_outsymbols (output_bfd) [bfd_get_symcount (output_bfd)] = sym;
output_bfd->outsymbols[output_bfd->symcount] = sym;
if (sym != NULL)
++ bfd_get_symcount (output_bfd);
++output_bfd->symcount;
return TRUE;
}

View File

@ -505,10 +505,10 @@ NAME (aout, some_aout_object_p) (bfd *abfd,
abort ();
}
bfd_get_start_address (abfd) = execp->a_entry;
abfd->start_address = execp->a_entry;
obj_aout_symbols (abfd) = NULL;
bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist);
abfd->symcount = execp->a_syms / sizeof (struct external_nlist);
/* The default relocation entry size is that of traditional V7 Unix. */
obj_reloc_entry_size (abfd) = RELOC_SIZE;
@ -1512,7 +1512,7 @@ NAME (aout, slurp_symbol_table) (bfd *abfd)
return FALSE;
}
bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd);
abfd->symcount = obj_aout_external_sym_count (abfd);
obj_aout_symbols (abfd) = cached;

View File

@ -1093,7 +1093,7 @@ pe_ILF_build_a_bfd (bfd * abfd,
/* Point the bfd at the symbol table. */
obj_symbols (abfd) = vars.sym_cache;
bfd_get_symcount (abfd) = vars.sym_index;
abfd->symcount = vars.sym_index;
obj_raw_syments (abfd) = vars.native_syms;
obj_raw_syment_count (abfd) = vars.sym_index;

View File

@ -2031,12 +2031,12 @@ som_object_setup (bfd *abfd,
|| (aux_hdrp->exec_entry & 0x3) != 0
|| ! found)
{
bfd_get_start_address (abfd) = aux_hdrp->exec_flags;
abfd->start_address = aux_hdrp->exec_flags;
obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_entry;
}
else
{
bfd_get_start_address (abfd) = aux_hdrp->exec_entry + current_offset;
abfd->start_address = aux_hdrp->exec_entry + current_offset;
obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags;
}
}
@ -2044,7 +2044,7 @@ som_object_setup (bfd *abfd,
obj_som_exec_data (abfd)->version_id = file_hdrp->version_id;
bfd_default_set_arch_mach (abfd, bfd_arch_hppa, pa10);
bfd_get_symcount (abfd) = file_hdrp->symbol_total;
abfd->symcount = file_hdrp->symbol_total;
/* Initialize the saved symbol table and string table to NULL.
Save important offsets and sizes from the SOM header into
@ -4792,7 +4792,7 @@ som_slurp_symbol_table (bfd *abfd)
/* We modify the symbol count to record the number of BFD symbols we
created. */
bfd_get_symcount (abfd) = sym - symbase;
abfd->symcount = sym - symbase;
/* Save our results and return success. */
obj_som_symtab (abfd) = symbase;
@ -6131,7 +6131,7 @@ som_slurp_armap (bfd *abfd)
/* For archives without .o files there is no symbol table. */
if (! CONST_STRNEQ (nextname, "/ "))
{
bfd_has_map (abfd) = FALSE;
abfd->has_armap = FALSE;
return TRUE;
}
@ -6201,7 +6201,7 @@ som_slurp_armap (bfd *abfd)
return FALSE;
/* Notify the generic archive code that we have a symbol map. */
bfd_has_map (abfd) = TRUE;
abfd->has_armap = TRUE;
return TRUE;
}

View File

@ -455,8 +455,8 @@ bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int symcount)
return FALSE;
}
bfd_get_outsymbols (abfd) = location;
bfd_get_symcount (abfd) = symcount;
abfd->outsymbols = location;
abfd->symcount = symcount;
return TRUE;
}

View File

@ -8912,8 +8912,8 @@ alpha_vms_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
return FALSE;
}
bfd_get_outsymbols (abfd) = NULL;
bfd_get_symcount (abfd) = 0;
abfd->outsymbols = NULL;
abfd->symcount = 0;
/* Mark all sections which will be included in the output file. */
for (o = abfd->sections; o != NULL; o = o->next)

View File

@ -6412,9 +6412,9 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
goto error_return;
}
/* Setting bfd_get_symcount to 0 will cause write_object_contents to
/* Setting symcount to 0 will cause write_object_contents to
not try to write out the symbols. */
bfd_get_symcount (abfd) = 0;
abfd->symcount = 0;
return TRUE;