[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared Libs



ekl%beastie@SDF.LONESTAR.ORG wrote:

> 	struct _lib_stdio {
> 		void *	basepage;   /* set by lib. start-up code */
> 		char *  filename;   /* fixed in header file */
> 		char *  module;     /* fixed in header file */
> 		void *	data_block; /* set at run-time */
> 	}
[ ... ]
> Once the _dispatch function sets up for the call, it executes a trap,
> such as trap # 3 or something currently unused.  The trap executes code
> that is responsible for finding the proper function using the information
> from the structure and a set of hash tables.

Searching for the proper function would be faster if the module structure
were to include a module number for `well known' modules:
  
struct shared_module {
	void *		basepage;
 	char *		filename;
 	char *		module;
 	u_int32_t	modno;
 	void *		data_block;
}

Since the module numbers have to be uniq, this requires registration of
modules (allthough the same aplies to module names!). The number zero
could be used for unregistered modules, for which the trap code would
have to use the (hopefully uniq) name of the module. Module number one
could be taken by the really basic stuff, like errno and environ (these
must be implemented as functions, can't use global vars).

The main problem I see with your approach in general, is speed. It's
very inefficient to trap for each library function call. It might be
more efficient if the apllications start-up code traps exactly once
for each module that the application is going to need. The trap code
makes sure the modules are loaded, and returns a jumptable.


Waldi