mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-20 16:01:10 +08:00
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.
This commit is contained in:
parent
4f66b246ba
commit
353549d744
@ -1,3 +1,18 @@
|
||||
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.
|
||||
|
||||
2002-12-20 Earnie Boyd <earnie@users.sf.net>
|
||||
|
||||
* include/_mingw.h: Increment version to 2.4.
|
||||
|
@ -150,7 +150,8 @@ FLAGS_TO_PASS:=\
|
||||
CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \
|
||||
CRT_fp8.o CRT_fp10.o txtmode.o binmode.o
|
||||
MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \
|
||||
main.o crtst.o mthr_stub.o CRT_fp10.o txtmode.o
|
||||
main.o crtst.o mthr_stub.o CRT_fp10.o txtmode.o \
|
||||
pseudo-reloc.o pseudo-reloc-list.o
|
||||
MOLD_OBJS = ctype_old.o string_old.o
|
||||
|
||||
LIBS = libcrtdll.a libmsvcrt.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \
|
||||
@ -164,7 +165,9 @@ crt1.c crtdll.def crtmt.c crtst.c ctype_old.c dllcrt1.c dllmain.c \
|
||||
gccmain.c init.c install-sh jamfile main.c mkinstalldirs moldname-crtdll.def \
|
||||
moldname-msvcrt.def moldname.def moldname.def.in msvcrt.def msvcrt20.def \
|
||||
msvcrt40.def mthr.c mthr_init.c mthr_stub.c readme.txt string_old.c \
|
||||
CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c
|
||||
CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c pseudo-reloc.c \
|
||||
pseudo-reloc-list.c
|
||||
|
||||
|
||||
all_dlls_host = @all_dlls_host@
|
||||
install_dlls_host = @install_dlls_host@
|
||||
|
@ -47,6 +47,9 @@
|
||||
* a-good-idea use of include. */
|
||||
#include "init.c"
|
||||
|
||||
|
||||
extern void _pei386_runtime_relocator (void);
|
||||
|
||||
extern int main (int, char **, char **);
|
||||
|
||||
/*
|
||||
@ -203,6 +206,10 @@ __mingw_CRTStartup ()
|
||||
*/
|
||||
_mingw32_init_fmode ();
|
||||
|
||||
|
||||
/* Adust references to dllimported data that have non-zero offsets. */
|
||||
_pei386_runtime_relocator ();
|
||||
|
||||
/*
|
||||
* Call the main function. If the user does not supply one
|
||||
* the one in the 'libmingw32.a' library will be linked in, and
|
||||
|
@ -54,6 +54,7 @@ p_atexit_fn __dllonexit (p_atexit_fn, p_atexit_fn**, p_atexit_fn**);
|
||||
|
||||
extern BOOL WINAPI DllMain (HANDLE, DWORD, LPVOID);
|
||||
|
||||
extern void _pei386_runtime_relocator (void);
|
||||
|
||||
BOOL WINAPI
|
||||
DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
@ -62,6 +63,11 @@ DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("%s: DLL_PROCESS_ATTACH (%d)\n", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
/* Initialize private atexit table for this dll.
|
||||
32 is min size required by ANSI */
|
||||
|
||||
@ -74,11 +80,10 @@ DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
*first_atexit = NULL;
|
||||
next_atexit = first_atexit;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("%s: DLL_PROCESS_ATTACH (%d)\n", __FUNCTION__);
|
||||
#endif
|
||||
/* Adust references to dllimported data (from other DLL's)
|
||||
that have non-zero offsets. */
|
||||
_pei386_runtime_relocator ();
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* From libgcc.a, __main calls global class constructors,
|
||||
__do_global_ctors, which registers __do_global_dtors
|
||||
|
3
winsup/mingw/pseudo-reloc-list.c
Normal file
3
winsup/mingw/pseudo-reloc-list.c
Normal file
@ -0,0 +1,3 @@
|
||||
/* Define here in .bss in case not defined by linker script. */
|
||||
char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0;
|
||||
char __RUNTIME_PSEUDO_RELOC_LIST__ = 0;
|
46
winsup/mingw/pseudo-reloc.c
Normal file
46
winsup/mingw/pseudo-reloc.c
Normal file
@ -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__);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user