* section bug?
@ 1999-07-01 0:00 SONE Takeshi
1999-07-01 0:00 ` patch for i386-pe section header [Re: section bug?] Mumit Khan
0 siblings, 1 reply; 5+ messages in thread
From: SONE Takeshi @ 1999-07-01 0:00 UTC (permalink / raw)
To: egcs; +Cc: binutils
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.
--
SONE Takeshi ^[$B$=$M^[(B ^[$B$?$1$7^[(B
mailto:ts1@cma.co.jp Office Craftsman Arts
http://www.cma.co.jp/~ts1/
^ permalink raw reply [flat|nested] 5+ messages in thread
* patch for i386-pe section header [Re: section bug?]
1999-07-01 0:00 section bug? SONE Takeshi
@ 1999-07-01 0:00 ` Mumit Khan
1999-07-01 0:00 ` Ian Lance Taylor
0 siblings, 1 reply; 5+ messages in thread
From: Mumit Khan @ 1999-07-01 0:00 UTC (permalink / raw)
To: SONE Takeshi; +Cc: binutils
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch for i386-pe section header [Re: section bug?]
1999-07-01 0:00 ` patch for i386-pe section header [Re: section bug?] Mumit Khan
@ 1999-07-01 0:00 ` Ian Lance Taylor
1999-07-01 0:00 ` Mumit Khan
1999-07-01 0:00 ` Mumit Khan
0 siblings, 2 replies; 5+ messages in thread
From: Ian Lance Taylor @ 1999-07-01 0:00 UTC (permalink / raw)
To: khan; +Cc: ts1, binutils
Date: Sat, 26 Jun 1999 18:31:14 -0500
From: Mumit Khan <khan@xraylith.wisc.EDU>
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;
In the second new line, shouldn't that be
flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE
?
I would almost just check that in, but I thought I'd better check to
see if I was missing something.
Ian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch for i386-pe section header [Re: section bug?]
1999-07-01 0:00 ` Ian Lance Taylor
@ 1999-07-01 0:00 ` Mumit Khan
1999-07-01 0:00 ` Mumit Khan
1 sibling, 0 replies; 5+ messages in thread
From: Mumit Khan @ 1999-07-01 0:00 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: ts1, binutils
On 26 Jun 1999, Ian Lance Taylor wrote:
>
> In the second new line, shouldn't that be
> flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE
> ?
>
> I would almost just check that in, but I thought I'd better check to
> see if I was missing something.
For correctness yes, but never noticed it since NT doesn't seem to care.
Btw, I'm just about to fix a few other section attribute things in the
same routine, so let's wait till I send an update. It'll also give me
time to run the testsuite + test W9x, where something always goes wrong.
Regards,
Mumit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch for i386-pe section header [Re: section bug?]
1999-07-01 0:00 ` Ian Lance Taylor
1999-07-01 0:00 ` Mumit Khan
@ 1999-07-01 0:00 ` Mumit Khan
1 sibling, 0 replies; 5+ messages in thread
From: Mumit Khan @ 1999-07-01 0:00 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: ts1, binutils
Ian Lance Taylor <ian@zembu.com> writes:
>
> In the second new line, shouldn't that be
> flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE
> ?
>
> I would almost just check that in, but I thought I'd better check to
> see if I was missing something.
>
And I also forgot to diff the whole tree. Damn. Now it's tested on both
NT and W9x.
bfd/ChangeLog:
Sat Jun 26 21:09:44 1999 Mumit Khan <khan@xraylith.wisc.edu>
* peicode.h (coff_swap_scnhdr_out): Mark user-defined writable
sections as writable.
gas/ChangeLog:
Sat Jun 26 21:09:44 1999 Mumit Khan <khan@xraylith.wisc.edu>
* config/obj-coff.c (obj_coff_section): Mark writable sections
as data.
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/27 02:08:58
@@ -1235,7 +1235,11 @@ coff_swap_scnhdr_out (abfd, in, out)
else if (strcmp (scnhdr_int->s_name, ".rsrc") == 0)
flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_SHARED;
else
- flags |= IMAGE_SCN_MEM_READ;
+ {
+ flags |= IMAGE_SCN_MEM_READ;
+ if (! (flags & SEC_READONLY))
+ flags |= IMAGE_SCN_MEM_WRITE;
+ }
bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
}
Index: gas/config/obj-coff.c
===================================================================
RCS file: /cvs/binutils/binutils/gas/config/obj-coff.c,v
retrieving revision 1.5
diff -u -3 -p -r1.5 obj-coff.c
--- gas/config/obj-coff.c 1999/06/19 14:04:44 1.5
+++ gas/config/obj-coff.c 1999/06/27 02:08:59
@@ -1247,7 +1247,7 @@ obj_coff_section (ignore)
case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
case 'n': flags &=~ SEC_LOAD; break;
case 'd':
- case 'w': flags &=~ SEC_READONLY; break;
+ case 'w': flags |= SEC_DATA; flags &=~ SEC_READONLY; break;
case 'x': flags |= SEC_CODE; break;
case 'r': flags |= SEC_READONLY; break;
Regards,
Mumit
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-07-01 0:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-01 0:00 section bug? SONE Takeshi
1999-07-01 0:00 ` patch for i386-pe section header [Re: section bug?] Mumit Khan
1999-07-01 0:00 ` Ian Lance Taylor
1999-07-01 0:00 ` Mumit Khan
1999-07-01 0:00 ` Mumit Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).