diff options
author | Alan Modra <amodra@gmail.com> | 2020-12-17 07:44:48 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-12-18 10:34:16 +1030 |
commit | 7f3a18cfb58deb36e05469d94e7b9e48b19d90af (patch) | |
tree | fdcaf3f90aab305c07bb75189d9db56db67c4dbe /bfd | |
parent | 3ece0b95273fafe20fface5be0b70667eaf7a127 (diff) | |
download | gdb-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')
-rw-r--r-- | bfd/ChangeLog | 15 | ||||
-rw-r--r-- | bfd/ecoff.c | 66 | ||||
-rw-r--r-- | bfd/elf32-m32r.c | 20 | ||||
-rw-r--r-- | bfd/elf32-score.c | 20 | ||||
-rw-r--r-- | bfd/elf32-score7.c | 22 | ||||
-rw-r--r-- | bfd/elf32-tic6x.c | 20 | ||||
-rw-r--r-- | bfd/elf32-v850.c | 72 | ||||
-rw-r--r-- | bfd/elf64-mmix.c | 20 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 40 |
9 files changed, 80 insertions, 215 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f88a565..40d96a8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -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> * elfxx-target.h (elfNN_bed): Constify. diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 2e4bf88..22060e7 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -51,38 +51,7 @@ /* 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. */ @@ -644,8 +613,11 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd, 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. */ @@ -787,19 +759,6 @@ ecoff_set_symbol_info (bfd *abfd, } /* 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; @@ -3400,19 +3359,6 @@ ecoff_link_add_externals (bfd *abfd, } /* 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: diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 533d662..46fb6c7 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -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 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. */ @@ -1350,19 +1353,6 @@ _bfd_m32r_elf_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym) 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; diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c index 8038057..5c15c70 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -201,8 +201,11 @@ static bfd *reldyn_sorting_bfd; 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) @@ -3031,19 +3034,6 @@ s3_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym) 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; diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c index 8b2b4bc..40ae21b 100644 --- a/bfd/elf32-score7.c +++ b/bfd/elf32-score7.c @@ -197,9 +197,12 @@ static bfd *reldyn_sorting_bfd; 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, @@ -2836,19 +2839,6 @@ s7_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym) 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; diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c index 5f5abd5..3ccb9c7 100644 --- a/bfd/elf32-tic6x.c +++ b/bfd/elf32-tic6x.c @@ -128,8 +128,11 @@ struct elf32_tic6x_obj_tdata 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[] = { @@ -2970,19 +2973,6 @@ elf32_tic6x_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym) 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; 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; diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 2fc491c..fad1a0a 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -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. 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. */ @@ -2090,19 +2093,6 @@ mmix_elf_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED, asymbol *asym) 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; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 4ea04d4..6d43d10 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -7058,15 +7058,21 @@ elf_mips_abi_name (bfd *abfd) 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. */ @@ -7085,19 +7091,6 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym) 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; @@ -7110,19 +7103,6 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym) 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; |