* Re: patch for COFF .section
@ 2000-06-29 21:55 Mark E.
0 siblings, 0 replies; 3+ messages in thread
From: Mark E. @ 2000-06-29 21:55 UTC (permalink / raw)
To: binutils
Thanks for checking it in.
I've studied the !BFD_ASSEMBLER version of obj_coff_section and it also
doesn't warn in not warning about changing attributes after they've already
been set, but with a twist. !bfd gas for DJGPP takes this:
.section .foo,"x"
.section .foo,"b"
.section .foo,"w"
and sets the section attributes for code, data, and bss.
The problem with fixing this is you can't tell the difference between a
section that was just created by subseg_new and an existing section that
happens to have the default flags.
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: patch for COFF .section
@ 2000-06-29 16:54 Nick Clifton
0 siblings, 0 replies; 3+ messages in thread
From: Nick Clifton @ 2000-06-29 16:54 UTC (permalink / raw)
To: snowball3; +Cc: binutils
Hi Mark,
: 2000-06-27 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.
Approved and applied.
Cheers
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* patch for COFF .section
@ 2000-06-27 12:54 Mark E.
0 siblings, 0 replies; 3+ messages in thread
From: Mark E. @ 2000-06-27 12:54 UTC (permalink / raw)
To: binutils
Hello again,
The BFD_ASSEMBLER version of obj_coff_section has some major flaws. If the .section
directive doesn't have a flags argument, the section's attributes are changed to
SEC_LOAD. And if the .section directive does have a flags argument, it always changes
the section's attributes, even if they've already been set. The patch below corrects
this by:
* not changing 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.
2000-06-27 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.
Index: src/gas/config/obj-coff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.c,v
retrieving revision 1.25
diff -c -p -r1.25 obj-coff.c
*** obj-coff.c 2000/06/17 22:00:30 1.25
--- obj-coff.c 2000/06/27 19:33:38
*************** obj_coff_section (ignore)
*** 1353,1359 ****
char c;
char *name;
unsigned int exp;
! flagword flags;
asection *sec;
if (flag_mri)
--- 1353,1359 ----
char c;
char *name;
unsigned int exp;
! flagword flags, oldflags;
asection *sec;
if (flag_mri)
*************** obj_coff_section (ignore)
*** 1375,1381 ****
SKIP_WHITESPACE ();
exp = 0;
! flags = SEC_LOAD;
if (*input_line_pointer == ',')
{
--- 1375,1381 ----
SKIP_WHITESPACE ();
exp = 0;
! flags = SEC_NO_FLAGS;
if (*input_line_pointer == ',')
{
*************** obj_coff_section (ignore)
*** 1420,1437 ****
sec = subseg_new (name, (subsegT) exp);
! if (flags != SEC_NO_FLAGS)
{
! flagword oldflags;
- oldflags = bfd_get_section_flags (stdoutput, sec);
- oldflags &= SEC_LINK_ONCE | SEC_LINK_DUPLICATES;
- flags |= oldflags;
-
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 ()));
}
demand_empty_rest_of_line ();
--- 1420,1456 ----
sec = subseg_new (name, (subsegT) exp);
! oldflags = bfd_get_section_flags (stdoutput, sec);
! if (oldflags == SEC_NO_FLAGS)
{
! /* 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 ()));
! }
! 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 ();
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-06-29 21:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-29 21:55 patch for COFF .section Mark E.
-- strict thread matches above, loose matches on Subject: below --
2000-06-29 16:54 Nick Clifton
2000-06-27 12:54 Mark E.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).