This is the mail archive of the binutils@sourceware.cygnus.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]

patch for i386-pe section header [Re: section bug?]


SONE Takeshi <ts1@cma.co.jp> writes:
> In Cygwin32 and Mingw32 environment with binutils 2.9.4, this code
> crashes:
> 
> int a __attribute__((section("mysec"))) = 0;
> main()
> {
> 	a = 1;
> }
> 
> gcc looks doing right thing:
> 
> .section	mysec,"w"
> 	.align 4
> _a:
> 	.long 0
> 
> I run dumpbin.exe (from MS) on the output and it says that mysec in the
> .o file is marked Read Only, and in the .exe file it is marked Code and
> Read Only.

The following should fix this bug. 

Sat Jun 26 18:25:30 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* peicode.h (coff_swap_scnhdr_out): Mark user-defined writable 
	sections as writable.

Index: bfd/peicode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/peicode.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 peicode.h
--- bfd/peicode.h	1999/05/25 11:37:40	1.3
+++ bfd/peicode.h	1999/06/26 23:22:14
@@ -1234,6 +1234,8 @@ coff_swap_scnhdr_out (abfd, in, out)
 		| IMAGE_SCN_MEM_SHARED | IMAGE_SCN_MEM_READ);
     else if (strcmp (scnhdr_int->s_name, ".rsrc")  == 0)
       flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_SHARED;
+    else if (! (flags & SEC_READONLY))
+      flags |= IMAGE_SCN_MEM_WRITE;
     else
       flags |= IMAGE_SCN_MEM_READ;
 
Regards,
Mumit


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