Minor fix to COFF .section change

Mark E. snowball3@bigfoot.com
Sat Jul 1 18:39:00 GMT 2000


Hi guys,
Looks like I found one more reason to post. It turns out SEC_LOAD may not be so good as 
a default. For example, ".section .eh_frame" according to objdump:

ehframe.s:

.section .eh_frame

  3 .eh_frame     00000000  00000000  00000000  00000000  2**2
                  ALLOC, LOAD, CODE

Ouch. Not only does this cause crashes when throwing a C++ exception if the default is 
treated as code, but it's contrary to my reading of the .section docs. I didn't think 
SEC_LOAD by itself would add SEC_ALLOC and SEC_CODE, but looking at styp_to_sec_flags 
and sec_to_styp_flags reveals this to be true. I believe the right thing to do is make 
the default so that SEC_CODE can't be added and guarantee that the section is writable 
according to the docs.

2000-07-01  Mark Elbrecht  <snowball3@bigfoot.com>

	* config/obj-coff.c (obj_coff_section) [BFD_ASSEMBLER]: Make the
	  default section flags 'SEC_LOAD | SEC_DATA' to prevent the section
	  from mistakenly being marked as code when output.

Index: src/gas/config/obj-coff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.c,v
retrieving revision 1.26
diff -c -p -r1.26 obj-coff.c
*** obj-coff.c	2000/06/29 23:54:13	1.26
--- obj-coff.c	2000/07/02 01:26:05
*************** obj_coff_section (ignore)
*** 1426,1432 ****
        /* Set section flags for a new section just created by subseg_new.
           Provide a default if no flags were parsed.  */
        if (flags == SEC_NO_FLAGS)
!         flags = SEC_LOAD;
            
  #ifdef COFF_LONG_SECTION_NAMES
        /* Add SEC_LINK_ONCE and SEC_LINK_DUPLICATES_DISCARD to .gnu.linkonce
--- 1426,1432 ----
        /* Set section flags for a new section just created by subseg_new.
           Provide a default if no flags were parsed.  */
        if (flags == SEC_NO_FLAGS)
!         flags = SEC_LOAD | SEC_DATA;
            
  #ifdef COFF_LONG_SECTION_NAMES
        /* Add SEC_LINK_ONCE and SEC_LINK_DUPLICATES_DISCARD to .gnu.linkonce



More information about the Binutils mailing list