xref: /onnv-gate/usr/src/cmd/sgs/include/rtc.h (revision 1976:f0691a145b7e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1976Sab196087  * Common Development and Distribution License (the "License").
6*1976Sab196087  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1976Sab196087  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_RTC_H
270Sstevel@tonic-gate #define	_RTC_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  * Global include file for the runtime configuration support.
330Sstevel@tonic-gate  */
340Sstevel@tonic-gate #include <time.h>
350Sstevel@tonic-gate #include <machdep.h>
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #ifdef	__cplusplus
380Sstevel@tonic-gate extern "C" {
390Sstevel@tonic-gate #endif
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
42*1976Sab196087  * Linker configuration files are designed to be mapped into memory
43*1976Sab196087  * and accessed directly. Hence, the layout of the data must follow
44*1976Sab196087  * byte order and alignment rules for the program examining it.
45*1976Sab196087  *
46*1976Sab196087  * From its initial design through the release of Solaris 10, runtime
47*1976Sab196087  * linker configuration files started with a configuration header (Rtc_head).
48*1976Sab196087  * The role of Rtc_head is to provide a table of contents to the remainder
49*1976Sab196087  * of the file. It tells what information is contained in the file,
50*1976Sab196087  * and the offset (relative to the base of the Rtc_head structure)
51*1976Sab196087  * within the file at which each item can be found. These offsets are
52*1976Sab196087  * 32-bit values. Linker configuration files are 32-bit limited, even
53*1976Sab196087  * for 64-bit platforms.
54*1976Sab196087  *
55*1976Sab196087  * It should be noted that Rtc_head contains no information that can be
56*1976Sab196087  * used to identify the type of program that created the file (byte order,
57*1976Sab196087  * elf class, and machine architecture). This leads to some difficulties:
58*1976Sab196087  *	- Interpreting a config file using a program with the opposite
59*1976Sab196087  *	  byte order can crash the program.
60*1976Sab196087  *	- Structure layout differences can cause a 64-bit version of the
61*1976Sab196087  *	  program to fail to read a 32-bit config file correctly, or
62*1976Sab196087  *	  vice versa. This was not an issue on sparc (both 32 and 64-bit
63*1976Sab196087  *	  happen to lay out the same way). However, 32 and 64-bit X86
64*1976Sab196087  *	  have differing alignment rules.
65*1976Sab196087  *	- The file command cannot easily identify a linker configuration
66*1976Sab196087  *	  file, and simply reports them as "data".
67*1976Sab196087  * Initially, the design of of these files assumed that a given file
68*1976Sab196087  * would be readable by any system. Experience shows that this is wrong.
69*1976Sab196087  * A linker config file is ABI specific, much like an object file. It should
70*1976Sab196087  * only be interpreted by a compatible program.
71*1976Sab196087  *
72*1976Sab196087  * Linker configuration files now start with an Rtc_id structure, followed
73*1976Sab196087  * immediately by Rtc_head. Rtc_id provides the information necessary to
74*1976Sab196087  * detect the type of program that wrote the file, in a manner that allows
75*1976Sab196087  * backwards compatibility with pre-existing config files:
76*1976Sab196087  *	- We can detect an old config file, because they do not start
77*1976Sab196087  *	  with the characters "\077RLC". In this case, we assume the
78*1976Sab196087  *	  file is compatible with the program interpreting it, and that
79*1976Sab196087  *	  Rtc_head is the first thing in the file.
80*1976Sab196087  *	- Solaris 10 and older will refuse to handle a config
81*1976Sab196087  *	  file that has an Rtc_id, because they will interpret
82*1976Sab196087  *	  the "\077RLC" signature as the ch_version field of Rtc_head,
83*1976Sab196087  *	  and will reject the version as being invalid.
84*1976Sab196087  *	- Rtc_id is specified such that its size will be 16 bytes
85*1976Sab196087  *	  on all systems, sufficient to align Rtc_head on any system, and
86*1976Sab196087  *	  to provide future expansion room.
87*1976Sab196087  *	- Offsets to data in the file continue to be specified relative
88*1976Sab196087  *	  to the Rtc_head address, meaning that existing software will
89*1976Sab196087  *	  continue to work with little or no modification.
90*1976Sab196087  */
91*1976Sab196087 
92*1976Sab196087 /*
93*1976Sab196087  * Identification header.
94*1976Sab196087  *
95*1976Sab196087  * This is defined in usr/src/common/sgsrtcid/sgsrtcid.h
96*1976Sab196087  * so that file(1) can also access it.
97*1976Sab196087  */
98*1976Sab196087 #include <sgsrtcid.h>
99*1976Sab196087 
100*1976Sab196087 /*
1010Sstevel@tonic-gate  * Configuration header.
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate typedef struct {
1040Sstevel@tonic-gate 	Word	ch_version;		/* version of config file */
1050Sstevel@tonic-gate 	Word	ch_cnflags;		/* configuration flags */
1060Sstevel@tonic-gate 	Word	ch_dlflags;		/* dldump() flags used */
1070Sstevel@tonic-gate 	Word	ch_app;			/* application that this config file */
1080Sstevel@tonic-gate 					/*	is specific to */
1090Sstevel@tonic-gate 	Word	ch_hash;		/* hash table offset */
1100Sstevel@tonic-gate 	Word	ch_obj;			/* object table offset */
1110Sstevel@tonic-gate 	Word	ch_str;			/* string table offset */
1120Sstevel@tonic-gate 	Word	ch_file;		/* file entries */
1130Sstevel@tonic-gate 	Word	ch_dir;			/* directory entries */
1140Sstevel@tonic-gate 	Word	ch_edlibpath;		/* ELF default library path offset */
1150Sstevel@tonic-gate 	Word	ch_adlibpath;		/* AOUT default library path offset */
1160Sstevel@tonic-gate 	Word	ch_eslibpath;		/* ELF secure library path offset */
1170Sstevel@tonic-gate 	Word	ch_aslibpath;		/* AOUT secure library path offset */
1180Sstevel@tonic-gate 	Lword	ch_resbgn;		/* memory reservation required to map */
1190Sstevel@tonic-gate 	Lword	ch_resend;		/*	alternative objects defined */
1200Sstevel@tonic-gate 					/*	by the configuration info */
1210Sstevel@tonic-gate 	Word	ch_env;			/* environment variables */
1220Sstevel@tonic-gate 	Word	ch_fltr;		/* filter table entries */
1230Sstevel@tonic-gate 	Word	ch_flte;		/* filtee table entries */
1240Sstevel@tonic-gate } Rtc_head;
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate #define	RTC_HDR_IGNORE	0x0001		/* ignore config information */
1270Sstevel@tonic-gate #define	RTC_HDR_ALTER	0x0002		/* alternative objects are defined - */
1280Sstevel@tonic-gate 					/*	these may exist without a */
1290Sstevel@tonic-gate 					/*	memory reservation (see -a) */
1300Sstevel@tonic-gate #define	RTC_HDR_64	0x0004		/* 64-bit objects used */
1310Sstevel@tonic-gate #define	RTC_HDR_UPM	0x0008		/* includes unified process model */
1320Sstevel@tonic-gate 
1330Sstevel@tonic-gate /*
1340Sstevel@tonic-gate  * Object descriptor.
1350Sstevel@tonic-gate  */
1360Sstevel@tonic-gate typedef struct {
1370Sstevel@tonic-gate 	Lword	co_info;		/* validation information */
1380Sstevel@tonic-gate 	Word	co_name;		/* object name (directory or file) */
1390Sstevel@tonic-gate 	Word	co_hash;		/* name hash value */
1400Sstevel@tonic-gate 	Half	co_id;			/* directory identifier */
1410Sstevel@tonic-gate 	Half	co_flags;		/* various flags */
1420Sstevel@tonic-gate 	Word	co_alter;		/* alternative object file */
1430Sstevel@tonic-gate } Rtc_obj;
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate #define	RTC_OBJ_DIRENT	0x0001		/* object defines a directory */
1460Sstevel@tonic-gate #define	RTC_OBJ_ALLENTS	0x0002		/* directory was scanned for all */
1470Sstevel@tonic-gate 					/*	containing objects */
1480Sstevel@tonic-gate #define	RTC_OBJ_NOEXIST	0x0004		/* object does not exist */
1490Sstevel@tonic-gate #define	RTC_OBJ_EXEC	0x0008		/* object identifies executable */
1500Sstevel@tonic-gate #define	RTC_OBJ_ALTER	0x0010		/* object has an alternate */
1510Sstevel@tonic-gate #define	RTC_OBJ_DUMP	0x0020		/* alternate created by dldump(3x) */
1520Sstevel@tonic-gate #define	RTC_OBJ_REALPTH	0x0040		/* object identifies real path */
1530Sstevel@tonic-gate #define	RTC_OBJ_NOALTER	0x0080		/* object can't have an alternate */
1540Sstevel@tonic-gate #define	RTC_OBJ_GROUP	0x0100		/* object was expanded as a group */
1550Sstevel@tonic-gate #define	RTC_OBJ_APP	0x0200		/* object indicates app which makes */
1560Sstevel@tonic-gate 					/*	configuration file specific */
1570Sstevel@tonic-gate #define	RTC_OBJ_CMDLINE	0x0400		/* object specified from command line */
1580Sstevel@tonic-gate #define	RTC_OBJ_FILTER	0x0800		/* object identifies a filter */
1590Sstevel@tonic-gate #define	RTC_OBJ_FILTEE	0x1000		/* object identifies a filtee */
1600Sstevel@tonic-gate #define	RTC_OBJ_OPTINAL	0x2000		/* object alternative is optional */
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate /*
1630Sstevel@tonic-gate  * Directory and file descriptors.  The configuration cache (cd_dir) points to
1640Sstevel@tonic-gate  * an array of directory descriptors, this in turn point to their associated
1650Sstevel@tonic-gate  * arrays of file descriptors.  Both of these provide sequential access for
1660Sstevel@tonic-gate  * configuration file validation (directory, and possible file stat()'s).
1670Sstevel@tonic-gate  */
1680Sstevel@tonic-gate typedef struct {
1690Sstevel@tonic-gate 	Word	cd_obj;			/* index to Rtc_obj */
1700Sstevel@tonic-gate 	Word	cd_file;		/* index to Rtc_file[] */
1710Sstevel@tonic-gate } Rtc_dir;
1720Sstevel@tonic-gate 
1730Sstevel@tonic-gate typedef	struct {
1740Sstevel@tonic-gate 	Word	cf_obj;			/* index to Rtc_obj */
1750Sstevel@tonic-gate } Rtc_file;
1760Sstevel@tonic-gate 
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate #define	RTC_VER_NONE	0
1790Sstevel@tonic-gate #define	RTC_VER_ONE	1		/* original version */
1800Sstevel@tonic-gate #define	RTC_VER_TWO	2		/* updated for -u use */
1810Sstevel@tonic-gate #define	RTC_VER_THREE	3		/* updated for -e/-E use */
1820Sstevel@tonic-gate #define	RTC_VER_FOUR	4		/* updated for filter/filtees */
1830Sstevel@tonic-gate #define	RTC_VER_CURRENT RTC_VER_FOUR
1840Sstevel@tonic-gate #define	RTC_VER_NUM	5
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate /*
1870Sstevel@tonic-gate  * Environment variable descriptor.  The configuration cache (ch_env) points to
1880Sstevel@tonic-gate  * an array of these descriptors.
1890Sstevel@tonic-gate  */
1900Sstevel@tonic-gate typedef struct {
1910Sstevel@tonic-gate 	Word	env_str;		/* index into string table */
1920Sstevel@tonic-gate 	Word	env_flags;		/* various flags */
1930Sstevel@tonic-gate } Rtc_env;
1940Sstevel@tonic-gate 
1950Sstevel@tonic-gate #define	RTC_ENV_REPLACE	0x0001		/* replaceable string definition */
1960Sstevel@tonic-gate #define	RTC_ENV_PERMANT	0x0002		/* permanent string definition */
1970Sstevel@tonic-gate #define	RTC_ENV_CONFIG	0x1000		/* string originates from config file */
1980Sstevel@tonic-gate 
1990Sstevel@tonic-gate /*
2000Sstevel@tonic-gate  * Filter descriptor.  The configuration cache (ch_flt) points to an array of
2010Sstevel@tonic-gate  * these descriptors.
2020Sstevel@tonic-gate  */
2030Sstevel@tonic-gate typedef struct {
2040Sstevel@tonic-gate 	Word	fr_filter;		/* filter name, and filtee string */
2050Sstevel@tonic-gate 	Word	fr_string;		/*	as indexs into string table */
2060Sstevel@tonic-gate 	Word	fr_filtee;		/* index into filtee array */
2070Sstevel@tonic-gate } Rtc_fltr;
2080Sstevel@tonic-gate 
2090Sstevel@tonic-gate typedef struct {
2100Sstevel@tonic-gate 	Word	fe_filtee;
2110Sstevel@tonic-gate } Rtc_flte;
2120Sstevel@tonic-gate 
2130Sstevel@tonic-gate #ifdef	__cplusplus
2140Sstevel@tonic-gate }
2150Sstevel@tonic-gate #endif
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate #endif	/* _RTC_H */
218