This is the mail archive of the cygwin-developers mailing list for the Cygwin 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]

Re: CFA: pseudo-reloc v2

Dave Korn wrote:
> Charles Wilson wrote:
>>   120 void
>>   121 _pei386_runtime_relocator ()
>>   122 {
>>   123   static int was_init = 0;
>>   124   if (was_init)
>>   125     return;
>>   126   ++was_init;
>>   127   do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&_image_base__);
>>   128 }
>   Maybe that static should be NO_COPY?  If everything gets remapped in the
> forkee, do the relocs need rerunning?  (I'm not sure about the behaviour of
> NtCreateProcess w.r.t modified .text section pages.)

Good guess!  With the following patch, all of these fork tests perform
as expected.  One oddity; it turns out that __INSIDE_CYGWIN__ is not
defined inside pseudo-reloc.c, so I used __CYGWIN__ as a guard.
Alternatively, I could have done something like:

#ifdef __CYGWIN__
# include "winsup.h"

and then (a) __INSIDE_CYGWIN__ would be defined, and (b) I could use
winsup.h's NO_COPY macro, instead of duplicating it. But I'm not sure
that's really what we want to do, for pseudo-reloc.  Since the code is
linked to client DLLs and EXEs, it really is /not/ 'inside' cygwin, is it?

Anyway, I think we now have proof-of-concept working code. All that's
left are stylistic things, like the above consideration, and the two
issues I raised in my earlier message.

Comments, anyone?


This patch assumes you've already copied winsup/mingw/pseudo-reloc.c to

--- winsup/mingw/pseudo-reloc.c	2009-03-17 09:18:08.463300000 -0400
+++ winsup/cygwin/lib/pseudo-reloc.c	2009-10-03 23:46:51.681400000 -0400
@@ -20,6 +20,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#if defined(__CYGWIN__)
+/* copied from winsup.h */
+# define NO_COPY __attribute__((nocommon))
+# define NO_COPY

  extern char __RUNTIME_PSEUDO_RELOC_LIST__;
@@ -170,7 +177,7 @@
  _pei386_runtime_relocator ()
-  static int was_init = 0;
+  static NO_COPY int was_init = 0;
   if (was_init)

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