xref: /illumos-gate/usr/src/cmd/sgs/rtld/common/cache_a.out.h (revision 0ccfe5834c3b867c1b6c273cae02ec8922bc0fd2)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	Copyright (c) 1998 by Sun Microsystems, Inc.
24  */
25 #ifndef	_CACHE_DOT_H
26 #define	_CACHE_DOT_H
27 
28 /*
29  * ld.so directory caching
30  */
31 #include	<sys/types.h>
32 
33 /*
34  * Shared object lookup performance in the run-time link editor is
35  * enhanced through the use of caches for directories that the editor
36  * searches.  A given "cache" describes the contents of a single directory,
37  * and each cache entry contains the canonical name for a shared object
38  * as well as its absolute pathname.
39  *
40  * Within a cache, "pointers" are really relative addresses to some absolute
41  * address (often the base address of the containing database).
42  */
43 
44 /*
45  * Relative pointer macros.
46  */
47 #define	RELPTR(base, absptr) ((long)(absptr) - (long)(base))
48 #define	AP(base) ((caddr_t)base)
49 
50 /*
51  * Definitions for cache structures.
52  */
53 #define	DB_HASH		11		/* number of hash buckets in caches */
54 #define	LD_CACHE_MAGIC 	0x041155	/* cookie to identify data structure */
55 #define	LD_CACHE_VERSION 0		/* version number of cache structure */
56 
57 struct	dbe	{			/* element of a directory cache */
58 	long	dbe_next;		/* (rp) next element on this list */
59 	long	dbe_lop;		/* (rp) canonical name for object */
60 	long	dbe_name;		/* (rp) absolute name */
61 };
62 
63 struct	db	{			/* directory cache database */
64 	long	db_name;		/* (rp) directory contained here */
65 	struct	dbe db_hash[DB_HASH];	/* hash buckets */
66 	caddr_t	db_chain;		/* private to database mapping */
67 };
68 
69 struct dbf 	{			/* cache file image */
70 	long dbf_magic;			/* identifying cookie */
71 	long dbf_version;		/* version no. of these dbs */
72 	long dbf_machtype;		/* machine type */
73 	long dbf_db;		/* directory cache dbs */
74 };
75 
76 /*
77  * Structures used to describe and access a database.
78  */
79 struct	dbd	{			/* data base descriptor */
80 	struct	dbd *dbd_next;		/* next one on this list */
81 	struct	db *dbd_db;		/* data base described by this */
82 };
83 
84 struct	dd	{			/* directory descriptor */
85 	struct	dd *dd_next;		/* next one on this list */
86 	struct	db *dd_db;		/* data base described by this */
87 };
88 
89 /*
90  * Interfaces imported/exported by the lookup code.
91  */
92 
93 char	*ask_db();			/* ask db for highest minor number */
94 struct	db *lo_cache();			/* obtain cache for directory name */
95 
96 #endif
97