This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [RFA] Coff SEC_LOAD vs SEC_NEVER_LOAD
Ian Lance Taylor wrote:
I think I would recommend none of the above. If you can get
SEC_NEVER_LOAD to be set for your output section, then I would expect
STYP_NOLOAD to be set in the COFF file. Then there is some chance
that SEC_LOAD will not be set when gdb reads the file. If SEC_LOAD is
still set for a STYP_NOLOAD section, that might be a bug.
Well it is. Here's an objdump of a coff file that I manually have set
the STYP_NOLOAD flag:
0 .dummy 00000002 00809800 00809800 00000000 2**0
ALLOC, LOAD, NEVER_LOAD
Looking in coffcode.h i find this in styp_to_sec_flags():
#ifdef STYP_NOLOAD
if (styp_flags & STYP_NOLOAD)
sec_flags |= SEC_NEVER_LOAD;
#endif /* STYP_NOLOAD */
followed by this:
else
sec_flags |= SEC_ALLOC | SEC_LOAD;
Which confirms this obeservation. However, looking at the code, it
surely seems like this code isnt made this way by accident.
My suggested fix to the problem is attached. It does not apply to the
COFF_WITH_PE targets nor have I checked that that version has the same bug.
Regards,
Svein
bfd/ChangeLog:
2003-05-30 Svein E. Seldal <Svein.Seldal@solidas.com>
* coffcode.h (styp_to_sec_flags): Move the STYP_NOLOAD handling
to the bottom. STYP_NOLOAD now removes the SEC_LOAD flag instead
of using the SEC_NEVER_LOAD.
Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.90
diff -c -3 -p -r1.90 coffcode.h
*** bfd/coffcode.h 24 Apr 2003 12:36:06 -0000 1.90
--- bfd/coffcode.h 30 May 2003 12:26:31 -0000
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 602,612 ****
sec_flags |= SEC_CLINK;
#endif
- #ifdef STYP_NOLOAD
- if (styp_flags & STYP_NOLOAD)
- sec_flags |= SEC_NEVER_LOAD;
- #endif /* STYP_NOLOAD */
-
/* For 386 COFF, at least, an unloadable text or data section is
actually a shared library section. */
if (styp_flags & STYP_TEXT)
--- 602,607 ----
*************** styp_to_sec_flags (abfd, hdr, name, sect
*** 713,718 ****
--- 708,718 ----
if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0)
sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;
#endif
+
+ #ifdef STYP_NOLOAD
+ if (styp_flags & STYP_NOLOAD)
+ sec_flags &= ~SEC_LOAD;
+ #endif /* STYP_NOLOAD */
if (flags_ptr == NULL)
return FALSE;