diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2003-01-01 10:00:39 +0000 |
---|---|---|
committer | Danny Smith <dannysmith@users.sourceforge.net> | 2003-01-01 10:00:39 +0000 |
commit | 353549d7441a2a8fddb4467ee796445e9db30abc (patch) | |
tree | 4c2254b36f5ec6fc0e890f471027fc0be694d6be /winsup/mingw/pseudo-reloc.c | |
parent | 4f66b246ba438eae815dc0e8ec0887f064b09aab (diff) | |
download | cygnal-353549d7441a2a8fddb4467ee796445e9db30abc.tar.gz cygnal-353549d7441a2a8fddb4467ee796445e9db30abc.tar.bz2 cygnal-353549d7441a2a8fddb4467ee796445e9db30abc.zip |
2003-01-01 Danny Smith <dannysmith@users.sourceforge.net>
* pseudo-reloc.c (do_pseudo_reloc): Make static.
* pseudo-reloc-list.c: New file.
* crt1.c (_pei386_runtime_relocator): Declare.
(__mingw_CRTStartup): Call it.
* dllcrt1.c (_pei386_runtime_relocator): Declare.
(DllMainCRTStartup): Call it.
* Makefile.in: Add pseudo-reloc.o pseude-reloc-list.o to
libmingw32.a.
2003-01-01 Egor Duda <deo@logos-m.ru>
* pseudo-reloc.c: New file.
Diffstat (limited to 'winsup/mingw/pseudo-reloc.c')
-rw-r--r-- | winsup/mingw/pseudo-reloc.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/winsup/mingw/pseudo-reloc.c b/winsup/mingw/pseudo-reloc.c new file mode 100644 index 000000000..9fe607d2c --- /dev/null +++ b/winsup/mingw/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; + +static 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__); +} |