This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
coff section flags: STYP_COPY, in particular, for TI COFF files
- From: John E Hein <jhein at timing dot com>
- To: binutils at sources dot redhat dot com
- Date: Fri, 4 Apr 2003 17:48:45 -0700
- Subject: coff section flags: STYP_COPY, in particular, for TI COFF files
I am looking into supporting the TMS320C6x
(c6x-tools.sourceforge.net), and I've found that the COFF files
generated by TI's compiler (Code Composer Studio) include some
sections flagged by STYP_COPY.
This is not handled in bfd/coffcode.h
Sections flagged by STYP_COPY are to be relocated and loaded, but not
allocated. For instance, there's a .vers section that has section
flags 0x50 (STYP_COPY | STYP_DATA). binutils marks these with
SEC_LOAD & SEC_ALLOC (loaded & allocated).
In recent TI tools (CCS 2.20), there's another section ($BRID) which
has the same problem.
Note that the c54x support that is now included in binutils has the
same flaw.
There are also problems with STYP_DSECT (not handled by binutils in
sec_to_styp_flags()) and also with STYP_PAD (should be loaded, but not
marked by binutils with SEC_LOAD). But I haven't seen a COFF file
generated by the TI tools that have the STYP_DSECT nor STYP_PAD flags
set (yet).
Attached is a patch. Comments?
--- coffcode.h.orig Fri Apr 4 17:41:35 2003
+++ coffcode.h Fri Apr 4 17:43:41 2003
@@ -644,8 +644,10 @@
sec_flags |= SEC_DEBUGGING;
#endif
}
+ else if ((styp_flags & STYP_PAD) && (sec_flags & SEC_NEVER_LOAD))
+ sec_flags = 0;
else if (styp_flags & STYP_PAD)
- sec_flags = 0;
+ sec_flags = SEC_LOAD;
else if (strcmp (name, _TEXT) == 0)
{
if (sec_flags & SEC_NEVER_LOAD)
@@ -702,6 +704,9 @@
if (styp_flags & STYP_OTHER_LOAD)
sec_flags = (SEC_LOAD | SEC_ALLOC);
#endif /* STYP_SDATA */
+
+ if (styp_flags & (STYP_COPY | STYP_DSECT))
+ sec_flags &= ~SEC_ALLOC);
#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE)
/* As a GNU extension, if the name begins with .gnu.linkonce, we