Statically initialise target common sections

This tidies initialisation of target common sections, doing so using a
static initialiser rather than via code and deleting unnecessary
symbol_ptr_ptr variables (the one in asection is used instead).

The patch also initialises ecoff.c:bfd_debug_section using
BFD_FAKE_SECTION.  That does change bfd_debug_section slightly,
output_section was NULL now bfd_debug_section, and symbol_ptr_ptr
was NULL now &bfd_debug_section.symbol, but I believe those changes
are safe.

bfd/
	* ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION.
	(ecoff_scom_section, ecoff_scom_symbol): Statically init using
	BFD_FAKE_SECTION and GLOBAL_SYM_INIT.  Delete initialisation code.
	(ecoff_scom_symbol_ptr): Delete.
	* elf32-m32r.c (m32r_elf_scom_section, m32r_elf_scom_symbol),
	(m32r_elf_scom_symbol_ptr),
	* elf32-score.c (score_elf_scom_section, score_elf_scom_symbol),
	(score_elf_scom_symbol_ptr),
	* elf32-score7.c (score_elf_scom_section, score_elf_scom_symbol),
	(score_elf_scom_symbol_ptr),
	* elf32-tic6x.c (tic6x_elf_scom_section, tic6x_elf_scom_symbol),
	(tic6x_elf_scom_symbol_ptr),
	* elf32-v850.c (v850_elf_scom_section, v850_elf_scom_symbol),
	(v850_elf_scom_symbol_ptr),
	(v850_elf_tcom_section, v850_elf_tcom_symbol),
	(v850_elf_tcom_symbol_ptr),
	(v850_elf_zcom_section, v850_elf_zcom_symbol),
	(v850_elf_zcom_symbol_ptr),
	* elf64-mmix.c (mmix_elf_reg_section, mmix_elf_reg_section_symbol),
	(mmix_elf_reg_section_symbol_ptr),
	* elfxx-mips.c (mips_elf_scom_section, mips_elf_scom_symbol),
	(mips_elf_scom_symbol_ptr): Likewise.
gas/
	* ecoff.c (ecoff_frob_symbol): Rename scom_section to
	ecoff_scom_section and statically initialise.
This commit is contained in:
Alan Modra 2020-12-17 07:44:48 +10:30
parent 3ece0b9527
commit 7f3a18cfb5
11 changed files with 93 additions and 232 deletions

View file

@ -1,3 +1,18 @@
2020-12-18 Alan Modra <amodra@gmail.com>
* ecoff.c (bfd_debug_section): Init using BFD_FAKE_SECTION.
(ecoff_scom_section, ecoff_scom_symbol): Statically init using
BFD_FAKE_SECTION and GLOBAL_SYM_INIT. Delete initialisation code.
* elf32-m32r.c (m32r_elf_scom_section, m32r_elf_scom_symbol),
* elf32-score.c (score_elf_scom_section, score_elf_scom_symbol),
* elf32-score7.c (score_elf_scom_section, score_elf_scom_symbol),
* elf32-tic6x.c (tic6x_elf_scom_section, tic6x_elf_scom_symbol),
* elf32-v850.c (v850_elf_scom_section, v850_elf_scom_symbol),
(v850_elf_tcom_section, v850_elf_tcom_symbol),
(v850_elf_zcom_section, v850_elf_zcom_symbol),
* elf64-mmix.c (mmix_elf_reg_section, mmix_elf_reg_section_symbol),
* elfxx-mips.c (mips_elf_scom_section, mips_elf_scom_symbol): Likewise.
2020-12-16 Alan Modra <amodra@gmail.com> 2020-12-16 Alan Modra <amodra@gmail.com>
* elfxx-target.h (elfNN_bed): Constify. * elfxx-target.h (elfNN_bed): Constify.

View file

@ -51,38 +51,7 @@
/* This stuff is somewhat copied from coffcode.h. */ /* This stuff is somewhat copied from coffcode.h. */
static asection bfd_debug_section = static asection bfd_debug_section =
{ BFD_FAKE_SECTION (bfd_debug_section, NULL, "*DEBUG*", 0, 0);
/* name, id, section_id, index, next, prev, flags, */
"*DEBUG*", 0, 0, 0, NULL, NULL, 0,
/* user_set_vma, */
0,
/* linker_mark, linker_has_input, gc_mark, compress_status, */
0, 0, 1, 0,
/* segment_mark, sec_info_type, use_rela_p, */
0, 0, 0,
/* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, */
0, 0, 0, 0, 0, 0,
/* vma, lma, size, rawsize, compressed_size, relax, relax_count, */
0, 0, 0, 0, 0, 0, 0,
/* output_offset, output_section, alignment_power, */
0, NULL, 0,
/* relocation, orelocation, reloc_count, filepos, rel_filepos, */
NULL, NULL, 0, 0, 0,
/* line_filepos, userdata, contents, lineno, lineno_count, */
0, NULL, NULL, NULL, 0,
/* entsize, kept_section, moving_line_filepos, */
0, NULL, 0,
/* target_index, used_by_bfd, constructor_chain, owner, */
0, NULL, NULL, NULL,
/* symbol, */
NULL,
/* symbol_ptr_ptr, */
NULL,
/* map_head, map_tail, */
{ NULL }, { NULL },
/* already_assigned */
NULL,
};
/* Create an ECOFF object. */ /* Create an ECOFF object. */
@ -644,8 +613,11 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
faster assembler code. This is what we use for the small common faster assembler code. This is what we use for the small common
section. */ section. */
static asection ecoff_scom_section; static asection ecoff_scom_section;
static asymbol ecoff_scom_symbol; static const asymbol ecoff_scom_symbol =
static asymbol *ecoff_scom_symbol_ptr; GLOBAL_SYM_INIT (SCOMMON, &ecoff_scom_section);
static asection ecoff_scom_section =
BFD_FAKE_SECTION (ecoff_scom_section, &ecoff_scom_symbol,
SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
/* Create an empty symbol. */ /* Create an empty symbol. */
@ -787,19 +759,6 @@ ecoff_set_symbol_info (bfd *abfd,
} }
/* Fall through. */ /* Fall through. */
case scSCommon: case scSCommon:
if (ecoff_scom_section.name == NULL)
{
/* Initialize the small common section. */
ecoff_scom_section.name = SCOMMON;
ecoff_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
ecoff_scom_section.output_section = &ecoff_scom_section;
ecoff_scom_section.symbol = &ecoff_scom_symbol;
ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
ecoff_scom_symbol.name = SCOMMON;
ecoff_scom_symbol.flags = BSF_SECTION_SYM;
ecoff_scom_symbol.section = &ecoff_scom_section;
ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
}
asym->section = &ecoff_scom_section; asym->section = &ecoff_scom_section;
asym->flags = 0; asym->flags = 0;
break; break;
@ -3400,19 +3359,6 @@ ecoff_link_add_externals (bfd *abfd,
} }
/* Fall through. */ /* Fall through. */
case scSCommon: case scSCommon:
if (ecoff_scom_section.name == NULL)
{
/* Initialize the small common section. */
ecoff_scom_section.name = SCOMMON;
ecoff_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
ecoff_scom_section.output_section = &ecoff_scom_section;
ecoff_scom_section.symbol = &ecoff_scom_symbol;
ecoff_scom_section.symbol_ptr_ptr = &ecoff_scom_symbol_ptr;
ecoff_scom_symbol.name = SCOMMON;
ecoff_scom_symbol.flags = BSF_SECTION_SYM;
ecoff_scom_symbol.section = &ecoff_scom_section;
ecoff_scom_symbol_ptr = &ecoff_scom_symbol;
}
section = &ecoff_scom_section; section = &ecoff_scom_section;
break; break;
case scSUndefined: case scSUndefined:

View file

@ -1337,8 +1337,11 @@ _bfd_m32r_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
_SDA_BASE. This is what we use for the small common section. This _SDA_BASE. This is what we use for the small common section. This
approach is copied from elf32-mips.c. */ approach is copied from elf32-mips.c. */
static asection m32r_elf_scom_section; static asection m32r_elf_scom_section;
static asymbol m32r_elf_scom_symbol; static const asymbol m32r_elf_scom_symbol =
static asymbol *m32r_elf_scom_symbol_ptr; GLOBAL_SYM_INIT (".scommon", &m32r_elf_scom_section);
static asection m32r_elf_scom_section =
BFD_FAKE_SECTION (m32r_elf_scom_section, &m32r_elf_scom_symbol,
".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
/* Handle the special M32R section numbers that a symbol may use. */ /* Handle the special M32R section numbers that a symbol may use. */
@ -1350,19 +1353,6 @@ _bfd_m32r_elf_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym)
switch (elfsym->internal_elf_sym.st_shndx) switch (elfsym->internal_elf_sym.st_shndx)
{ {
case SHN_M32R_SCOMMON: case SHN_M32R_SCOMMON:
if (m32r_elf_scom_section.name == NULL)
{
/* Initialize the small common section. */
m32r_elf_scom_section.name = ".scommon";
m32r_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
m32r_elf_scom_section.output_section = &m32r_elf_scom_section;
m32r_elf_scom_section.symbol = &m32r_elf_scom_symbol;
m32r_elf_scom_section.symbol_ptr_ptr = &m32r_elf_scom_symbol_ptr;
m32r_elf_scom_symbol.name = ".scommon";
m32r_elf_scom_symbol.flags = BSF_SECTION_SYM;
m32r_elf_scom_symbol.section = &m32r_elf_scom_section;
m32r_elf_scom_symbol_ptr = &m32r_elf_scom_symbol;
}
asym->section = &m32r_elf_scom_section; asym->section = &m32r_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;

View file

@ -201,8 +201,11 @@ static bfd *reldyn_sorting_bfd;
faster assembler code. This is what we use for the small common faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */ section. This approach is copied from ecoff.c. */
static asection score_elf_scom_section; static asection score_elf_scom_section;
static asymbol score_elf_scom_symbol; static const asymbol score_elf_scom_symbol =
static asymbol *score_elf_scom_symbol_ptr; GLOBAL_SYM_INIT (".scommon", &score_elf_scom_section);
static asection score_elf_scom_section =
BFD_FAKE_SECTION (score_elf_scom_section, &score_elf_scom_symbol,
".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
static bfd_vma static bfd_vma
score_bfd_get_16 (bfd *abfd, const void *data) score_bfd_get_16 (bfd *abfd, const void *data)
@ -3031,19 +3034,6 @@ s3_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
break; break;
/* Fall through. */ /* Fall through. */
case SHN_SCORE_SCOMMON: case SHN_SCORE_SCOMMON:
if (score_elf_scom_section.name == NULL)
{
/* Initialize the small common section. */
score_elf_scom_section.name = ".scommon";
score_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
score_elf_scom_section.output_section = &score_elf_scom_section;
score_elf_scom_section.symbol = &score_elf_scom_symbol;
score_elf_scom_section.symbol_ptr_ptr = &score_elf_scom_symbol_ptr;
score_elf_scom_symbol.name = ".scommon";
score_elf_scom_symbol.flags = BSF_SECTION_SYM;
score_elf_scom_symbol.section = &score_elf_scom_section;
score_elf_scom_symbol_ptr = &score_elf_scom_symbol;
}
asym->section = &score_elf_scom_section; asym->section = &score_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;

View file

@ -197,9 +197,12 @@ static bfd *reldyn_sorting_bfd;
together, and then referenced via the gp pointer, which yields together, and then referenced via the gp pointer, which yields
faster assembler code. This is what we use for the small common faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */ section. This approach is copied from ecoff.c. */
static asection score_elf_scom_section; static asection score_elf_scom_section;
static asymbol score_elf_scom_symbol; static const asymbol score_elf_scom_symbol =
static asymbol * score_elf_scom_symbol_ptr; GLOBAL_SYM_INIT (".scommon", &score_elf_scom_section);
static asection score_elf_scom_section =
BFD_FAKE_SECTION (score_elf_scom_section, &score_elf_scom_symbol,
".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
static bfd_reloc_status_type static bfd_reloc_status_type
score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED, score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
@ -2836,19 +2839,6 @@ s7_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
break; break;
/* Fall through. */ /* Fall through. */
case SHN_SCORE_SCOMMON: case SHN_SCORE_SCOMMON:
if (score_elf_scom_section.name == NULL)
{
/* Initialize the small common section. */
score_elf_scom_section.name = ".scommon";
score_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
score_elf_scom_section.output_section = &score_elf_scom_section;
score_elf_scom_section.symbol = &score_elf_scom_symbol;
score_elf_scom_section.symbol_ptr_ptr = &score_elf_scom_symbol_ptr;
score_elf_scom_symbol.name = ".scommon";
score_elf_scom_symbol.flags = BSF_SECTION_SYM;
score_elf_scom_symbol.section = &score_elf_scom_section;
score_elf_scom_symbol_ptr = &score_elf_scom_symbol;
}
asym->section = &score_elf_scom_section; asym->section = &score_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;

View file

@ -128,8 +128,11 @@ struct elf32_tic6x_obj_tdata
faster assembler code. This is what we use for the small common faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */ section. This approach is copied from ecoff.c. */
static asection tic6x_elf_scom_section; static asection tic6x_elf_scom_section;
static asymbol tic6x_elf_scom_symbol; static const asymbol tic6x_elf_scom_symbol =
static asymbol *tic6x_elf_scom_symbol_ptr; GLOBAL_SYM_INIT (".scommon", &tic6x_elf_scom_section);
static asection tic6x_elf_scom_section =
BFD_FAKE_SECTION (tic6x_elf_scom_section, &tic6x_elf_scom_symbol,
".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
static reloc_howto_type elf32_tic6x_howto_table[] = static reloc_howto_type elf32_tic6x_howto_table[] =
{ {
@ -2970,19 +2973,6 @@ elf32_tic6x_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym)
switch (elfsym->internal_elf_sym.st_shndx) switch (elfsym->internal_elf_sym.st_shndx)
{ {
case SHN_TIC6X_SCOMMON: case SHN_TIC6X_SCOMMON:
if (tic6x_elf_scom_section.name == NULL)
{
/* Initialize the small common section. */
tic6x_elf_scom_section.name = ".scommon";
tic6x_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
tic6x_elf_scom_section.output_section = &tic6x_elf_scom_section;
tic6x_elf_scom_section.symbol = &tic6x_elf_scom_symbol;
tic6x_elf_scom_section.symbol_ptr_ptr = &tic6x_elf_scom_symbol_ptr;
tic6x_elf_scom_symbol.name = ".scommon";
tic6x_elf_scom_symbol.flags = BSF_SECTION_SYM;
tic6x_elf_scom_symbol.section = &tic6x_elf_scom_section;
tic6x_elf_scom_symbol_ptr = &tic6x_elf_scom_symbol;
}
asym->section = &tic6x_elf_scom_section; asym->section = &tic6x_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;

View file

@ -2929,15 +2929,29 @@ v850_elf_print_private_bfd_data (bfd *abfd, void * ptr)
respectively, which yields smaller, faster assembler code. This respectively, which yields smaller, faster assembler code. This
approach is copied from elf32-mips.c. */ approach is copied from elf32-mips.c. */
static asection v850_elf_scom_section; static asection v850_elf_scom_section;
static asymbol v850_elf_scom_symbol; static const asymbol v850_elf_scom_symbol =
static asymbol * v850_elf_scom_symbol_ptr; GLOBAL_SYM_INIT (".scommon", &v850_elf_scom_section);
static asection v850_elf_tcom_section; static asection v850_elf_scom_section =
static asymbol v850_elf_tcom_symbol; BFD_FAKE_SECTION (v850_elf_scom_section, &v850_elf_scom_symbol,
static asymbol * v850_elf_tcom_symbol_ptr; ".scommon", 0,
static asection v850_elf_zcom_section; SEC_IS_COMMON | SEC_SMALL_DATA | SEC_ALLOC | SEC_DATA);
static asymbol v850_elf_zcom_symbol;
static asymbol * v850_elf_zcom_symbol_ptr; static asection v850_elf_tcom_section;
static const asymbol v850_elf_tcom_symbol =
GLOBAL_SYM_INIT (".tcommon", &v850_elf_tcom_section);
static asection v850_elf_tcom_section =
BFD_FAKE_SECTION (v850_elf_tcom_section, &v850_elf_tcom_symbol,
".tcommon", 0,
SEC_IS_COMMON | SEC_SMALL_DATA);
static asection v850_elf_zcom_section;
static const asymbol v850_elf_zcom_symbol =
GLOBAL_SYM_INIT (".zcommon", &v850_elf_zcom_section);
static asection v850_elf_zcom_section =
BFD_FAKE_SECTION (v850_elf_zcom_section, &v850_elf_zcom_symbol,
".zcommon", 0,
SEC_IS_COMMON | SEC_SMALL_DATA);
/* Given a BFD section, try to locate the /* Given a BFD section, try to locate the
corresponding ELF section index. */ corresponding ELF section index. */
@ -2997,56 +3011,16 @@ v850_elf_symbol_processing (bfd *abfd, asymbol *asym)
switch (indx) switch (indx)
{ {
case SHN_V850_SCOMMON: case SHN_V850_SCOMMON:
if (v850_elf_scom_section.name == NULL)
{
/* Initialize the small common section. */
v850_elf_scom_section.name = ".scommon";
v850_elf_scom_section.flags
= SEC_IS_COMMON | SEC_SMALL_DATA | SEC_ALLOC | SEC_DATA;
v850_elf_scom_section.output_section = & v850_elf_scom_section;
v850_elf_scom_section.symbol = & v850_elf_scom_symbol;
v850_elf_scom_section.symbol_ptr_ptr = & v850_elf_scom_symbol_ptr;
v850_elf_scom_symbol.name = ".scommon";
v850_elf_scom_symbol.flags = BSF_SECTION_SYM;
v850_elf_scom_symbol.section = & v850_elf_scom_section;
v850_elf_scom_symbol_ptr = & v850_elf_scom_symbol;
}
asym->section = & v850_elf_scom_section; asym->section = & v850_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;
case SHN_V850_TCOMMON: case SHN_V850_TCOMMON:
if (v850_elf_tcom_section.name == NULL)
{
/* Initialize the tcommon section. */
v850_elf_tcom_section.name = ".tcommon";
v850_elf_tcom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
v850_elf_tcom_section.output_section = & v850_elf_tcom_section;
v850_elf_tcom_section.symbol = & v850_elf_tcom_symbol;
v850_elf_tcom_section.symbol_ptr_ptr = & v850_elf_tcom_symbol_ptr;
v850_elf_tcom_symbol.name = ".tcommon";
v850_elf_tcom_symbol.flags = BSF_SECTION_SYM;
v850_elf_tcom_symbol.section = & v850_elf_tcom_section;
v850_elf_tcom_symbol_ptr = & v850_elf_tcom_symbol;
}
asym->section = & v850_elf_tcom_section; asym->section = & v850_elf_tcom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;
case SHN_V850_ZCOMMON: case SHN_V850_ZCOMMON:
if (v850_elf_zcom_section.name == NULL)
{
/* Initialize the zcommon section. */
v850_elf_zcom_section.name = ".zcommon";
v850_elf_zcom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
v850_elf_zcom_section.output_section = & v850_elf_zcom_section;
v850_elf_zcom_section.symbol = & v850_elf_zcom_symbol;
v850_elf_zcom_section.symbol_ptr_ptr = & v850_elf_zcom_symbol_ptr;
v850_elf_zcom_symbol.name = ".zcommon";
v850_elf_zcom_symbol.flags = BSF_SECTION_SYM;
v850_elf_zcom_symbol.section = & v850_elf_zcom_section;
v850_elf_zcom_symbol_ptr = & v850_elf_zcom_symbol;
}
asym->section = & v850_elf_zcom_section; asym->section = & v850_elf_zcom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;

View file

@ -2076,8 +2076,11 @@ mmix_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
formats (e.g. mmo) than for example a STT_REGISTER attribute. formats (e.g. mmo) than for example a STT_REGISTER attribute.
This section faking is based on a construct in elf32-mips.c. */ This section faking is based on a construct in elf32-mips.c. */
static asection mmix_elf_reg_section; static asection mmix_elf_reg_section;
static asymbol mmix_elf_reg_section_symbol; static const asymbol mmix_elf_reg_section_symbol =
static asymbol *mmix_elf_reg_section_symbol_ptr; GLOBAL_SYM_INIT (MMIX_REG_SECTION_NAME, &mmix_elf_reg_section);
static asection mmix_elf_reg_section =
BFD_FAKE_SECTION (mmix_elf_reg_section, &mmix_elf_reg_section_symbol,
MMIX_REG_SECTION_NAME, 0, SEC_NO_FLAGS);
/* Handle the special section numbers that a symbol may use. */ /* Handle the special section numbers that a symbol may use. */
@ -2090,19 +2093,6 @@ mmix_elf_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym)
switch (elfsym->internal_elf_sym.st_shndx) switch (elfsym->internal_elf_sym.st_shndx)
{ {
case SHN_REGISTER: case SHN_REGISTER:
if (mmix_elf_reg_section.name == NULL)
{
/* Initialize the register section. */
mmix_elf_reg_section.name = MMIX_REG_SECTION_NAME;
mmix_elf_reg_section.flags = SEC_NO_FLAGS;
mmix_elf_reg_section.output_section = &mmix_elf_reg_section;
mmix_elf_reg_section.symbol = &mmix_elf_reg_section_symbol;
mmix_elf_reg_section.symbol_ptr_ptr = &mmix_elf_reg_section_symbol_ptr;
mmix_elf_reg_section_symbol.name = MMIX_REG_SECTION_NAME;
mmix_elf_reg_section_symbol.flags = BSF_SECTION_SYM;
mmix_elf_reg_section_symbol.section = &mmix_elf_reg_section;
mmix_elf_reg_section_symbol_ptr = &mmix_elf_reg_section_symbol;
}
asym->section = &mmix_elf_reg_section; asym->section = &mmix_elf_reg_section;
break; break;

View file

@ -7058,15 +7058,21 @@ elf_mips_abi_name (bfd *abfd)
faster assembler code. This is what we use for the small common faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */ section. This approach is copied from ecoff.c. */
static asection mips_elf_scom_section; static asection mips_elf_scom_section;
static asymbol mips_elf_scom_symbol; static const asymbol mips_elf_scom_symbol =
static asymbol *mips_elf_scom_symbol_ptr; GLOBAL_SYM_INIT (".scommon", &mips_elf_scom_section);
static asection mips_elf_scom_section =
BFD_FAKE_SECTION (mips_elf_scom_section, &mips_elf_scom_symbol,
".scommon", 0, SEC_IS_COMMON | SEC_SMALL_DATA);
/* MIPS ELF also uses an acommon section, which represents an /* MIPS ELF also uses an acommon section, which represents an
allocated common symbol which may be overridden by a allocated common symbol which may be overridden by a
definition in a shared library. */ definition in a shared library. */
static asection mips_elf_acom_section; static asection mips_elf_acom_section;
static asymbol mips_elf_acom_symbol; static const asymbol mips_elf_acom_symbol =
static asymbol *mips_elf_acom_symbol_ptr; GLOBAL_SYM_INIT (".acommon", &mips_elf_acom_section);
static asection mips_elf_acom_section =
BFD_FAKE_SECTION (mips_elf_acom_section, &mips_elf_acom_symbol,
".acommon", 0, SEC_ALLOC);
/* This is used for both the 32-bit and the 64-bit ABI. */ /* This is used for both the 32-bit and the 64-bit ABI. */
@ -7085,19 +7091,6 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
either resolve these symbols to something in a shared either resolve these symbols to something in a shared
library, or it can just leave them here. For our purposes, library, or it can just leave them here. For our purposes,
we can consider these symbols to be in a new section. */ we can consider these symbols to be in a new section. */
if (mips_elf_acom_section.name == NULL)
{
/* Initialize the acommon section. */
mips_elf_acom_section.name = ".acommon";
mips_elf_acom_section.flags = SEC_ALLOC;
mips_elf_acom_section.output_section = &mips_elf_acom_section;
mips_elf_acom_section.symbol = &mips_elf_acom_symbol;
mips_elf_acom_section.symbol_ptr_ptr = &mips_elf_acom_symbol_ptr;
mips_elf_acom_symbol.name = ".acommon";
mips_elf_acom_symbol.flags = BSF_SECTION_SYM;
mips_elf_acom_symbol.section = &mips_elf_acom_section;
mips_elf_acom_symbol_ptr = &mips_elf_acom_symbol;
}
asym->section = &mips_elf_acom_section; asym->section = &mips_elf_acom_section;
break; break;
@ -7110,19 +7103,6 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
break; break;
/* Fall through. */ /* Fall through. */
case SHN_MIPS_SCOMMON: case SHN_MIPS_SCOMMON:
if (mips_elf_scom_section.name == NULL)
{
/* Initialize the small common section. */
mips_elf_scom_section.name = ".scommon";
mips_elf_scom_section.flags = SEC_IS_COMMON | SEC_SMALL_DATA;
mips_elf_scom_section.output_section = &mips_elf_scom_section;
mips_elf_scom_section.symbol = &mips_elf_scom_symbol;
mips_elf_scom_section.symbol_ptr_ptr = &mips_elf_scom_symbol_ptr;
mips_elf_scom_symbol.name = ".scommon";
mips_elf_scom_symbol.flags = BSF_SECTION_SYM;
mips_elf_scom_symbol.section = &mips_elf_scom_section;
mips_elf_scom_symbol_ptr = &mips_elf_scom_symbol;
}
asym->section = &mips_elf_scom_section; asym->section = &mips_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size; asym->value = elfsym->internal_elf_sym.st_size;
break; break;

View file

@ -1,3 +1,8 @@
2020-12-18 Alan Modra <amodra@gmail.com>
* ecoff.c (ecoff_frob_symbol): Rename scom_section to
ecoff_scom_section, move to file scope and statically initialise.
2020-12-16 Alan Modra <amodra@gmail.com> 2020-12-16 Alan Modra <amodra@gmail.com>
* config/obj-elf.c (obj_elf_section): Don't set elf_osabi here. * config/obj-elf.c (obj_elf_section): Don't set elf_osabi here.

View file

@ -3551,6 +3551,13 @@ ecoff_stab (segT sec ATTRIBUTE_UNUSED,
cur_file_ptr = save_file_ptr; cur_file_ptr = save_file_ptr;
} }
static asection ecoff_scom_section;
static const asymbol ecoff_scom_symbol =
GLOBAL_SYM_INIT (SCOMMON, &ecoff_scom_section);
static asection ecoff_scom_section =
BFD_FAKE_SECTION (ecoff_scom_section, &ecoff_scom_symbol,
SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
/* Frob an ECOFF symbol. Small common symbols go into a special /* Frob an ECOFF symbol. Small common symbols go into a special
.scommon section rather than bfd_com_section. */ .scommon section rather than bfd_com_section. */
@ -3561,23 +3568,7 @@ ecoff_frob_symbol (symbolS *sym)
&& S_GET_VALUE (sym) > 0 && S_GET_VALUE (sym) > 0
&& S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput)) && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
{ {
static asection scom_section; S_SET_SEGMENT (sym, &ecoff_scom_section);
static asymbol scom_symbol;
/* We must construct a fake section similar to bfd_com_section
but with the name .scommon. */
if (scom_section.name == NULL)
{
scom_section = *bfd_com_section_ptr;
scom_section.name = ".scommon";
scom_section.output_section = &scom_section;
scom_section.symbol = &scom_symbol;
scom_section.symbol_ptr_ptr = &scom_section.symbol;
scom_symbol = *bfd_com_section_ptr->symbol;
scom_symbol.name = ".scommon";
scom_symbol.section = &scom_section;
}
S_SET_SEGMENT (sym, &scom_section);
} }
/* Double check weak symbols. */ /* Double check weak symbols. */