+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>
* elfxx-target.h (elfNN_bed): Constify.
\f
/* This stuff is somewhat copied from coffcode.h. */
static asection bfd_debug_section =
-{
- /* 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,
-};
+ BFD_FAKE_SECTION (bfd_debug_section, NULL, "*DEBUG*", 0, 0);
/* Create an ECOFF object. */
faster assembler code. This is what we use for the small common
section. */
static asection ecoff_scom_section;
-static asymbol ecoff_scom_symbol;
-static asymbol *ecoff_scom_symbol_ptr;
+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);
/* Create an empty symbol. */
}
/* Fall through. */
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->flags = 0;
break;
}
/* Fall through. */
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;
break;
case scSUndefined:
_SDA_BASE. This is what we use for the small common section. This
approach is copied from elf32-mips.c. */
static asection m32r_elf_scom_section;
-static asymbol m32r_elf_scom_symbol;
-static asymbol *m32r_elf_scom_symbol_ptr;
+static const asymbol m32r_elf_scom_symbol =
+ 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. */
switch (elfsym->internal_elf_sym.st_shndx)
{
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->value = elfsym->internal_elf_sym.st_size;
break;
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
static asection score_elf_scom_section;
-static asymbol score_elf_scom_symbol;
-static asymbol *score_elf_scom_symbol_ptr;
+static const asymbol score_elf_scom_symbol =
+ 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
score_bfd_get_16 (bfd *abfd, const void *data)
break;
/* Fall through. */
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->value = elfsym->internal_elf_sym.st_size;
break;
together, and then referenced via the gp pointer, which yields
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
-static asection score_elf_scom_section;
-static asymbol score_elf_scom_symbol;
-static asymbol * score_elf_scom_symbol_ptr;
+static asection score_elf_scom_section;
+static const asymbol score_elf_scom_symbol =
+ 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
score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
break;
/* Fall through. */
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->value = elfsym->internal_elf_sym.st_size;
break;
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
static asection tic6x_elf_scom_section;
-static asymbol tic6x_elf_scom_symbol;
-static asymbol *tic6x_elf_scom_symbol_ptr;
+static const asymbol tic6x_elf_scom_symbol =
+ 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[] =
{
switch (elfsym->internal_elf_sym.st_shndx)
{
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->value = elfsym->internal_elf_sym.st_size;
break;
respectively, which yields smaller, faster assembler code. This
approach is copied from elf32-mips.c. */
-static asection v850_elf_scom_section;
-static asymbol v850_elf_scom_symbol;
-static asymbol * v850_elf_scom_symbol_ptr;
-static asection v850_elf_tcom_section;
-static asymbol v850_elf_tcom_symbol;
-static asymbol * v850_elf_tcom_symbol_ptr;
-static asection v850_elf_zcom_section;
-static asymbol v850_elf_zcom_symbol;
-static asymbol * v850_elf_zcom_symbol_ptr;
+static asection v850_elf_scom_section;
+static const asymbol v850_elf_scom_symbol =
+ GLOBAL_SYM_INIT (".scommon", &v850_elf_scom_section);
+static asection v850_elf_scom_section =
+ BFD_FAKE_SECTION (v850_elf_scom_section, &v850_elf_scom_symbol,
+ ".scommon", 0,
+ SEC_IS_COMMON | SEC_SMALL_DATA | SEC_ALLOC | SEC_DATA);
+
+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
corresponding ELF section index. */
switch (indx)
{
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->value = elfsym->internal_elf_sym.st_size;
break;
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->value = elfsym->internal_elf_sym.st_size;
break;
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->value = elfsym->internal_elf_sym.st_size;
break;
formats (e.g. mmo) than for example a STT_REGISTER attribute.
This section faking is based on a construct in elf32-mips.c. */
static asection mmix_elf_reg_section;
-static asymbol mmix_elf_reg_section_symbol;
-static asymbol *mmix_elf_reg_section_symbol_ptr;
+static const asymbol mmix_elf_reg_section_symbol =
+ 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. */
switch (elfsym->internal_elf_sym.st_shndx)
{
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;
break;
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
static asection mips_elf_scom_section;
-static asymbol mips_elf_scom_symbol;
-static asymbol *mips_elf_scom_symbol_ptr;
+static const asymbol mips_elf_scom_symbol =
+ 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
allocated common symbol which may be overridden by a
definition in a shared library. */
static asection mips_elf_acom_section;
-static asymbol mips_elf_acom_symbol;
-static asymbol *mips_elf_acom_symbol_ptr;
+static const asymbol mips_elf_acom_symbol =
+ 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. */
either resolve these symbols to something in a shared
library, or it can just leave them here. For our purposes,
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;
break;
break;
/* Fall through. */
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->value = elfsym->internal_elf_sym.st_size;
break;
+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>
* config/obj-elf.c (obj_elf_section): Don't set elf_osabi here.
cur_file_ptr = save_file_ptr;
}
\f
+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
.scommon section rather than bfd_com_section. */
&& S_GET_VALUE (sym) > 0
&& S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
{
- static asection 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);
+ S_SET_SEGMENT (sym, &ecoff_scom_section);
}
/* Double check weak symbols. */