[RFA] Coff SEC_LOAD vs SEC_NEVER_LOAD

Svein E. Seldal Svein.Seldal@solidas.com
Fri May 30 14:08:00 GMT 2003


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.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: noload-fix.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20030530/fbaf2984/attachment.ksh>


More information about the Binutils mailing list