This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Possible Bug with "n" Flag of .section Directive


> Duh!  Yes you are right.  The code for the non-COFF_WITH_PE version is
> rather messy, but my guess at an (*untested*) patch would be:
Messy is right. But your patch made no difference, so I started looking 
deeper into the problem and came up with a patch.

I used a simple file with:
.section .foo_n, "n"

.section .foo_dn, "dn"

and objdump now reports:
  3 .foo_n        00000000  00000000  00000000  00000000  2**2
                  ALLOC, LOAD, NEVER_LOAD
  4 .foo_dn       00000000  00000000  00000000  00000000  2**2
                  DATA, NEVER_LOAD

'.foo_dn' looks ok to me now, but DJGPP doesn't use the 'n' flag so I can't 
be absolutely sure. And I believe 'n' isn't supposed to be used alone, so I 
didn't try to fix that case.

Index: src/gas/config/obj-coff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.c,v
retrieving revision 1.40
diff -c -p -r1.40 obj-coff.c
*** obj-coff.c	2001/02/11 23:22:25	1.40
--- obj-coff.c	2001/02/22 20:32:01
*************** obj_coff_section (ignore)
*** 1434,1440 ****
  	      switch (*input_line_pointer)
  		{
  		case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
! 		case 'n': flags &=~ SEC_LOAD; break;
  		case 'd': flags |= SEC_DATA | SEC_LOAD; /* fall through */
  		case 'w': flags &=~ SEC_READONLY; break;
  		case 'x': flags |= SEC_CODE | SEC_LOAD; break;
--- 1434,1440 ----
  	      switch (*input_line_pointer)
  		{
  		case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
! 		case 'n': flags &=~ SEC_LOAD; flags |= SEC_NEVER_LOAD; break;
  		case 'd': flags |= SEC_DATA | SEC_LOAD; /* fall through */
  		case 'w': flags &=~ SEC_READONLY; break;
  		case 'x': flags |= SEC_CODE | SEC_LOAD; break;
*************** obj_coff_section (ignore)
*** 1488,1494 ****
        /* 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);
      }
--- 1488,1494 ----
        /* 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 | SEC_NEVER_LOAD;
        if ((flags ^ oldflags) & matchflags)
  	as_warn (_("Ignoring changed section attributes for %s"), name);
      }

And just in case I got it right:
2001-02-22  Mark Elbrecht  <snowball3@bigfoot.com>

	* config/obj-coff.c [BFD_ASSEMBLER] (obj_coff_section): Set
	  SEC_NEVER_LOAD when the 'n' flag is used.
	  Add SEC_NEVER_LOAD to matchflags.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]