From: nickc Date: Thu, 29 Jun 2000 23:54:12 +0000 (+0000) Subject: Do not change an existing section's attributes if a flags argument isn't X-Git-Tag: pre-cygwin-heap~850 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=8a3125465999b5f2642ad8490f79cd1f197bda51;p=pf3gnuchains%2Fpf3gnuchains4x.git 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. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index c5d81daae7..67f4b6135f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2000-06-29 Mark Elbrecht + + * 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 * 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 9b73dcd0cb..6557aa3704 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 ();