aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-v850.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-12-17 07:44:48 +1030
committerAlan Modra <amodra@gmail.com>2020-12-18 10:34:16 +1030
commit7f3a18cfb58deb36e05469d94e7b9e48b19d90af (patch)
treefdcaf3f90aab305c07bb75189d9db56db67c4dbe /bfd/elf32-v850.c
parent3ece0b95273fafe20fface5be0b70667eaf7a127 (diff)
downloadgdb-7f3a18cfb58deb36e05469d94e7b9e48b19d90af.zip
gdb-7f3a18cfb58deb36e05469d94e7b9e48b19d90af.tar.gz
gdb-7f3a18cfb58deb36e05469d94e7b9e48b19d90af.tar.bz2
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.
Diffstat (limited to 'bfd/elf32-v850.c')
-rw-r--r--bfd/elf32-v850.c72
1 files changed, 23 insertions, 49 deletions
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 8c6af58..88e774b 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -2929,15 +2929,29 @@ v850_elf_print_private_bfd_data (bfd *abfd, void * ptr)
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. */
@@ -2997,56 +3011,16 @@ v850_elf_symbol_processing (bfd *abfd, asymbol *asym)
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;