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