Print this page
10366 ld(1) should support GNU-style linker sets
10581 ld(1) should know kernel modules are a thing
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/include/sgs.h
+++ new/usr/src/cmd/sgs/include/sgs.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988 AT&T
24 24 * All Rights Reserved
25 25 *
26 26 *
27 27 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
28 28 *
29 29 * Global include file for all sgs.
30 30 */
31 31
32 32 #ifndef _SGS_H
33 33 #define _SGS_H
34 34
35 35 #ifdef __cplusplus
36 36 extern "C" {
37 37 #endif
38 38
39 39 /* <assert.h> keys off of NDEBUG */
40 40 #ifdef DEBUG
41 41 #undef NDEBUG
42 42 #else
43 43 #define NDEBUG
44 44 #endif
45 45
46 46 #ifndef _ASM
47 47 #include <sys/types.h>
48 48 #include <sys/machelf.h>
49 49 #include <stdlib.h>
50 50 #include <stdarg.h>
51 51 #include <libelf.h>
52 52 #include <assert.h>
53 53 #include <alist.h>
54 54 #endif /* _ASM */
55 55
56 56 /*
57 57 * Software identification.
58 58 */
59 59 #define SGS ""
60 60 #define SGU_PKG "Software Generation Utilities"
61 61 #define SGU_REL "(SGU) Solaris-ELF (4.0)"
62 62
63 63
64 64 #ifndef _ASM
65 65
66 66 /*
67 67 * link_ver_string[] contains a version string for use by the link-editor
68 68 * and all other linker components. It is found in libconv, and is
69 69 * generated by sgs/libconv/common/bld_vernote.ksh. That script produces
70 70 * libconv/{plat}/vernote.s, which is in turn assembled/linked into
71 71 * libconv.
72 72 */
73 73 extern const char link_ver_string[];
74 74 /*
75 75 * Macro to round to next double word boundary.
76 76 */
77 77 #define S_DROUND(x) (((x) + sizeof (double) - 1) & ~(sizeof (double) - 1))
78 78
79 79 /*
80 80 * General align and round macros.
81 81 */
82 82 #define S_ALIGN(x, a) ((x) & ~(((a) ? (a) : 1) - 1))
83 83 #define S_ROUND(x, a) ((x) + (((a) ? (a) : 1) - 1) & ~(((a) ? (a) : 1) - 1))
84 84
85 85 /*
86 86 * Bit manipulation macros; generic bit mask and is `v' in the range
87 87 * supportable in `n' bits?
88 88 */
89 89 #define S_MASK(n) ((1 << (n)) -1)
90 90 #define S_INRANGE(v, n) (((-(1 << (n)) - 1) < (v)) && ((v) < (1 << (n))))
91 91
92 92
93 93 /*
94 94 * Yet another definition of the OFFSETOF macro, used with the AVL routines.
95 95 */
96 96 #define SGSOFFSETOF(s, m) ((size_t)(&(((s *)0)->m)))
97 97
98 98 /*
99 99 * When casting between integer and pointer types, gcc will complain
100 100 * if the integer type used is not large enough to hold the pointer
101 101 * value without loss. Although a dubious practice in general, this
102 102 * is sometimes done by design. In those cases, the general solution
103 103 * is to introduce an intermediate cast to widen the integer value. The
104 104 * CAST_PTRINT macro does this, and its use documents the fact that
105 105 * the programmer is doing that sort of cast.
106 106 */
107 107 #ifdef __GNUC__
108 108 #define CAST_PTRINT(cast, value) ((cast)(uintptr_t)value)
109 109 #else
110 110 #define CAST_PTRINT(cast, value) ((cast)value)
111 111 #endif
112 112
113 113 /*
114 114 * General typedefs.
115 115 */
116 116 typedef enum {
117 117 FALSE = 0,
118 118 TRUE = 1
119 119 } Boolean;
120 120
121 121 /*
122 122 * Types of errors (used by veprintf()), together with a generic error return
123 123 * value.
124 124 */
125 125 typedef enum {
126 126 ERR_NONE, /* plain message */
127 127 ERR_WARNING_NF, /* warning that cannot be promoted to fatal */
128 128 ERR_WARNING, /* warning that can be promoted to fatal */
129 129 ERR_GUIDANCE, /* guidance warning that can be promoted */
130 130 ERR_FATAL, /* fatal error */
131 131 ERR_ELF, /* fatal libelf error */
132 132 ERR_NUM /* # of Error codes. Must be last */
133 133 } Error;
134 134
135 135 /*
136 136 * Type used to represent line numbers within files, and a corresponding
137 137 * printing macro for it.
138 138 */
139 139 typedef ulong_t Lineno;
140 140 #define EC_LINENO(_x) EC_XWORD(_x) /* "llu" */
141 141
142 142
143 143 #if defined(_LP64) && !defined(_ELF64)
144 144 #define S_ERROR (~(uint_t)0)
145 145 #else
146 146 #define S_ERROR (~(uintptr_t)0)
147 147 #endif
148 148
149 149 /*
150 150 * CTF currently does not handle automatic array variables sized via function
151 151 * arguments (VLA arrays) properly, when the code is compiled with gcc.
152 152 * Adding 1 to the size is a workaround. VLA_SIZE, and its use, should be
153 153 * pulled when CTF is fixed or replaced.
154 154 */
155 155 #ifdef __GNUC__
156 156 #define VLA_SIZE(_arg) ((_arg) + 1)
157 157 #else
158 158 #define VLA_SIZE(_arg) (_arg)
159 159 #endif
160 160
161 161 /*
162 162 * Structure to maintain rejected files elf information. Files that are not
163 163 * applicable to the present link-edit are rejected and a search for an
164 164 * appropriate file may be resumed. The first rejected files information is
165 165 * retained so that a better error diagnostic can be given should an appropriate
166 166 * file not be located.
167 167 */
168 168 typedef struct {
169 169 ushort_t rej_type; /* SGS_REJ_ value */
170 170 ushort_t rej_flags; /* additional information */
171 171 uint_t rej_info; /* numeric and string information */
172 172 const char *rej_str; /* associated with error */
173 173 const char *rej_name; /* object name - expanded library */
174 174 /* name and archive members */
175 175 } Rej_desc;
176 176
177 177 #define SGS_REJ_NONE 0
178 178 #define SGS_REJ_MACH 1 /* wrong ELF machine type */
179 179 #define SGS_REJ_CLASS 2 /* wrong ELF class (32-bit/64-bit) */
180 180 #define SGS_REJ_DATA 3 /* wrong ELF data format (MSG/LSB) */
181 181 #define SGS_REJ_TYPE 4 /* bad ELF type */
182 182 #define SGS_REJ_BADFLAG 5 /* bad ELF flags value */
183 183 #define SGS_REJ_MISFLAG 6 /* mismatched ELF flags value */
184 184 #define SGS_REJ_VERSION 7 /* mismatched ELF/lib version */
185 185 #define SGS_REJ_HAL 8 /* HAL R1 extensions required */
186 186 #define SGS_REJ_US3 9 /* Sun UltraSPARC III extensions */
↓ open down ↓ |
186 lines elided |
↑ open up ↑ |
187 187 /* required */
188 188 #define SGS_REJ_STR 10 /* generic error - info is a string */
189 189 #define SGS_REJ_UNKFILE 11 /* unknown file type */
190 190 #define SGS_REJ_UNKCAP 12 /* unknown capabilities */
191 191 #define SGS_REJ_HWCAP_1 13 /* hardware capabilities mismatch */
192 192 #define SGS_REJ_SFCAP_1 14 /* software capabilities mismatch */
193 193 #define SGS_REJ_MACHCAP 15 /* machine capability mismatch */
194 194 #define SGS_REJ_PLATCAP 16 /* platform capability mismatch */
195 195 #define SGS_REJ_HWCAP_2 17 /* hardware capabilities mismatch */
196 196 #define SGS_REJ_ARCHIVE 18 /* archive used in invalid context */
197 -#define SGS_REJ_NUM 19
197 +#define SGS_REJ_KMOD 19 /* object is a kernel module */
198 +#define SGS_REJ_NUM 20
198 199
199 200 #define FLG_REJ_ALTER 0x01 /* object name is an alternative */
200 201
201 202 /*
202 203 * For those source files used both inside and outside of the
203 204 * libld source base (tools/common/string_table.c) we can
204 205 * automatically switch between the allocation models
205 206 * based off of the 'cc -DUSE_LIBLD_MALLOC' flag.
206 207 */
207 208 #ifdef USE_LIBLD_MALLOC
208 209 #define calloc(x, a) libld_malloc(((size_t)x) * ((size_t)a))
209 210 #define free libld_free
210 211 #define malloc libld_malloc
211 212 #define realloc libld_realloc
212 213
213 214 #define libld_calloc(x, a) libld_malloc(((size_t)x) * ((size_t)a))
214 215 extern void libld_free(void *);
215 216 extern void *libld_malloc(size_t);
216 217 extern void *libld_realloc(void *, size_t);
217 218 #endif
218 219
219 220 /*
220 221 * Data structures (defined in libld.h).
221 222 */
222 223 typedef struct audit_desc Audit_desc;
223 224 typedef struct audit_info Audit_info;
224 225 typedef struct audit_list Audit_list;
225 226 typedef struct cap_desc Cap_desc;
226 227 typedef struct ent_desc Ent_desc;
227 228 typedef struct group_desc Group_desc;
228 229 typedef struct ifl_desc Ifl_desc;
229 230 typedef struct is_desc Is_desc;
230 231 typedef struct isa_desc Isa_desc;
231 232 typedef struct isa_opt Isa_opt;
232 233 typedef struct os_desc Os_desc;
233 234 typedef struct ofl_desc Ofl_desc;
234 235 typedef struct rel_cache Rel_cache;
235 236 typedef struct rel_cachebuf Rel_cachebuf;
236 237 typedef struct rel_aux_cachebuf Rel_aux_cachebuf;
237 238 typedef struct rel_aux Rel_aux;
238 239 typedef struct rel_desc Rel_desc;
239 240 typedef struct sdf_desc Sdf_desc;
240 241 typedef struct sdv_desc Sdv_desc;
241 242 typedef struct sec_order Sec_order;
242 243 typedef struct sg_desc Sg_desc;
243 244 typedef struct sort_desc Sort_desc;
244 245 typedef struct sym_avlnode Sym_avlnode;
245 246 typedef struct sym_aux Sym_aux;
246 247 typedef struct sym_desc Sym_desc;
247 248 typedef struct uts_desc Uts_desc;
248 249 typedef struct ver_desc Ver_desc;
249 250 typedef struct ver_index Ver_index;
250 251
251 252 /*
252 253 * Data structures defined in rtld.h.
253 254 */
254 255 typedef struct lm_list Lm_list;
255 256 #ifdef _SYSCALL32
256 257 typedef struct lm_list32 Lm_list32;
257 258 #endif /* _SYSCALL32 */
258 259
259 260 /*
260 261 * For the various utilities that include sgs.h
261 262 */
262 263 extern int assfail(const char *, const char *, int);
263 264 extern void eprintf(Lm_list *, Error, const char *, ...);
264 265 extern void veprintf(Lm_list *, Error, const char *, va_list);
265 266 extern uint_t sgs_str_hash(const char *);
266 267 extern uint_t findprime(uint_t);
267 268
268 269 #endif /* _ASM */
269 270
270 271 #ifdef __cplusplus
271 272 }
272 273 #endif
273 274
274 275
275 276 #endif /* _SGS_H */
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX