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]
Other format: [Raw text]

[Patch] gas/obj-coff.c : Make 'r' section flag mean readonly _data_


Hello,

gas (in BFD_ASSEMBLER case) does not interpret the 'r' flag correctly 
The comment before config/obj-coff.c (obj_coff_section [BEF_ASSEMBLER])
explicitly says that "r" means read-only data 

But this:

// rdata.s
.globl _foo
	.section .rdata$foo,"r"
_foo:
	.long	1


currently does this:

as rdata.s
objdump -h a.out

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000000  00000000  00000000  00000000  2**4
                  ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00000000  00000000  00000000  2**4
                  ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000000  2**4
                  ALLOC
  3 .rdata$foo    00000004  00000000  00000000  000000b4  2**2
                  CONTENTS, READONLY


I believe the correct section flags shoud be:

  3 .rdata$foo    00000004  00000000  00000000  000000b4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

That is, the same as .data, but marked as readonly.
( = TC_COFF_SECTION_DEFAULT_ATTRIBUTES | READONLY).


The following patch fixes the flags.  (Yes, I see the default alignment
difference too) 

Tested on mingw32.

2003-10-02  Danny Smith  <dannysmith.users.sourceforge.net>

	* config/obj-coff.c (obj_coff_section [BEF_ASSEMBLER]):
	Make 'r' mean readonly data.

Index: config/obj-coff.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-coff.c,v
retrieving revision 1.67
diff -c -3 -p -r1.67 obj-coff.c
*** config/obj-coff.c	12 Dec 2002 22:46:47 -0000	1.67
--- config/obj-coff.c	2 Oct 2003 09:39:53 -0000
*************** obj_coff_section (ignore)
*** 1474,1480 ****
  
  		case 'a': break; /* For compatability with ELF.  */
  		case 'x': flags |= SEC_CODE | SEC_LOAD; break;
! 		case 'r': flags |= SEC_READONLY; break;
  
  		case 'i': /* STYP_INFO */
  		case 'l': /* STYP_LIB */
--- 1474,1480 ----
  
  		case 'a': break; /* For compatability with ELF.  */
  		case 'x': flags |= SEC_CODE | SEC_LOAD; break;
! 		case 'r': flags |= SEC_DATA | SEC_LOAD | SEC_READONLY; break;
  
  		case 'i': /* STYP_INFO */
  		case 'l': /* STYP_LIB */

http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search


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