From b862c4219812f85712f7c7ea521c1c6cf4bcc198 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 9 Dec 2002 22:49:12 +0000 Subject: * lib/pseudo-reloc.c: New file. * lib/_cygwin_crt0_common.cc: Perform pseudo-relocs during initialization of cygwin binary (.exe or .dll). --- winsup/cygwin/lib/pseudo-reloc.c | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 winsup/cygwin/lib/pseudo-reloc.c (limited to 'winsup/cygwin/lib/pseudo-reloc.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 + 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 + +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__); +} -- cgit v1.2.3