xref: /titanic_41/usr/src/cmd/sgs/include/rtc.h (revision c13de8f6a88563211bd4432ca11ca38ed3bf0fc0)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*c13de8f6Sab196087  * Common Development and Distribution License (the "License").
6*c13de8f6Sab196087  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*c13de8f6Sab196087  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_RTC_H
277c478bd9Sstevel@tonic-gate #define	_RTC_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Global include file for the runtime configuration support.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate #include <time.h>
357c478bd9Sstevel@tonic-gate #include <machdep.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
42*c13de8f6Sab196087  * Linker configuration files are designed to be mapped into memory
43*c13de8f6Sab196087  * and accessed directly. Hence, the layout of the data must follow
44*c13de8f6Sab196087  * byte order and alignment rules for the program examining it.
45*c13de8f6Sab196087  *
46*c13de8f6Sab196087  * From its initial design through the release of Solaris 10, runtime
47*c13de8f6Sab196087  * linker configuration files started with a configuration header (Rtc_head).
48*c13de8f6Sab196087  * The role of Rtc_head is to provide a table of contents to the remainder
49*c13de8f6Sab196087  * of the file. It tells what information is contained in the file,
50*c13de8f6Sab196087  * and the offset (relative to the base of the Rtc_head structure)
51*c13de8f6Sab196087  * within the file at which each item can be found. These offsets are
52*c13de8f6Sab196087  * 32-bit values. Linker configuration files are 32-bit limited, even
53*c13de8f6Sab196087  * for 64-bit platforms.
54*c13de8f6Sab196087  *
55*c13de8f6Sab196087  * It should be noted that Rtc_head contains no information that can be
56*c13de8f6Sab196087  * used to identify the type of program that created the file (byte order,
57*c13de8f6Sab196087  * elf class, and machine architecture). This leads to some difficulties:
58*c13de8f6Sab196087  *	- Interpreting a config file using a program with the opposite
59*c13de8f6Sab196087  *	  byte order can crash the program.
60*c13de8f6Sab196087  *	- Structure layout differences can cause a 64-bit version of the
61*c13de8f6Sab196087  *	  program to fail to read a 32-bit config file correctly, or
62*c13de8f6Sab196087  *	  vice versa. This was not an issue on sparc (both 32 and 64-bit
63*c13de8f6Sab196087  *	  happen to lay out the same way). However, 32 and 64-bit X86
64*c13de8f6Sab196087  *	  have differing alignment rules.
65*c13de8f6Sab196087  *	- The file command cannot easily identify a linker configuration
66*c13de8f6Sab196087  *	  file, and simply reports them as "data".
67*c13de8f6Sab196087  * Initially, the design of of these files assumed that a given file
68*c13de8f6Sab196087  * would be readable by any system. Experience shows that this is wrong.
69*c13de8f6Sab196087  * A linker config file is ABI specific, much like an object file. It should
70*c13de8f6Sab196087  * only be interpreted by a compatible program.
71*c13de8f6Sab196087  *
72*c13de8f6Sab196087  * Linker configuration files now start with an Rtc_id structure, followed
73*c13de8f6Sab196087  * immediately by Rtc_head. Rtc_id provides the information necessary to
74*c13de8f6Sab196087  * detect the type of program that wrote the file, in a manner that allows
75*c13de8f6Sab196087  * backwards compatibility with pre-existing config files:
76*c13de8f6Sab196087  *	- We can detect an old config file, because they do not start
77*c13de8f6Sab196087  *	  with the characters "\077RLC". In this case, we assume the
78*c13de8f6Sab196087  *	  file is compatible with the program interpreting it, and that
79*c13de8f6Sab196087  *	  Rtc_head is the first thing in the file.
80*c13de8f6Sab196087  *	- Solaris 10 and older will refuse to handle a config
81*c13de8f6Sab196087  *	  file that has an Rtc_id, because they will interpret
82*c13de8f6Sab196087  *	  the "\077RLC" signature as the ch_version field of Rtc_head,
83*c13de8f6Sab196087  *	  and will reject the version as being invalid.
84*c13de8f6Sab196087  *	- Rtc_id is specified such that its size will be 16 bytes
85*c13de8f6Sab196087  *	  on all systems, sufficient to align Rtc_head on any system, and
86*c13de8f6Sab196087  *	  to provide future expansion room.
87*c13de8f6Sab196087  *	- Offsets to data in the file continue to be specified relative
88*c13de8f6Sab196087  *	  to the Rtc_head address, meaning that existing software will
89*c13de8f6Sab196087  *	  continue to work with little or no modification.
90*c13de8f6Sab196087  */
91*c13de8f6Sab196087 
92*c13de8f6Sab196087 /*
93*c13de8f6Sab196087  * Identification header.
94*c13de8f6Sab196087  *
95*c13de8f6Sab196087  * This is defined in usr/src/common/sgsrtcid/sgsrtcid.h
96*c13de8f6Sab196087  * so that file(1) can also access it.
97*c13de8f6Sab196087  */
98*c13de8f6Sab196087 #include <sgsrtcid.h>
99*c13de8f6Sab196087 
100*c13de8f6Sab196087 /*
1017c478bd9Sstevel@tonic-gate  * Configuration header.
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate typedef struct {
1047c478bd9Sstevel@tonic-gate 	Word	ch_version;		/* version of config file */
1057c478bd9Sstevel@tonic-gate 	Word	ch_cnflags;		/* configuration flags */
1067c478bd9Sstevel@tonic-gate 	Word	ch_dlflags;		/* dldump() flags used */
1077c478bd9Sstevel@tonic-gate 	Word	ch_app;			/* application that this config file */
1087c478bd9Sstevel@tonic-gate 					/*	is specific to */
1097c478bd9Sstevel@tonic-gate 	Word	ch_hash;		/* hash table offset */
1107c478bd9Sstevel@tonic-gate 	Word	ch_obj;			/* object table offset */
1117c478bd9Sstevel@tonic-gate 	Word	ch_str;			/* string table offset */
1127c478bd9Sstevel@tonic-gate 	Word	ch_file;		/* file entries */
1137c478bd9Sstevel@tonic-gate 	Word	ch_dir;			/* directory entries */
1147c478bd9Sstevel@tonic-gate 	Word	ch_edlibpath;		/* ELF default library path offset */
1157c478bd9Sstevel@tonic-gate 	Word	ch_adlibpath;		/* AOUT default library path offset */
1167c478bd9Sstevel@tonic-gate 	Word	ch_eslibpath;		/* ELF secure library path offset */
1177c478bd9Sstevel@tonic-gate 	Word	ch_aslibpath;		/* AOUT secure library path offset */
1187c478bd9Sstevel@tonic-gate 	Lword	ch_resbgn;		/* memory reservation required to map */
1197c478bd9Sstevel@tonic-gate 	Lword	ch_resend;		/*	alternative objects defined */
1207c478bd9Sstevel@tonic-gate 					/*	by the configuration info */
1217c478bd9Sstevel@tonic-gate 	Word	ch_env;			/* environment variables */
1227c478bd9Sstevel@tonic-gate 	Word	ch_fltr;		/* filter table entries */
1237c478bd9Sstevel@tonic-gate 	Word	ch_flte;		/* filtee table entries */
1247c478bd9Sstevel@tonic-gate } Rtc_head;
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate #define	RTC_HDR_IGNORE	0x0001		/* ignore config information */
1277c478bd9Sstevel@tonic-gate #define	RTC_HDR_ALTER	0x0002		/* alternative objects are defined - */
1287c478bd9Sstevel@tonic-gate 					/*	these may exist without a */
1297c478bd9Sstevel@tonic-gate 					/*	memory reservation (see -a) */
1307c478bd9Sstevel@tonic-gate #define	RTC_HDR_64	0x0004		/* 64-bit objects used */
1317c478bd9Sstevel@tonic-gate #define	RTC_HDR_UPM	0x0008		/* includes unified process model */
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate /*
1347c478bd9Sstevel@tonic-gate  * Object descriptor.
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate typedef struct {
1377c478bd9Sstevel@tonic-gate 	Lword	co_info;		/* validation information */
1387c478bd9Sstevel@tonic-gate 	Word	co_name;		/* object name (directory or file) */
1397c478bd9Sstevel@tonic-gate 	Word	co_hash;		/* name hash value */
1407c478bd9Sstevel@tonic-gate 	Half	co_id;			/* directory identifier */
1417c478bd9Sstevel@tonic-gate 	Half	co_flags;		/* various flags */
1427c478bd9Sstevel@tonic-gate 	Word	co_alter;		/* alternative object file */
1437c478bd9Sstevel@tonic-gate } Rtc_obj;
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #define	RTC_OBJ_DIRENT	0x0001		/* object defines a directory */
1467c478bd9Sstevel@tonic-gate #define	RTC_OBJ_ALLENTS	0x0002		/* directory was scanned for all */
1477c478bd9Sstevel@tonic-gate 					/*	containing objects */
1487c478bd9Sstevel@tonic-gate #define	RTC_OBJ_NOEXIST	0x0004		/* object does not exist */
1497c478bd9Sstevel@tonic-gate #define	RTC_OBJ_EXEC	0x0008		/* object identifies executable */
1507c478bd9Sstevel@tonic-gate #define	RTC_OBJ_ALTER	0x0010		/* object has an alternate */
1517c478bd9Sstevel@tonic-gate #define	RTC_OBJ_DUMP	0x0020		/* alternate created by dldump(3x) */
1527c478bd9Sstevel@tonic-gate #define	RTC_OBJ_REALPTH	0x0040		/* object identifies real path */
1537c478bd9Sstevel@tonic-gate #define	RTC_OBJ_NOALTER	0x0080		/* object can't have an alternate */
1547c478bd9Sstevel@tonic-gate #define	RTC_OBJ_GROUP	0x0100		/* object was expanded as a group */
1557c478bd9Sstevel@tonic-gate #define	RTC_OBJ_APP	0x0200		/* object indicates app which makes */
1567c478bd9Sstevel@tonic-gate 					/*	configuration file specific */
1577c478bd9Sstevel@tonic-gate #define	RTC_OBJ_CMDLINE	0x0400		/* object specified from command line */
1587c478bd9Sstevel@tonic-gate #define	RTC_OBJ_FILTER	0x0800		/* object identifies a filter */
1597c478bd9Sstevel@tonic-gate #define	RTC_OBJ_FILTEE	0x1000		/* object identifies a filtee */
1607c478bd9Sstevel@tonic-gate #define	RTC_OBJ_OPTINAL	0x2000		/* object alternative is optional */
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /*
1637c478bd9Sstevel@tonic-gate  * Directory and file descriptors.  The configuration cache (cd_dir) points to
1647c478bd9Sstevel@tonic-gate  * an array of directory descriptors, this in turn point to their associated
1657c478bd9Sstevel@tonic-gate  * arrays of file descriptors.  Both of these provide sequential access for
1667c478bd9Sstevel@tonic-gate  * configuration file validation (directory, and possible file stat()'s).
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate typedef struct {
1697c478bd9Sstevel@tonic-gate 	Word	cd_obj;			/* index to Rtc_obj */
1707c478bd9Sstevel@tonic-gate 	Word	cd_file;		/* index to Rtc_file[] */
1717c478bd9Sstevel@tonic-gate } Rtc_dir;
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate typedef	struct {
1747c478bd9Sstevel@tonic-gate 	Word	cf_obj;			/* index to Rtc_obj */
1757c478bd9Sstevel@tonic-gate } Rtc_file;
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate #define	RTC_VER_NONE	0
1797c478bd9Sstevel@tonic-gate #define	RTC_VER_ONE	1		/* original version */
1807c478bd9Sstevel@tonic-gate #define	RTC_VER_TWO	2		/* updated for -u use */
1817c478bd9Sstevel@tonic-gate #define	RTC_VER_THREE	3		/* updated for -e/-E use */
1827c478bd9Sstevel@tonic-gate #define	RTC_VER_FOUR	4		/* updated for filter/filtees */
1837c478bd9Sstevel@tonic-gate #define	RTC_VER_CURRENT RTC_VER_FOUR
1847c478bd9Sstevel@tonic-gate #define	RTC_VER_NUM	5
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate /*
1877c478bd9Sstevel@tonic-gate  * Environment variable descriptor.  The configuration cache (ch_env) points to
1887c478bd9Sstevel@tonic-gate  * an array of these descriptors.
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate typedef struct {
1917c478bd9Sstevel@tonic-gate 	Word	env_str;		/* index into string table */
1927c478bd9Sstevel@tonic-gate 	Word	env_flags;		/* various flags */
1937c478bd9Sstevel@tonic-gate } Rtc_env;
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #define	RTC_ENV_REPLACE	0x0001		/* replaceable string definition */
1967c478bd9Sstevel@tonic-gate #define	RTC_ENV_PERMANT	0x0002		/* permanent string definition */
1977c478bd9Sstevel@tonic-gate #define	RTC_ENV_CONFIG	0x1000		/* string originates from config file */
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate /*
2007c478bd9Sstevel@tonic-gate  * Filter descriptor.  The configuration cache (ch_flt) points to an array of
2017c478bd9Sstevel@tonic-gate  * these descriptors.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate typedef struct {
2047c478bd9Sstevel@tonic-gate 	Word	fr_filter;		/* filter name, and filtee string */
2057c478bd9Sstevel@tonic-gate 	Word	fr_string;		/*	as indexs into string table */
2067c478bd9Sstevel@tonic-gate 	Word	fr_filtee;		/* index into filtee array */
2077c478bd9Sstevel@tonic-gate } Rtc_fltr;
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate typedef struct {
2107c478bd9Sstevel@tonic-gate 	Word	fe_filtee;
2117c478bd9Sstevel@tonic-gate } Rtc_flte;
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2147c478bd9Sstevel@tonic-gate }
2157c478bd9Sstevel@tonic-gate #endif
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate #endif	/* _RTC_H */
218