xref: /illumos-gate/usr/src/cmd/sgs/libld/common/globals.c (revision dd72704bd9e794056c558153663c739e2012d721)
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 /*
23  *	Copyright (c) 1988 AT&T
24  *	  All Rights Reserved
25  *
26  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
27  * Copyright 2022 Oxide Computer Company
28  */
29 
30 /*
31  * Global variables
32  */
33 #include	<sys/elf.h>
34 #include	"msg.h"
35 #include	"_libld.h"
36 
37 APlist		*lib_support;	/* list of support libraries specified */
38 				/*	(-S option) */
39 int		demangle_flag;	/* symbol demangling required */
40 
41 /*
42  * Paths and directories for library searches.  These are used to set up
43  * linked lists of directories which are maintained in the ofl structure.
44  */
45 char		*Plibpath;	/* User specified -YP or defaults to LIBPATH */
46 char		*Llibdir;	/* User specified -YL */
47 char		*Ulibdir;	/* User specified -YU */
48 
49 /*
50  * A default library search path is used if one was not supplied on the command
51  * line.  Note: these strings can not use MSG_ORIG() since they are modified as
52  * part of the path processing.
53  */
54 char		def64_Plibpath[] = "/lib/64:/usr/lib/64";
55 char		def32_Plibpath[] = "/usr/ccs/lib:/lib:/usr/lib";
56 
57 /*
58  * Rejected file error messages (indexed to match SGS_REJ_ values).
59  */
60 const Msg
61 reject[SGS_REJ_NUM] = {
62 		MSG_STR_EMPTY,
63 		MSG_REJ_MACH,		/* MSG_INTL(MSG_REJ_MACH) */
64 		MSG_REJ_CLASS,		/* MSG_INTL(MSG_REJ_CLASS) */
65 		MSG_REJ_DATA,		/* MSG_INTL(MSG_REJ_DATA) */
66 		MSG_REJ_TYPE,		/* MSG_INTL(MSG_REJ_TYPE) */
67 		MSG_REJ_BADFLAG,	/* MSG_INTL(MSG_REJ_BADFLAG) */
68 		MSG_REJ_MISFLAG,	/* MSG_INTL(MSG_REJ_MISFLAG) */
69 		MSG_REJ_VERSION,	/* MSG_INTL(MSG_REJ_VERSION) */
70 		MSG_REJ_HAL,		/* MSG_INTL(MSG_REJ_HAL) */
71 		MSG_REJ_US3,		/* MSG_INTL(MSG_REJ_US3) */
72 		MSG_REJ_STR,		/* MSG_INTL(MSG_REJ_STR) */
73 		MSG_REJ_UNKFILE,	/* MSG_INTL(MSG_REJ_UNKFILE) */
74 		MSG_REJ_UNKCAP,		/* MSG_INTL(MSG_REJ_UNKCAP) */
75 		MSG_REJ_HWCAP_1,	/* MSG_INTL(MSG_REJ_HWCAP_1) */
76 		MSG_REJ_SFCAP_1,	/* MSG_INTL(MSG_REJ_SFCAP_1) */
77 		MSG_REJ_MACHCAP,	/* MSG_INTL(MSG_REJ_MACHCAP) */
78 		MSG_REJ_PLATCAP,	/* MSG_INTL(MSG_REJ_PLATCAP) */
79 		MSG_REJ_HWCAP_2,	/* MSG_INTL(MSG_REJ_HWCAP_2) */
80 		MSG_REJ_ARCHIVE,	/* MSG_INTL(MSG_REJ_ARCHIVE) */
81 		MSG_REJ_KMOD,		/* MSG_INTL(MSG_REJ_KMOD) */
82 		MSG_REJ_HWCAP_3		/* MSG_INTL(MSG_REJ_HWCAP_3) */
83 	};
84 #if SGS_REJ_NUM != (SGS_REJ_HWCAP_3 + 1)
85 #error SGS_REJ_NUM has changed
86 #endif
87 
88 /*
89  * Symbol types that we include in .SUNW_ldynsym sections
90  * (indexed by STT_ values).
91  */
92 const int
93 ldynsym_symtype[] = {
94 		0,			/* STT_NOTYPE (not counting 1st slot) */
95 		0,			/* STT_OBJECT */
96 		1,			/* STT_FUNC */
97 		0,			/* STT_SECTION */
98 		1,			/* STT_FILE */
99 		0,			/* STT_COMMON */
100 		0,			/* STT_TLS */
101 		0,			/* 7 */
102 		0,			/* 8 */
103 		0,			/* 9 */
104 		0,			/* 10 */
105 		0,			/* 11 */
106 		0,			/* 12 */
107 		0,			/* STT_SPARC_REGISTER */
108 		0,			/* 14 */
109 		0,			/* 15 */
110 };
111 #if STT_NUM != (STT_TLS + 1)
112 #error "STT_NUM has grown. Update ldynsym_symtype[]."
113 #endif
114 
115 /*
116  * Symbol types that we include in .SUNW_dynsymsort sections
117  * (indexed by STT_ values).
118  */
119 const int
120 dynsymsort_symtype[] = {
121 		0,			/* STT_NOTYPE */
122 		1,			/* STT_OBJECT */
123 		1,			/* STT_FUNC */
124 		0,			/* STT_SECTION */
125 		0,			/* STT_FILE */
126 		1,			/* STT_COMMON */
127 		0,			/* STT_TLS */
128 		0,			/* 7 */
129 		0,			/* 8 */
130 		0,			/* 9 */
131 		0,			/* 10 */
132 		0,			/* 11 */
133 		0,			/* 12 */
134 		0,			/* STT_SPARC_REGISTER */
135 		0,			/* 14 */
136 		0,			/* 15 */
137 };
138 #if STT_NUM != (STT_TLS + 1)
139 #error "STT_NUM has grown. Update dynsymsort_symtype[]."
140 #endif
141