This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Possible Bug with "n" Flag of .section Directive
- To: Tracy dot Kuhrt at microchip dot com
- Subject: Re: Possible Bug with "n" Flag of .section Directive
- From: Nick Clifton <nickc at redhat dot com>
- Date: 21 Feb 2001 11:32:42 -0800
- Cc: binutils at sourceware dot cygnus dot com
- References: <OF9CBEFD12.59C2AACB-ON072569FA.0055F73A@microchip.com>
Hi Tracy,
> Given the following .section directive:
> .section foo_n, "n"
>
> The objdump output gives:
>
> foo_n.o: file format coff-sparc
>
> Sections:
> Idx Name Size VMA LMA File off Algn
> 0 .text 00000000 00000000 00000000 00000000 2**3
> ALLOC, LOAD, CODE
> 1 .data 00000000 00000000 00000000 00000000 2**3
> ALLOC, LOAD, DATA
> 2 .bss 00000000 00000000 00000000 00000000 2**3
> ALLOC
> 3 foo_n 00000000 00000000 00000000 00000000 2**3
> ALLOC, LOAD
>
> The documentation states that the "n" flag means that the section is not
> loaded. The assembler appears to be setting the section's flags correctly
> in the object file, but when objdump gets ahold of it, it changes the
> flags to be ALLOC, LOAD. It appears that this is happening in the
> function styp_to_sec_flags in coffgen.c. Is this a bug?
Actually I think that you will find that the assembler is setting the
ALLOC and LOAD bits and that objdump is in fact displaying the correct
information.
The reason for this behavior is that the "n" flag removes an
attribute from the section, rather than setting an attribute. The
code in the assembler that parses the .section pseudo op
(obj_coff_section in gas/config/obj-coff.c) starts by setting all the
section flags to zero and then parsing each of the flags in turn. If
no flags were set by the .section directive, then the default
attributes are used instead. In this case the default flags are ALLOC
and LOAD. Since the "n" attribute doe not set a flag, but removes
it, the code thinks that no attributes have been set and so the
defaults are used.
The solution is to use the "b" attribute instead of the "n"
attribute. This will give you an ALLOC'able section which is not
LOAD'able, which is presumably what you want.
Cheers
Nick