delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/04/15/13:22:55

From: sos AT buggy DOT prospect DOT com DOT ru (Sergey Okhapkin)
Subject: New import library format proposal.
15 Apr 1998 13:22:55 -0700 :
Message-ID: <01BD68CB.224726A0.cygnus.cygwin32.developers@sos>
To: "'cygwin32-developers AT cygnus DOT com'" <cygwin32-developers AT cygnus DOT com>

Hi!

I designed this import library format to speed-up process startup. No 
exports are linked statically, all dll symbols (except LoadLibrary() and 
GetProcAddres() in libkernel32.a) are resolved dynamically on demand. I 
hope this should speed-up the startup time of a process. Actual linking is 
performed only on the first call of dll-exported function, the next calls 
are a bit faster than in a current implementation (direct jump instead of 
indirect jump). Dll-exported datas should be accessed/imported in a old 
(current) way. Library files will have a smaller size than now. New format 
is compatible with old object files.

Every import library module have the following structure:

Library module 1:

	.data_cygwin_nocopy	// The section must not be copied on fork.
	.align 4
_entry1 AT N:				// Called function
	call do_call$dllname	// Call dynamic linker
	.asciz "entry1"		// Name of dll's export

Library module 2:

	.data_cygwin_nocopy
	.align 4
_entry2:
	call do_call$dllname
	.asciz "entry2"
.....

Main library module - dynamic linker (C-like pseudocode):

static NO_COPY HANDLE dll=NULL;

do_call$dllname()
{
	unsigned *ptr;
	FARPROC addr;

	.asm "pop ptr";	// pop return addr from stack, remember it in ptr.
				// ptr points now to required export name.
	if (dll == NULL)
		if ((dll = LoadLibrary("dllname.dll")) == NULL)
			exit process or raise an exception "DLL NOT FOUND";
	if ((addr = GetProcAddress(dll, ptr)) == NULL)
		exit process or raise an exeption "DLL ENTRY POINT NOT FOUND";
	ptr[-1] = addr; // Store entry address for next library calls
	ptr[-2] = jmp instruction opcode; // replace "call" instruction with "jmp"
	.asm "jmp addr" // Actual call to requested function
}

What do you think about? And... Do we need it?-)

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019