aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorDave Anglin <dave.anglin@nrc.ca>2004-04-28 18:02:49 +0000
committerDave Anglin <dave.anglin@nrc.ca>2004-04-28 18:02:49 +0000
commit351e2b5aa7a71258e6b682ac1a3228964de8d22c (patch)
treeceeea7cffc3e9334242ef8f547b4fcfb144a3eaa /gas
parent82c10df67c913fa42750768634b7e7a618d55be6 (diff)
downloadgdb-351e2b5aa7a71258e6b682ac1a3228964de8d22c.zip
gdb-351e2b5aa7a71258e6b682ac1a3228964de8d22c.tar.gz
gdb-351e2b5aa7a71258e6b682ac1a3228964de8d22c.tar.bz2
* som.c (struct som_misc_symbol_info): Add is_comdat, is_common and
dup_common fields. (setup_sections): Use som_subspace_dictionary_record struct instead subspace_dictionary_record. Set SEC_LINK_ONCE if subspace is is_comdat, is_common or dup_common. (som_prep_headers): Use som_subspace_dictionary_record struct. Set is_comdat, is_common and dup_common in section subspace_dict from copy_data. (som_begin_writing): Use som_subspace_dictionary_record struct. (som_finish_writing): Likewise. (som_bfd_derive_misc_symbol_info): Add support to set is_comdat, is_common and dup_common flags in info for symbol. Add comment regarding linker support for these fields. Slightly reorganize function. (som_build_and_write_symbol_table): Set is_comdat, is_common and dup_common fields in symbol table from symbol info. (bfd_som_set_subsection_attributes): Add comdat, common and dup_common arguments. Set corresponding fields in copy_data. Change all callers. (som_bfd_ar_write_symbol_stuff): Set dup_common flag in library symbol table. (som_vec): Add SEC_LINK_ONCE to applicable section flags. * som.h (som_subspace_dictionary_record): Define. (som_copyable_section_data_struct): Add is_comdat, is_common and dup_common fields. (som_section_data_struct): Use som_subspace_dictionary_record struct instead of subspace_dictionary_record. (bfd_boolean bfd_som_set_subsection_attributes): Adjust prototype. * config/obj-som.c (obj_som_init_stab_section): Add new arguments in call to obj_set_subsection_attributes. (obj_som_init_stab_section): Likewise. * config/tc-hppa.c (default_subspace_dict): Add comdat field. (pa_def_subspaces): Provide comdat default. (pa_subspace): Handle new "comdat" parameter. Set SEC_LINK_ONCE and not SEC_IS_COMMON if section is comdat, common or dup_common. Update calls to create_new_subspace and update_subspace to pass comdat flag. (create_new_subspace, update_subspace): Add new comdat argument. Use it in calls to obj_set_subsection_attributes. * doc/c-hppa.texi (.subspa, .nsubspa): Document new comdat parameter and use of comdat, common and dup_comm parameters.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog15
-rw-r--r--gas/config/obj-som.c4
-rw-r--r--gas/config/tc-hppa.c69
-rw-r--r--gas/doc/c-hppa.texi45
4 files changed, 103 insertions, 30 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 08a4750..23eee16 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,18 @@
+2004-04-28 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+
+ * config/obj-som.c (obj_som_init_stab_section): Add new arguments in
+ call to obj_set_subsection_attributes.
+ (obj_som_init_stab_section): Likewise.
+ * config/tc-hppa.c (default_subspace_dict): Add comdat field.
+ (pa_def_subspaces): Provide comdat default.
+ (pa_subspace): Handle new "comdat" parameter. Set SEC_LINK_ONCE and
+ not SEC_IS_COMMON if section is comdat, common or dup_common. Update
+ calls to create_new_subspace and update_subspace to pass comdat flag.
+ (create_new_subspace, update_subspace): Add new comdat argument. Use
+ it in calls to obj_set_subsection_attributes.
+ * doc/c-hppa.texi (.subspa, .nsubspa): Document new comdat parameter
+ and use of comdat, common and dup_comm parameters.
+
2004-04-26 H.J. Lu <hongjiu.lu@intel.com>
* config/obj-elf.c (obj_elf_change_section): Check if the old
diff --git a/gas/config/obj-som.c b/gas/config/obj-som.c
index 454042a..a736c96 100644
--- a/gas/config/obj-som.c
+++ b/gas/config/obj-som.c
@@ -248,7 +248,7 @@ obj_som_init_stab_section (seg)
(just created above). Also set some attributes which BFD does
not understand. In particular, access bits, sort keys, and load
quadrant. */
- obj_set_subsection_attributes (seg, space, 0x1f, 73, 0);
+ obj_set_subsection_attributes (seg, space, 0x1f, 73, 0, 0, 0, 0);
bfd_set_section_alignment (stdoutput, seg, 2);
/* Make some space for the first special stab entry and zero the memory.
@@ -271,7 +271,7 @@ obj_som_init_stab_section (seg)
not understand. In particular, access bits, sort keys, and load
quadrant. */
seg = bfd_get_section_by_name (stdoutput, "$GDB_STRINGS$");
- obj_set_subsection_attributes (seg, space, 0x1f, 72, 0);
+ obj_set_subsection_attributes (seg, space, 0x1f, 72, 0, 0, 0, 0);
bfd_set_section_alignment (stdoutput, seg, 2);
subseg_set (saved_seg, saved_subseg);
diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c
index 77563a9..72abe1d 100644
--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -363,6 +363,9 @@ struct default_subspace_dict
/* Nonzero if this subspace contains only code. */
char code_only;
+ /* Nonzero if this is a comdat subspace. */
+ char comdat;
+
/* Nonzero if this is a common subspace. */
char common;
@@ -555,13 +558,13 @@ static sd_chain_struct *create_new_space PARAMS ((char *, int, int,
asection *, int));
static ssd_chain_struct *create_new_subspace PARAMS ((sd_chain_struct *,
char *, int, int,
- int, int, int,
+ int, int, int, int,
int, int, int, int,
int, asection *));
static ssd_chain_struct *update_subspace PARAMS ((sd_chain_struct *,
char *, int, int, int,
int, int, int, int,
- int, int, int,
+ int, int, int, int,
asection *));
static sd_chain_struct *is_defined_space PARAMS ((char *));
static ssd_chain_struct *is_defined_subspace PARAMS ((char *));
@@ -1117,12 +1120,12 @@ static const struct selector_entry selector_table[] =
static struct default_subspace_dict pa_def_subspaces[] =
{
- {"$CODE$", 1, 1, 1, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE},
- {"$DATA$", 1, 1, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA},
- {"$LIT$", 1, 1, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT},
- {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI},
- {"$BSS$", 1, 1, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS},
- {NULL, 0, 1, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
+ {"$CODE$", 1, 1, 1, 0, 0, 0, 0, 24, 0x2c, 0, 8, 0, 0, SUBSEG_CODE},
+ {"$DATA$", 1, 1, 0, 0, 0, 0, 0, 24, 0x1f, 1, 8, 1, 1, SUBSEG_DATA},
+ {"$LIT$", 1, 1, 0, 0, 0, 0, 0, 16, 0x2c, 0, 8, 0, 0, SUBSEG_LIT},
+ {"$MILLICODE$", 1, 1, 0, 0, 0, 0, 0, 8, 0x2c, 0, 8, 0, 0, SUBSEG_MILLI},
+ {"$BSS$", 1, 1, 0, 0, 0, 0, 1, 80, 0x1f, 1, 8, 1, 1, SUBSEG_BSS},
+ {NULL, 0, 1, 0, 0, 0, 0, 0, 255, 0x1f, 0, 4, 0, 0, 0}
};
static struct default_space_dict pa_def_spaces[] =
@@ -7454,7 +7457,7 @@ pa_subspace (create_new)
int create_new;
{
char *name, *ss_name, c;
- char loadable, code_only, common, dup_common, zero, sort;
+ char loadable, code_only, comdat, common, dup_common, zero, sort;
int i, access, space_index, alignment, quadrant, applicable, flags;
sd_chain_struct *space;
ssd_chain_struct *ssd;
@@ -7480,6 +7483,7 @@ pa_subspace (create_new)
sort = 0;
access = 0x7f;
loadable = 1;
+ comdat = 0;
common = 0;
dup_common = 0;
code_only = 0;
@@ -7514,6 +7518,7 @@ pa_subspace (create_new)
if (strcasecmp (pa_def_subspaces[i].name, ss_name) == 0)
{
loadable = pa_def_subspaces[i].loadable;
+ comdat = pa_def_subspaces[i].comdat;
common = pa_def_subspaces[i].common;
dup_common = pa_def_subspaces[i].dup_common;
code_only = pa_def_subspaces[i].code_only;
@@ -7577,6 +7582,11 @@ pa_subspace (create_new)
*input_line_pointer = c;
loadable = 0;
}
+ else if ((strncasecmp (name, "comdat", 6) == 0))
+ {
+ *input_line_pointer = c;
+ comdat = 1;
+ }
else if ((strncasecmp (name, "common", 6) == 0))
{
*input_line_pointer = c;
@@ -7609,8 +7619,17 @@ pa_subspace (create_new)
flags |= (SEC_ALLOC | SEC_LOAD);
if (code_only)
flags |= SEC_CODE;
- if (common || dup_common)
- flags |= SEC_IS_COMMON;
+
+ /* These flags are used to implement various flavors of initialized
+ common. The SOM linker discards duplicate subspaces when they
+ have the same "key" symbol name. This support is more like
+ GNU linkonce than BFD common. Further, pc-relative relocations
+ are converted to section relative relocations in BFD common
+ sections. This complicates the handling of relocations in
+ common sections containing text and isn't currently supported
+ correctly in the SOM BFD backend. */
+ if (comdat || common || dup_common)
+ flags |= SEC_LINK_ONCE;
flags |= SEC_RELOC | SEC_HAS_CONTENTS;
@@ -7652,16 +7671,16 @@ pa_subspace (create_new)
if (ssd)
current_subspace = update_subspace (space, ss_name, loadable,
- code_only, common, dup_common,
- sort, zero, access, space_index,
- alignment, quadrant,
+ code_only, comdat, common,
+ dup_common, sort, zero, access,
+ space_index, alignment, quadrant,
section);
else
current_subspace = create_new_subspace (space, ss_name, loadable,
- code_only, common,
+ code_only, comdat, common,
dup_common, zero, sort,
access, space_index,
- alignment, quadrant, section);
+ alignment, quadrant, section);
demand_empty_rest_of_line ();
current_subspace->ssd_seg = section;
@@ -7782,6 +7801,7 @@ pa_spaces_begin ()
create_new_subspace (space, name,
pa_def_subspaces[i].loadable,
pa_def_subspaces[i].code_only,
+ pa_def_subspaces[i].comdat,
pa_def_subspaces[i].common,
pa_def_subspaces[i].dup_common,
pa_def_subspaces[i].zero,
@@ -7883,12 +7903,12 @@ create_new_space (name, spnum, loadable, defined, private,
order as defined by the SORT entries. */
static ssd_chain_struct *
-create_new_subspace (space, name, loadable, code_only, common,
+create_new_subspace (space, name, loadable, code_only, comdat, common,
dup_common, is_zero, sort, access, space_index,
alignment, quadrant, seg)
sd_chain_struct *space;
char *name;
- int loadable, code_only, common, dup_common, is_zero;
+ int loadable, code_only, comdat, common, dup_common, is_zero;
int sort;
int access;
int space_index;
@@ -7945,8 +7965,8 @@ create_new_subspace (space, name, loadable, code_only, common,
}
#ifdef obj_set_subsection_attributes
- obj_set_subsection_attributes (seg, space->sd_seg, access,
- sort, quadrant);
+ obj_set_subsection_attributes (seg, space->sd_seg, access, sort,
+ quadrant, comdat, common, dup_common);
#endif
return chain_entry;
@@ -7956,12 +7976,13 @@ create_new_subspace (space, name, loadable, code_only, common,
various arguments. Return the modified subspace chain entry. */
static ssd_chain_struct *
-update_subspace (space, name, loadable, code_only, common, dup_common, sort,
- zero, access, space_index, alignment, quadrant, section)
+update_subspace (space, name, loadable, code_only, comdat, common, dup_common,
+ sort, zero, access, space_index, alignment, quadrant, section)
sd_chain_struct *space;
char *name;
int loadable;
int code_only;
+ int comdat;
int common;
int dup_common;
int zero;
@@ -7977,8 +7998,8 @@ update_subspace (space, name, loadable, code_only, common, dup_common, sort,
chain_entry = is_defined_subspace (name);
#ifdef obj_set_subsection_attributes
- obj_set_subsection_attributes (section, space->sd_seg, access,
- sort, quadrant);
+ obj_set_subsection_attributes (section, space->sd_seg, access, sort,
+ quadrant, comdat, common, dup_common);
#endif
return chain_entry;
diff --git a/gas/doc/c-hppa.texi b/gas/doc/c-hppa.texi
index 7e9ea30..9970188 100644
--- a/gas/doc/c-hppa.texi
+++ b/gas/doc/c-hppa.texi
@@ -245,14 +245,51 @@ identified by keywords. The keywords recognized are @samp{quad=@var{expr}}
beginning of this subsection; a power of two), @samp{access=@var{expr}} (value
for ``access rights'' field), @samp{sort=@var{expr}} (sorting order for this
subspace in link), @samp{code_only} (subsection contains only code),
-@samp{unloadable} (subsection cannot be loaded into memory), @samp{common}
-(subsection is common block), @samp{dup_comm} (initialized data may have
-duplicate names), or @samp{zero} (subsection is all zeros, do not write in
-object file).
+@samp{unloadable} (subsection cannot be loaded into memory), @samp{comdat}
+(subsection is comdat), @samp{common} (subsection is common block),
+@samp{dup_comm} (subsection may have duplicate names), or @samp{zero}
+(subsection is all zeros, do not write in object file).
@code{.nsubspa} always creates a new subspace with the given name, even
if one with the same name already exists.
+@samp{comdat}, @samp{common} and @samp{dup_comm} can be used to implement
+various flavors of one-only support when using the SOM linker. The SOM
+linker only supports specific combinations of these flags. The details
+are not documented. A brief description is provided here.
+
+@samp{comdat} provides a form of linkonce support. It is useful for
+both code and data subspaces. A @samp{comdat} subspace has a key symbol
+marked by the @samp{is_comdat} flag or @samp{ST_COMDAT}. Only the first
+subspace for any given key is selected. The key symbol becomes universal
+in shared links. This is similar to the behavior of @samp{secondary_def}
+symbols.
+
+@samp{common} provides Fortran named common support. It is only useful
+for data subspaces. Symbols with the flag @samp{is_common} retain this
+flag in shared links. Referencing a @samp{is_common} symbol in a shared
+library from outside the library doesn't work. Thus, @samp{is_common}
+symbols must be output whenever they are needed.
+
+@samp{common} and @samp{dup_comm} together provide Cobol common support.
+The subspaces in this case must all be the same length. Otherwise, this
+support is similar to the Fortran common support.
+
+@samp{dup_comm} by itself provides a type of one-only support for code.
+Only the first @samp{dup_comm} subspace is selected. There is a rather
+complex algorithm to compare subspaces. Code symbols marked with the
+@samp{dup_common} flag are hidden. This support was intended for "C++
+duplicate inlines".
+
+A simplified technique is used to mark the flags of symbols based on
+the flags of their subspace. A symbol with the scope SS_UNIVERSAL and
+type ST_ENTRY, ST_CODE or ST_DATA is marked with the corresponding
+settings of @samp{comdat}, @samp{common} and @samp{dup_comm} from the
+subspace, respectively. This avoids having to introduce additional
+directives to mark these symbols. The HP assembler sets @samp{is_common}
+from @samp{common}. However, it doesn't set the @samp{dup_common} from
+@samp{dup_comm}. It doesn't have @samp{comdat} support.
+
@item .version "@var{str}"
Write @var{str} as version identifier in object code.
@end table