public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mumit Khan <khan@xraylith.wisc.EDU>
To: binutils@sourceware.cygnus.com
Subject: (patch) pe-coff shared section flag
Date: Fri, 06 Aug 1999 23:47:00 -0000	[thread overview]
Message-ID: <199908070537.AAA16135@mercury.xraylith.wisc.edu> (raw)

pe-coff has a facility for sharing data among executables/DLLs via
shared segments. This patch allows a named section to be sharable
by adding a 's' flag to the existing set of section flags. 

Patch against 1999-07-21 snapshot, but should apply cleanly against
the current tree. I did try the current CVS, but it produces
executables that windows refuses to run, with or without my
change (I'd like to blame Donn Terry, but probably need some evidence 
first ;-).

GCC of course needs to be update to allow for this, and the patch
is on its way.
  
  int __attribute__((section("my_shared_data"),shared) foo = 0;

will put foo in a named section called "my_share_data" and make it 
shareable among all running copies of the executable.

bfd/ChangeLog:

Fri Aug  6 23:41:35 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* section.c (SEC_SHARED): Define.
	* bfd-in2.h: Rebuild.
	* bfd/coffcode.h (sec_to_styp_flags): Handle SEC_SHARED. 
	(styp_to_sec_flags): Likewise.
	* peicode.h (coff_swap_scnhdr_out): Likewise.

gas/ChangeLog:
Fri Aug  6 23:44:22 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* config/obj-coff.c (obj_coff_section): Handle 's' (shared) section 
	flag.

Index: bfd/section.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/section.c,v
retrieving revision 1.5
diff -u -3 -p -r1.5 section.c
--- bfd/section.c	1999/07/11 19:49:43	1.5
+++ bfd/section.c	1999/08/07 06:37:21
@@ -311,6 +311,9 @@ CODE_FRAGMENT
 .	   "near" the GP.  *}
 .#define SEC_SHORT 0x2000000
 .
+.	{* This section contains "shared" data. Only used on PE-coff.  *}
+.#define SEC_SHARED 0x4000000
+.
 .	{*  End of section flags.  *}
 .
 .	{* Some internal packed boolean fields.  *}
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/bfd-in2.h,v
retrieving revision 1.14
diff -u -3 -p -r1.14 bfd-in2.h
--- bfd/bfd-in2.h	1999/07/19 14:55:15	1.14
+++ bfd/bfd-in2.h	1999/08/07 06:37:21
@@ -1008,6 +1008,9 @@ typedef struct sec
           "near" the GP.  */
 #define SEC_SHORT 0x2000000
 
+        /* This section contains "shared" data. Only used on PE-coff.  */
+#define SEC_SHARED 0x4000000
+
         /*  End of section flags.  */
 
         /* Some internal packed boolean fields.  */
Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coffcode.h,v
retrieving revision 1.7
diff -u -3 -p -r1.7 coffcode.h
--- bfd/coffcode.h	1999/07/19 14:55:15	1.7
+++ bfd/coffcode.h	1999/08/07 06:37:22
@@ -443,6 +443,8 @@ sec_to_styp_flags (sec_name, sec_flags)
 #ifdef COFF_WITH_PE
   if (sec_flags & SEC_LINK_ONCE)
     styp_flags |= IMAGE_SCN_LNK_COMDAT;
+  if (sec_flags & SEC_SHARED)
+    styp_flags |= IMAGE_SCN_MEM_SHARED;
 #endif
 
   return (styp_flags);
@@ -576,6 +578,9 @@ styp_to_sec_flags (abfd, hdr, name)
 #ifdef COFF_WITH_PE
   if (styp_flags & IMAGE_SCN_LNK_REMOVE)
     sec_flags |= SEC_EXCLUDE;
+
+  if (styp_flags & IMAGE_SCN_MEM_SHARED)
+    sec_flags |= SEC_SHARED;
 
   if (styp_flags & IMAGE_SCN_LNK_COMDAT)
     {
Index: bfd/peicode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/peicode.h,v
retrieving revision 1.6
diff -u -3 -p -r1.6 peicode.h
--- bfd/peicode.h	1999/07/12 10:29:58	1.6
+++ bfd/peicode.h	1999/08/07 06:37:22
@@ -1239,6 +1239,8 @@ coff_swap_scnhdr_out (abfd, in, out)
 	flags |= IMAGE_SCN_MEM_READ;
 	if (! (flags & SEC_READONLY))
 	  flags |= IMAGE_SCN_MEM_WRITE;
+	if (flags & SEC_SHARED)
+	  flags |= IMAGE_SCN_MEM_SHARED;
       }
 
     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.6
diff -u -3 -p -r1.6 obj-coff.c
--- gas/config/obj-coff.c	1999/06/26 19:35:44	1.6
+++ gas/config/obj-coff.c	1999/08/07 06:37:23
@@ -1193,6 +1193,7 @@ coff_frob_file_after_relocs ()
  *						 'd' (apparently m88k for data)
  *                                               'x' for text
  *						 'r' for read-only data
+ *						 's' for shared data (pe-coff)
  * But if the argument is not a quoted string, treat it as a
  * subsegment number.
  */
@@ -1250,6 +1251,7 @@ obj_coff_section (ignore)
 		case 'w': flags |= SEC_DATA; flags &=~ SEC_READONLY; break;
 		case 'x': flags |= SEC_CODE; break;
 		case 'r': flags |= SEC_READONLY; break;
+		case 's': flags |= SEC_SHARED; break;
 
 		case 'i': /* STYP_INFO */
 		case 'l': /* STYP_LIB */

Regards,
Mumit

                 reply	other threads:[~1999-08-06 23:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199908070537.AAA16135@mercury.xraylith.wisc.edu \
    --to=khan@xraylith.wisc.edu \
    --cc=binutils@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).