Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-12-10 01:49:12 +0300
committerChristopher Faylor <me@cgf.cx>2002-12-10 01:49:12 +0300
commitb862c4219812f85712f7c7ea521c1c6cf4bcc198 (patch)
treefc3940a53b2d70a49fcdfe2c87687bf818db00b0
parent97cc22ad0662edd32330fc6e3ab0b9dd82dada1e (diff)
* lib/pseudo-reloc.c: New file.
* lib/_cygwin_crt0_common.cc: Perform pseudo-relocs during initialization of cygwin binary (.exe or .dll).
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/lib/_cygwin_crt0_common.cc3
-rw-r--r--winsup/cygwin/lib/pseudo-reloc.c46
-rw-r--r--winsup/cygwin/pseudo-reloc.cc46
4 files changed, 101 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 607c92814..de7ab2b56 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2002-12-02 Egor Duda <deo@logos-m.ru>
+
+ * lib/pseudo-reloc.c: New file.
+ * lib/_cygwin_crt0_common.cc: Perform pseudo-relocs during
+ initialization of cygwin binary (.exe or .dll).
+
2002-12-06 Christopher Faylor <cgf@redhat.com>
* cygwin.din: Reflect name change from strtodf to strtof. Export
diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc
index e0a3e6052..565ba2571 100644
--- a/winsup/cygwin/lib/_cygwin_crt0_common.cc
+++ b/winsup/cygwin/lib/_cygwin_crt0_common.cc
@@ -26,6 +26,7 @@ int cygwin_attach_noncygwin_dll (HMODULE, MainFunc);
int main (int, char **, char **);
struct _reent *_impure_ptr;
int _fmode;
+void _pei386_runtime_relocator ();
/* Set up pointers to various pieces so the dll can then use them,
and then jump to the dll. */
@@ -94,6 +95,8 @@ _cygwin_crt0_common (MainFunc f, per_process *u)
u->data_end = &_data_end__;
u->bss_start = &_bss_start__;
u->bss_end = &_bss_end__;
+
+ _pei386_runtime_relocator ();
return 1;
}
} /* "C" */
diff --git a/winsup/cygwin/lib/pseudo-reloc.c b/winsup/cygwin/lib/pseudo-reloc.c
new file mode 100644
index 000000000..5760a69ad
--- /dev/null
+++ b/winsup/cygwin/lib/pseudo-reloc.c
@@ -0,0 +1,46 @@
+/* pseudo-reloc.c
+
+ Written by Egor Duda <deo@logos-m.ru>
+ THIS SOFTWARE IS NOT COPYRIGHTED
+
+ This source code is offered for use in the public domain. You may
+ use, modify or distribute it freely.
+
+ This code is distributed in the hope that it will be useful but
+ WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
+ DISCLAMED. This includes but is not limited to warrenties of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+#include <windows.h>
+
+extern char __RUNTIME_PSEUDO_RELOC_LIST__;
+extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
+extern char _image_base__;
+
+typedef struct
+ {
+ DWORD addend;
+ DWORD target;
+ }
+runtime_pseudo_reloc;
+
+void
+do_pseudo_reloc (void* start, void* end, void* base)
+{
+ DWORD reloc_target;
+ runtime_pseudo_reloc* r;
+ for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++)
+ {
+ reloc_target = (DWORD) base + r->target;
+ *((DWORD*) reloc_target) += r->addend;
+ }
+}
+
+void
+_pei386_runtime_relocator ()
+{
+ do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
+ &__RUNTIME_PSEUDO_RELOC_LIST_END__,
+ &_image_base__);
+}
diff --git a/winsup/cygwin/pseudo-reloc.cc b/winsup/cygwin/pseudo-reloc.cc
new file mode 100644
index 000000000..5760a69ad
--- /dev/null
+++ b/winsup/cygwin/pseudo-reloc.cc
@@ -0,0 +1,46 @@
+/* pseudo-reloc.c
+
+ Written by Egor Duda <deo@logos-m.ru>
+ THIS SOFTWARE IS NOT COPYRIGHTED
+
+ This source code is offered for use in the public domain. You may
+ use, modify or distribute it freely.
+
+ This code is distributed in the hope that it will be useful but
+ WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
+ DISCLAMED. This includes but is not limited to warrenties of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+#include <windows.h>
+
+extern char __RUNTIME_PSEUDO_RELOC_LIST__;
+extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
+extern char _image_base__;
+
+typedef struct
+ {
+ DWORD addend;
+ DWORD target;
+ }
+runtime_pseudo_reloc;
+
+void
+do_pseudo_reloc (void* start, void* end, void* base)
+{
+ DWORD reloc_target;
+ runtime_pseudo_reloc* r;
+ for (r = (runtime_pseudo_reloc*) start; r < (runtime_pseudo_reloc*) end; r++)
+ {
+ reloc_target = (DWORD) base + r->target;
+ *((DWORD*) reloc_target) += r->addend;
+ }
+}
+
+void
+_pei386_runtime_relocator ()
+{
+ do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
+ &__RUNTIME_PSEUDO_RELOC_LIST_END__,
+ &_image_base__);
+}