Move BFD_FAKE_SECTION to libbfd.h
BFD_FAKE_SECTION and its sidekick GLOBAL_SYM_INIT don't need to be
cluttering bfd.h, and probably shouldn't be used outside bfd/. To
make them internal to bfd, make the bfd ecoff small common section
declaration global so it can be used instead of a duplicate in
gas/ecoff.c. Oddly this needs to go in bfd/ecofflink.c rather than
bfd/ecoff.c as the former is compiled for all targets needing the
ecoff small common section (some via a call in gas/config/obj-elf.c to
a function in gas/ecoff.c) while the latter is not.
While doing this rename ecoff_scom_section to _bfd_ecoff_scom_section
and remove support for traditional C from GLOBAL_SYM_INIT.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index c29ff2b..7a8318e 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -976,57 +976,6 @@
&& sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS);
}
-#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS) \
- /* name, next, prev, id, section_id, index, flags, user_set_vma, */ \
- { NAME, NULL, NULL, IDX, 0, 0, FLAGS, 0, \
- \
- /* linker_mark, linker_has_input, gc_mark, decompress_status, */ \
- 0, 0, 1, 0, \
- \
- /* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced, */ \
- 0, 0, 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, */ \
- 0, 0, 0, 0, 0, \
- \
- /* output_offset, output_section, relocation, orelocation, */ \
- 0, &SEC, NULL, NULL, \
- \
- /* reloc_count, alignment_power, filepos, rel_filepos, */ \
- 0, 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, */ \
- (struct bfd_symbol *) SYM, \
- \
- /* map_head, map_tail, already_assigned, type */ \
- { NULL }, { NULL }, NULL, 0 \
- \
- }
-
-/* We use a macro to initialize the static asymbol structures because
- traditional C does not permit us to initialize a union member while
- gcc warns if we don't initialize it.
- the_bfd, name, value, attr, section [, udata] */
-#ifdef __STDC__
-#define GLOBAL_SYM_INIT(NAME, SECTION) \
- { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
-#else
-#define GLOBAL_SYM_INIT(NAME, SECTION) \
- { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
-#endif
-
void bfd_section_list_clear (bfd *);
asection *bfd_get_section_by_name (bfd *abfd, const char *name);
diff --git a/bfd/ecoff-bfd.h b/bfd/ecoff-bfd.h
index a1371fa..cb86960 100644
--- a/bfd/ecoff-bfd.h
+++ b/bfd/ecoff-bfd.h
@@ -18,6 +18,8 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
+extern asection _bfd_ecoff_scom_section;
+
extern bool bfd_ecoff_set_gp_value
(bfd *abfd, bfd_vma gp_value);
extern bool bfd_ecoff_set_regmasks
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 361f488..5f9fa43 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -661,18 +661,6 @@
/* ECOFF symbol table routines. The ECOFF symbol table is described
in gcc/mips-tfile.c. */
-/* ECOFF uses two common sections. One is the usual one, and the
- other is for small objects. All the small objects are kept
- together, and then referenced via the gp pointer, which yields
- faster assembler code. This is what we use for the small common
- section. */
-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);
-
/* Create an empty symbol. */
asymbol *
@@ -813,7 +801,7 @@
}
/* Fall through. */
case scSCommon:
- asym->section = &ecoff_scom_section;
+ asym->section = &_bfd_ecoff_scom_section;
asym->flags = 0;
break;
case scVarRegister:
@@ -3441,7 +3429,7 @@
}
/* Fall through. */
case scSCommon:
- section = &ecoff_scom_section;
+ section = &_bfd_ecoff_scom_section;
break;
case scSUndefined:
section = bfd_und_section_ptr;
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index c193491..ce1bd41 100644
--- a/bfd/ecofflink.c
+++ b/bfd/ecofflink.c
@@ -32,7 +32,18 @@
#include "coff/ecoff.h"
#include "libcoff.h"
#include "libecoff.h"
-
+
+/* ECOFF uses two common sections. One is the usual one, and the
+ other is for small objects. All the small objects are kept
+ together, and then referenced via the gp pointer, which yields
+ faster assembler code. This is what we use for the small common
+ section. */
+static const asymbol ecoff_scom_symbol =
+ GLOBAL_SYM_INIT (SCOMMON, &_bfd_ecoff_scom_section);
+asection _bfd_ecoff_scom_section =
+ BFD_FAKE_SECTION (_bfd_ecoff_scom_section, &ecoff_scom_symbol,
+ SCOMMON, 0, SEC_IS_COMMON | SEC_SMALL_DATA);
+
/* Routines to swap auxiliary information in and out. I am assuming
that the auxiliary information format is always going to be target
independent. */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 86f2203..4f6f5ea 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -3668,6 +3668,49 @@
unsigned int r_type) ATTRIBUTE_HIDDEN;
/* Extracted from section.c. */
+#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS) \
+ /* name, next, prev, id, section_id, index, flags, user_set_vma, */ \
+ { NAME, NULL, NULL, IDX, 0, 0, FLAGS, 0, \
+ \
+ /* linker_mark, linker_has_input, gc_mark, decompress_status, */ \
+ 0, 0, 1, 0, \
+ \
+ /* segment_mark, sec_info_type, use_rela_p, mmapped_p, alloced, */ \
+ 0, 0, 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, */ \
+ 0, 0, 0, 0, 0, \
+ \
+ /* output_offset, output_section, relocation, orelocation, */ \
+ 0, &SEC, NULL, NULL, \
+ \
+ /* reloc_count, alignment_power, filepos, rel_filepos, */ \
+ 0, 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, */ \
+ (struct bfd_symbol *) SYM, \
+ \
+ /* map_head, map_tail, already_assigned, type */ \
+ { NULL }, { NULL }, NULL, 0 \
+ \
+ }
+
+#define GLOBAL_SYM_INIT(NAME, SECTION) \
+ /* the_bfd, name, value, attr, section, udata */ \
+ { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 } }
+
/* Extracted from stabs.c. */
bool _bfd_link_section_stabs
(bfd *, struct stab_info *, asection *, asection *, void **,
diff --git a/bfd/section.c b/bfd/section.c
index b1f7564..9460ff9 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -712,6 +712,7 @@
. && sec->sec_info_type != SEC_INFO_TYPE_JUST_SYMS);
.}
.
+INTERNAL
.#define BFD_FAKE_SECTION(SEC, SYM, NAME, IDX, FLAGS) \
. {* name, next, prev, id, section_id, index, flags, user_set_vma, *} \
. { NAME, NULL, NULL, IDX, 0, 0, FLAGS, 0, \
@@ -749,19 +750,11 @@
. {* map_head, map_tail, already_assigned, type *} \
. { NULL }, { NULL }, NULL, 0 \
. \
-. }
+. }
.
-.{* We use a macro to initialize the static asymbol structures because
-. traditional C does not permit us to initialize a union member while
-. gcc warns if we don't initialize it.
-. the_bfd, name, value, attr, section [, udata] *}
-.#ifdef __STDC__
-.#define GLOBAL_SYM_INIT(NAME, SECTION) \
-. { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
-.#else
-.#define GLOBAL_SYM_INIT(NAME, SECTION) \
-. { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
-.#endif
+.#define GLOBAL_SYM_INIT(NAME, SECTION) \
+. {* the_bfd, name, value, attr, section, udata *} \
+. { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 } }
.
*/
diff --git a/gas/ecoff.c b/gas/ecoff.c
index b8c9019..f665f11 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -36,6 +36,7 @@
#include "aout/stab_gnu.h"
#include "filenames.h"
#include "safe-ctype.h"
+#include "ecoff-bfd.h"
/* Why isn't this in coff/sym.h? */
#define ST_RFDESCAPE 0xfff
@@ -3549,13 +3550,6 @@
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
.scommon section rather than bfd_com_section. */
@@ -3566,7 +3560,7 @@
&& S_GET_VALUE (sym) > 0
&& S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
{
- S_SET_SEGMENT (sym, &ecoff_scom_section);
+ S_SET_SEGMENT (sym, &_bfd_ecoff_scom_section);
}
/* Double check weak symbols. */