aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2000-06-29 23:54:13 +0000
committerNick Clifton <nickc@redhat.com>2000-06-29 23:54:13 +0000
commitc99004323dc703af7de076ed14936983a5651520 (patch)
treeb23a80725fdac138ae7d48c80e3e1bc039e74736
parentfbe1e41fe2fe57e6a0aebac9d3e5f4906ec74985 (diff)
downloadgdb-c99004323dc703af7de076ed14936983a5651520.zip
gdb-c99004323dc703af7de076ed14936983a5651520.tar.gz
gdb-c99004323dc703af7de076ed14936983a5651520.tar.bz2
Do not change an existing section's attributes if a flags argument isn't
present. Warn if the new attributes don't match the section's current attributes.
-rw-r--r--gas/ChangeLog9
-rw-r--r--gas/config/obj-coff.c41
2 files changed, 38 insertions, 12 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index c5d81da..67f4b61 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2000-06-29 Mark Elbrecht <snowball3@bigfoot.com>
+
+ * config/obj-coff.c (obj_coff_setcion) [BFD_ASSEMBLER]: If the
+ flags argument is not present, don't change an existing section's
+ section's attributes. If the flags argument is present, warn if the
+ attributes don't match the section's current attributes. When
+ long section names are supported, set SEC_LINK_ONCE and
+ SEC_LINK_DUPLICATES_DISCARD for a new .gnu.linkonce section.
+
Thu Jun 29 21:30:00 2000 Hans-Peter Nilsson <hp@axis.com>
* config/obj-aout.c (obj_aout_type): Do not ignore for undefined
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 9b73dcd..6557aa3 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -652,7 +652,7 @@ static void
obj_coff_endef (ignore)
int ignore ATTRIBUTE_UNUSED;
{
- symbolS *symbolP;
+ symbolS *symbolP = NULL;
/* DIM BUG FIX sac@cygnus.com */
dim_index = 0;
@@ -1353,7 +1353,7 @@ obj_coff_section (ignore)
char c;
char *name;
unsigned int exp;
- flagword flags;
+ flagword flags, oldflags;
asection *sec;
if (flag_mri)
@@ -1375,7 +1375,7 @@ obj_coff_section (ignore)
SKIP_WHITESPACE ();
exp = 0;
- flags = SEC_LOAD;
+ flags = SEC_NO_FLAGS;
if (*input_line_pointer == ',')
{
@@ -1420,18 +1420,35 @@ obj_coff_section (ignore)
sec = subseg_new (name, (subsegT) exp);
- if (flags != SEC_NO_FLAGS)
+ oldflags = bfd_get_section_flags (stdoutput, sec);
+ if (oldflags == SEC_NO_FLAGS)
{
- flagword oldflags;
-
- oldflags = bfd_get_section_flags (stdoutput, sec);
- oldflags &= SEC_LINK_ONCE | SEC_LINK_DUPLICATES;
- flags |= oldflags;
+ /* Set section flags for a new section just created by subseg_new.
+ Provide a default if no flags were parsed. */
+ if (flags == SEC_NO_FLAGS)
+ flags = SEC_LOAD;
+
+#ifdef COFF_LONG_SECTION_NAMES
+ /* Add SEC_LINK_ONCE and SEC_LINK_DUPLICATES_DISCARD to .gnu.linkonce
+ sections so adjust_reloc_syms in write.c will correctly handle
+ relocs which refer to non-local symbols in these sections. */
+ if (strncmp (name, ".gnu.linkonce", sizeof(".gnu.linkonce") - 1) == 0)
+ flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
+#endif
if (! bfd_set_section_flags (stdoutput, sec, flags))
- as_warn (_("error setting flags for \"%s\": %s"),
- bfd_section_name (stdoutput, sec),
- bfd_errmsg (bfd_get_error ()));
+ as_warn (_("error setting flags for \"%s\": %s"),
+ bfd_section_name (stdoutput, sec),
+ bfd_errmsg (bfd_get_error ()));
+ }
+ else if (flags != SEC_NO_FLAGS)
+ {
+ /* This section's attributes have already been set. Warn if the
+ attributes don't match. */
+ flagword matchflags = SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
+ | SEC_DATA | SEC_SHARED;
+ if ((flags ^ oldflags) & matchflags)
+ as_warn (_("Ignoring changed section attributes for %s"), name);
}
demand_empty_rest_of_line ();