xref: /illumos-gate/usr/src/cmd/sgs/include/rtc.h (revision 7ae111d47a973fff4c6e231cc31f271dd9cef473)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_RTC_H
27 #define	_RTC_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Global include file for the runtime configuration support.
33  */
34 #include <time.h>
35 #include <machdep.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Linker configuration files are designed to be mapped into memory
43  * and accessed directly. Hence, the layout of the data must follow
44  * byte order and alignment rules for the program examining it.
45  *
46  * From its initial design through the release of Solaris 10, runtime
47  * linker configuration files started with a configuration header (Rtc_head).
48  * The role of Rtc_head is to provide a table of contents to the remainder
49  * of the file. It tells what information is contained in the file,
50  * and the offset (relative to the base of the Rtc_head structure)
51  * within the file at which each item can be found. These offsets are
52  * 32-bit values. Linker configuration files are 32-bit limited, even
53  * for 64-bit platforms.
54  *
55  * It should be noted that Rtc_head contains no information that can be
56  * used to identify the type of program that created the file (byte order,
57  * elf class, and machine architecture). This leads to some difficulties:
58  *	- Interpreting a config file using a program with the opposite
59  *	  byte order can crash the program.
60  *	- Structure layout differences can cause a 64-bit version of the
61  *	  program to fail to read a 32-bit config file correctly, or
62  *	  vice versa. This was not an issue on sparc (both 32 and 64-bit
63  *	  happen to lay out the same way). However, 32 and 64-bit X86
64  *	  have differing alignment rules.
65  *	- The file command cannot easily identify a linker configuration
66  *	  file, and simply reports them as "data".
67  * Initially, the design of of these files assumed that a given file
68  * would be readable by any system. Experience shows that this is wrong.
69  * A linker config file is ABI specific, much like an object file. It should
70  * only be interpreted by a compatible program.
71  *
72  * Linker configuration files now start with an Rtc_id structure, followed
73  * immediately by Rtc_head. Rtc_id provides the information necessary to
74  * detect the type of program that wrote the file, in a manner that allows
75  * backwards compatibility with pre-existing config files:
76  *	- We can detect an old config file, because they do not start
77  *	  with the characters "\077RLC". In this case, we assume the
78  *	  file is compatible with the program interpreting it, and that
79  *	  Rtc_head is the first thing in the file.
80  *	- Solaris 10 and older will refuse to handle a config
81  *	  file that has an Rtc_id, because they will interpret
82  *	  the "\077RLC" signature as the ch_version field of Rtc_head,
83  *	  and will reject the version as being invalid.
84  *	- Rtc_id is specified such that its size will be 16 bytes
85  *	  on all systems, sufficient to align Rtc_head on any system, and
86  *	  to provide future expansion room.
87  *	- Offsets to data in the file continue to be specified relative
88  *	  to the Rtc_head address, meaning that existing software will
89  *	  continue to work with little or no modification.
90  */
91 
92 /*
93  * Identification header.
94  *
95  * This is defined in usr/src/common/sgsrtcid/sgsrtcid.h
96  * so that file(1) can also access it.
97  */
98 #include <sgsrtcid.h>
99 
100 /*
101  * Configuration header.
102  */
103 typedef struct {
104 	Word	ch_version;		/* version of config file */
105 	Word	ch_cnflags;		/* configuration flags */
106 	Word	ch_dlflags;		/* dldump() flags used */
107 	Word	ch_app;			/* application that this config file */
108 					/*	is specific to */
109 	Word	ch_hash;		/* hash table offset */
110 	Word	ch_obj;			/* object table offset */
111 	Word	ch_str;			/* string table offset */
112 	Word	ch_file;		/* file entries */
113 	Word	ch_dir;			/* directory entries */
114 	Word	ch_edlibpath;		/* ELF default library path offset */
115 	Word	ch_adlibpath;		/* AOUT default library path offset */
116 	Word	ch_eslibpath;		/* ELF secure library path offset */
117 	Word	ch_aslibpath;		/* AOUT secure library path offset */
118 	Lword	ch_resbgn;		/* memory reservation required to map */
119 	Lword	ch_resend;		/*	alternative objects defined */
120 					/*	by the configuration info */
121 	Word	ch_env;			/* environment variables */
122 	Word	ch_fltr;		/* filter table entries */
123 	Word	ch_flte;		/* filtee table entries */
124 } Rtc_head;
125 
126 #define	RTC_HDR_IGNORE	0x0001		/* ignore config information */
127 #define	RTC_HDR_ALTER	0x0002		/* alternative objects are defined - */
128 					/*	these may exist without a */
129 					/*	memory reservation (see -a) */
130 #define	RTC_HDR_64	0x0004		/* 64-bit objects used */
131 #define	RTC_HDR_UPM	0x0008		/* includes unified process model */
132 
133 /*
134  * Object descriptor.
135  */
136 typedef struct {
137 	Lword	co_info;		/* validation information */
138 	Word	co_name;		/* object name (directory or file) */
139 	Word	co_hash;		/* name hash value */
140 	Half	co_id;			/* directory identifier */
141 	Half	co_flags;		/* various flags */
142 	Word	co_alter;		/* alternative object file */
143 } Rtc_obj;
144 
145 #define	RTC_OBJ_DIRENT	0x0001		/* object defines a directory */
146 #define	RTC_OBJ_ALLENTS	0x0002		/* directory was scanned for all */
147 					/*	containing objects */
148 #define	RTC_OBJ_NOEXIST	0x0004		/* object does not exist */
149 #define	RTC_OBJ_EXEC	0x0008		/* object identifies executable */
150 #define	RTC_OBJ_ALTER	0x0010		/* object has an alternate */
151 #define	RTC_OBJ_DUMP	0x0020		/* alternate created by dldump(3x) */
152 #define	RTC_OBJ_REALPTH	0x0040		/* object identifies real path */
153 #define	RTC_OBJ_NOALTER	0x0080		/* object can't have an alternate */
154 #define	RTC_OBJ_GROUP	0x0100		/* object was expanded as a group */
155 #define	RTC_OBJ_APP	0x0200		/* object indicates app which makes */
156 					/*	configuration file specific */
157 #define	RTC_OBJ_CMDLINE	0x0400		/* object specified from command line */
158 #define	RTC_OBJ_FILTER	0x0800		/* object identifies a filter */
159 #define	RTC_OBJ_FILTEE	0x1000		/* object identifies a filtee */
160 #define	RTC_OBJ_OPTINAL	0x2000		/* object alternative is optional */
161 
162 /*
163  * Directory and file descriptors.  The configuration cache (cd_dir) points to
164  * an array of directory descriptors, this in turn point to their associated
165  * arrays of file descriptors.  Both of these provide sequential access for
166  * configuration file validation (directory, and possible file stat()'s).
167  */
168 typedef struct {
169 	Word	cd_obj;			/* index to Rtc_obj */
170 	Word	cd_file;		/* index to Rtc_file[] */
171 } Rtc_dir;
172 
173 typedef	struct {
174 	Word	cf_obj;			/* index to Rtc_obj */
175 } Rtc_file;
176 
177 
178 #define	RTC_VER_NONE	0
179 #define	RTC_VER_ONE	1		/* original version */
180 #define	RTC_VER_TWO	2		/* updated for -u use */
181 #define	RTC_VER_THREE	3		/* updated for -e/-E use */
182 #define	RTC_VER_FOUR	4		/* updated for filter/filtees */
183 #define	RTC_VER_CURRENT RTC_VER_FOUR
184 #define	RTC_VER_NUM	5
185 
186 /*
187  * Environment variable descriptor.  The configuration cache (ch_env) points to
188  * an array of these descriptors.
189  */
190 typedef struct {
191 	Word	env_str;		/* index into string table */
192 	Word	env_flags;		/* various flags */
193 } Rtc_env;
194 
195 #define	RTC_ENV_REPLACE	0x0001		/* replaceable string definition */
196 #define	RTC_ENV_PERMANT	0x0002		/* permanent string definition */
197 #define	RTC_ENV_CONFIG	0x1000		/* string originates from config file */
198 
199 /*
200  * Filter descriptor.  The configuration cache (ch_flt) points to an array of
201  * these descriptors.
202  */
203 typedef struct {
204 	Word	fr_filter;		/* filter name, and filtee string */
205 	Word	fr_string;		/*	as indexs into string table */
206 	Word	fr_filtee;		/* index into filtee array */
207 } Rtc_fltr;
208 
209 typedef struct {
210 	Word	fe_filtee;
211 } Rtc_flte;
212 
213 #ifdef	__cplusplus
214 }
215 #endif
216 
217 #endif	/* _RTC_H */
218