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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include	<stdlib.h>
28 #include	<stdio.h>
29 #include	<unistd.h>
30 #include	<libintl.h>
31 #include	<libelf.h>
32 #include	<sys/machelf.h>
33 #include	<link.h>
34 #include	<strings.h>
35 #include	<ctype.h>
36 #include	<elfedit.h>
37 #include	<_elfedit.h>
38 #include	<sys/elf_SPARC.h>
39 #include	<sys/elf_amd64.h>
40 #include	<sys/auxv_386.h>
41 #include	<sys/auxv_SPARC.h>
42 #include	<msg.h>
43 #include	<elfcap.h>
44 
45 
46 
47 /*
48  * This file contains support for mapping well known ELF constants
49  * to their numeric values. It is a layer on top of the elfedit_atoui()
50  * routines defined in util.c. The idea is that centralizing all the
51  * support for such constants will improve consistency between modules,
52  * allow for sharing of commonly needed items, and make the modules
53  * simpler.
54  */
55 
56 
57 
58 
59 /*
60  * elfedit output style, with and without leading -o
61  */
62 static elfedit_atoui_sym_t sym_outstyle[] = {
63 	{ MSG_ORIG(MSG_STR_DEFAULT),		ELFEDIT_OUTSTYLE_DEFAULT },
64 	{ MSG_ORIG(MSG_STR_SIMPLE),		ELFEDIT_OUTSTYLE_SIMPLE },
65 	{ MSG_ORIG(MSG_STR_NUM),		ELFEDIT_OUTSTYLE_NUM },
66 	{ NULL }
67 };
68 static elfedit_atoui_sym_t sym_minus_o_outstyle[] = {
69 	{ MSG_ORIG(MSG_STR_MINUS_O_DEFAULT),	ELFEDIT_OUTSTYLE_DEFAULT },
70 	{ MSG_ORIG(MSG_STR_MINUS_O_SIMPLE),	ELFEDIT_OUTSTYLE_SIMPLE },
71 	{ MSG_ORIG(MSG_STR_MINUS_O_NUM),	ELFEDIT_OUTSTYLE_NUM },
72 	{ NULL }
73 };
74 
75 
76 /*
77  * Booleans
78  */
79 static elfedit_atoui_sym_t sym_bool[] = {
80 	{ MSG_ORIG(MSG_STR_T),			1 },
81 	{ MSG_ORIG(MSG_STR_F),			0 },
82 	{ MSG_ORIG(MSG_STR_TRUE),		1 },
83 	{ MSG_ORIG(MSG_STR_FALSE),		0 },
84 	{ MSG_ORIG(MSG_STR_ON),			1 },
85 	{ MSG_ORIG(MSG_STR_OFF),		0 },
86 	{ MSG_ORIG(MSG_STR_YES),		1 },
87 	{ MSG_ORIG(MSG_STR_NO),			0 },
88 	{ MSG_ORIG(MSG_STR_Y),			1 },
89 	{ MSG_ORIG(MSG_STR_N),			0 },
90 	{ NULL }
91 };
92 
93 /*
94  * ELF section indexes with support for the special index names.
95  */
96 static elfedit_atoui_sym_t sym_shn[] = {
97 	{ MSG_ORIG(MSG_SHN_UNDEF),		SHN_UNDEF },
98 	{ MSG_ORIG(MSG_SHN_UNDEF_ALT1),		SHN_UNDEF },
99 
100 	{ MSG_ORIG(MSG_SHN_SUNW_IGNORE),	SHN_SUNW_IGNORE },
101 	{ MSG_ORIG(MSG_SHN_SUNW_IGNORE_ALT1),	SHN_SUNW_IGNORE },
102 
103 	{ MSG_ORIG(MSG_SHN_BEFORE),		SHN_BEFORE },
104 	{ MSG_ORIG(MSG_SHN_BEFORE_ALT1),	SHN_BEFORE },
105 
106 	{ MSG_ORIG(MSG_SHN_AFTER),		SHN_AFTER },
107 	{ MSG_ORIG(MSG_SHN_AFTER_ALT1), 	SHN_AFTER },
108 
109 	{ MSG_ORIG(MSG_SHN_AMD64_LCOMMON), 	SHN_AMD64_LCOMMON },
110 	{ MSG_ORIG(MSG_SHN_AMD64_LCOMMON_ALT1),	SHN_AMD64_LCOMMON },
111 
112 	{ MSG_ORIG(MSG_SHN_ABS),		SHN_ABS },
113 	{ MSG_ORIG(MSG_SHN_ABS_ALT1),		SHN_ABS },
114 
115 	{ MSG_ORIG(MSG_SHN_COMMON),		SHN_COMMON },
116 	{ MSG_ORIG(MSG_SHN_COMMON_ALT1),	SHN_COMMON },
117 
118 	{ MSG_ORIG(MSG_SHN_XINDEX),		SHN_XINDEX },
119 	{ MSG_ORIG(MSG_SHN_XINDEX_ALT1),	SHN_XINDEX },
120 
121 	{ NULL }
122 };
123 
124 /*
125  * ELF section types.
126  */
127 static elfedit_atoui_sym_t sym_sht[] = {
128 	{ MSG_ORIG(MSG_SHT_NULL),		SHT_NULL },
129 	{ MSG_ORIG(MSG_SHT_NULL_ALT1),		SHT_NULL },
130 
131 	{ MSG_ORIG(MSG_SHT_PROGBITS),		SHT_PROGBITS },
132 	{ MSG_ORIG(MSG_SHT_PROGBITS_ALT1),	SHT_PROGBITS },
133 
134 	{ MSG_ORIG(MSG_SHT_SYMTAB),		SHT_SYMTAB },
135 	{ MSG_ORIG(MSG_SHT_SYMTAB_ALT1),	SHT_SYMTAB },
136 
137 	{ MSG_ORIG(MSG_SHT_STRTAB),		SHT_STRTAB },
138 	{ MSG_ORIG(MSG_SHT_STRTAB_ALT1),	SHT_STRTAB },
139 
140 	{ MSG_ORIG(MSG_SHT_RELA),		SHT_RELA },
141 	{ MSG_ORIG(MSG_SHT_RELA_ALT1),		SHT_RELA },
142 
143 	{ MSG_ORIG(MSG_SHT_HASH),		SHT_HASH },
144 	{ MSG_ORIG(MSG_SHT_HASH_ALT1),		SHT_HASH },
145 
146 	{ MSG_ORIG(MSG_SHT_DYNAMIC),		SHT_DYNAMIC },
147 	{ MSG_ORIG(MSG_SHT_DYNAMIC_ALT1),	SHT_DYNAMIC },
148 
149 	{ MSG_ORIG(MSG_SHT_NOTE),		SHT_NOTE },
150 	{ MSG_ORIG(MSG_SHT_NOTE_ALT1),		SHT_NOTE },
151 
152 	{ MSG_ORIG(MSG_SHT_NOBITS),		SHT_NOBITS },
153 	{ MSG_ORIG(MSG_SHT_NOBITS_ALT1),	SHT_NOBITS },
154 
155 	{ MSG_ORIG(MSG_SHT_REL),		SHT_REL },
156 	{ MSG_ORIG(MSG_SHT_REL_ALT1),		SHT_REL },
157 
158 	{ MSG_ORIG(MSG_SHT_SHLIB),		SHT_SHLIB },
159 	{ MSG_ORIG(MSG_SHT_SHLIB_ALT1),		SHT_SHLIB },
160 
161 	{ MSG_ORIG(MSG_SHT_DYNSYM),		SHT_DYNSYM },
162 	{ MSG_ORIG(MSG_SHT_DYNSYM_ALT1),	SHT_DYNSYM },
163 
164 	{ MSG_ORIG(MSG_SHT_INIT_ARRAY),		SHT_INIT_ARRAY },
165 	{ MSG_ORIG(MSG_SHT_INIT_ARRAY_ALT1),	SHT_INIT_ARRAY },
166 
167 	{ MSG_ORIG(MSG_SHT_FINI_ARRAY),		SHT_FINI_ARRAY },
168 	{ MSG_ORIG(MSG_SHT_FINI_ARRAY_ALT1),	SHT_FINI_ARRAY },
169 
170 	{ MSG_ORIG(MSG_SHT_PREINIT_ARRAY),	SHT_PREINIT_ARRAY },
171 	{ MSG_ORIG(MSG_SHT_PREINIT_ARRAY_ALT1),	SHT_PREINIT_ARRAY },
172 
173 	{ MSG_ORIG(MSG_SHT_GROUP),		SHT_GROUP },
174 	{ MSG_ORIG(MSG_SHT_GROUP_ALT1),		SHT_GROUP },
175 
176 	{ MSG_ORIG(MSG_SHT_SYMTAB_SHNDX),	SHT_SYMTAB_SHNDX },
177 	{ MSG_ORIG(MSG_SHT_SYMTAB_SHNDX_ALT1),	SHT_SYMTAB_SHNDX },
178 
179 	{ MSG_ORIG(MSG_SHT_SUNW_SYMSORT),	SHT_SUNW_symsort },
180 	{ MSG_ORIG(MSG_SHT_SUNW_SYMSORT_ALT1),	SHT_SUNW_symsort },
181 
182 	{ MSG_ORIG(MSG_SHT_SUNW_TLSSORT),	SHT_SUNW_tlssort },
183 	{ MSG_ORIG(MSG_SHT_SUNW_TLSSORT_ALT1),	SHT_SUNW_tlssort },
184 
185 	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM),	SHT_SUNW_LDYNSYM },
186 	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM_ALT1),	SHT_SUNW_LDYNSYM },
187 
188 	{ MSG_ORIG(MSG_SHT_SUNW_DOF),		SHT_SUNW_dof },
189 	{ MSG_ORIG(MSG_SHT_SUNW_DOF_ALT1),	SHT_SUNW_dof },
190 
191 	{ MSG_ORIG(MSG_SHT_SUNW_CAP),		SHT_SUNW_cap },
192 	{ MSG_ORIG(MSG_SHT_SUNW_CAP_ALT1),	SHT_SUNW_cap },
193 
194 	{ MSG_ORIG(MSG_SHT_SUNW_SIGNATURE),	SHT_SUNW_SIGNATURE },
195 	{ MSG_ORIG(MSG_SHT_SUNW_SIGNATURE_ALT1), SHT_SUNW_SIGNATURE },
196 
197 	{ MSG_ORIG(MSG_SHT_SUNW_ANNOTATE),	SHT_SUNW_ANNOTATE },
198 	{ MSG_ORIG(MSG_SHT_SUNW_ANNOTATE_ALT1),	SHT_SUNW_ANNOTATE },
199 
200 	{ MSG_ORIG(MSG_SHT_SUNW_DEBUGSTR),	SHT_SUNW_DEBUGSTR },
201 	{ MSG_ORIG(MSG_SHT_SUNW_DEBUGSTR_ALT1),	SHT_SUNW_DEBUGSTR },
202 
203 	{ MSG_ORIG(MSG_SHT_SUNW_DEBUG),		SHT_SUNW_DEBUG },
204 	{ MSG_ORIG(MSG_SHT_SUNW_DEBUG_ALT1),	SHT_SUNW_DEBUG },
205 
206 	{ MSG_ORIG(MSG_SHT_SUNW_MOVE),		SHT_SUNW_move },
207 	{ MSG_ORIG(MSG_SHT_SUNW_MOVE_ALT1),	SHT_SUNW_move },
208 
209 	{ MSG_ORIG(MSG_SHT_SUNW_COMDAT),	SHT_SUNW_COMDAT },
210 	{ MSG_ORIG(MSG_SHT_SUNW_COMDAT_ALT1),	SHT_SUNW_COMDAT },
211 
212 	{ MSG_ORIG(MSG_SHT_SUNW_SYMINFO),	SHT_SUNW_syminfo },
213 	{ MSG_ORIG(MSG_SHT_SUNW_SYMINFO_ALT1),	SHT_SUNW_syminfo },
214 
215 	{ MSG_ORIG(MSG_SHT_SUNW_VERDEF),	SHT_SUNW_verdef },
216 	{ MSG_ORIG(MSG_SHT_SUNW_VERDEF_ALT1),	SHT_SUNW_verdef },
217 
218 	{ MSG_ORIG(MSG_SHT_GNU_VERDEF),		SHT_GNU_verdef },
219 	{ MSG_ORIG(MSG_SHT_GNU_VERDEF_ALT1),	SHT_GNU_verdef },
220 
221 	{ MSG_ORIG(MSG_SHT_SUNW_VERNEED),	SHT_SUNW_verneed },
222 	{ MSG_ORIG(MSG_SHT_SUNW_VERNEED_ALT1),	SHT_SUNW_verneed },
223 
224 	{ MSG_ORIG(MSG_SHT_GNU_VERNEED),	SHT_GNU_verneed },
225 	{ MSG_ORIG(MSG_SHT_GNU_VERNEED_ALT1),	SHT_GNU_verneed },
226 
227 	{ MSG_ORIG(MSG_SHT_SUNW_VERSYM),	SHT_SUNW_versym },
228 	{ MSG_ORIG(MSG_SHT_SUNW_VERSYM_ALT1),	SHT_SUNW_versym },
229 
230 	{ MSG_ORIG(MSG_SHT_GNU_VERSYM),		SHT_GNU_versym },
231 	{ MSG_ORIG(MSG_SHT_GNU_VERSYM_ALT1),	SHT_GNU_versym },
232 
233 	{ MSG_ORIG(MSG_SHT_SPARC_GOTDATA),	SHT_SPARC_GOTDATA },
234 	{ MSG_ORIG(MSG_SHT_SPARC_GOTDATA_ALT1),	SHT_SPARC_GOTDATA },
235 
236 	{ MSG_ORIG(MSG_SHT_AMD64_UNWIND),	SHT_AMD64_UNWIND },
237 	{ MSG_ORIG(MSG_SHT_AMD64_UNWIND_ALT1),	SHT_AMD64_UNWIND },
238 
239 	{ NULL }
240 };
241 
242 /*
243  * ELF section types.
244  */
245 static elfedit_atoui_sym_t sym_sht_strtab[] = {
246 	{ MSG_ORIG(MSG_SHT_STRTAB),		SHT_STRTAB },
247 	{ MSG_ORIG(MSG_SHT_STRTAB_ALT1),	SHT_STRTAB },
248 
249 	{ NULL }
250 };
251 
252 
253 /*
254  * ELF section types for symbol tables
255  */
256 static elfedit_atoui_sym_t sym_sht_allsymtab[] = {
257 	{ MSG_ORIG(MSG_SHT_SYMTAB),		SHT_SYMTAB },
258 	{ MSG_ORIG(MSG_SHT_SYMTAB_ALT1),	SHT_SYMTAB },
259 
260 	{ MSG_ORIG(MSG_SHT_DYNSYM),		SHT_DYNSYM },
261 	{ MSG_ORIG(MSG_SHT_DYNSYM_ALT1),	SHT_DYNSYM },
262 
263 	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM),	SHT_SUNW_LDYNSYM },
264 	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM_ALT1),	SHT_SUNW_LDYNSYM },
265 
266 	{ NULL }
267 };
268 
269 /*
270  * ELF section types for SHT_SYMTAB
271  */
272 static elfedit_atoui_sym_t sym_sht_symtab[] = {
273 	{ MSG_ORIG(MSG_SHT_SYMTAB),		SHT_SYMTAB },
274 	{ MSG_ORIG(MSG_SHT_SYMTAB_ALT1),	SHT_SYMTAB },
275 
276 	{ NULL }
277 };
278 
279 /*
280  * ELF section types for SHT_SYMTAB
281  */
282 static elfedit_atoui_sym_t sym_sht_dynsym[] = {
283 	{ MSG_ORIG(MSG_SHT_DYNSYM),		SHT_DYNSYM },
284 	{ MSG_ORIG(MSG_SHT_DYNSYM_ALT1),	SHT_DYNSYM },
285 
286 	{ NULL }
287 };
288 
289 /*
290  * ELF section types for SHT_SUNW_LDYNSYM
291  */
292 static elfedit_atoui_sym_t sym_sht_ldynsym[] = {
293 	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM),	SHT_SUNW_LDYNSYM },
294 	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM_ALT1),	SHT_SUNW_LDYNSYM },
295 
296 	{ NULL }
297 };
298 
299 /*
300  * ELF dynamic tag DT_ values
301  */
302 static elfedit_atoui_sym_t sym_dt[] = {
303 	{ MSG_ORIG(MSG_DT_NULL),		DT_NULL },
304 	{ MSG_ORIG(MSG_DT_NULL_ALT1),		DT_NULL },
305 
306 	{ MSG_ORIG(MSG_DT_NEEDED),		DT_NEEDED },
307 	{ MSG_ORIG(MSG_DT_NEEDED_ALT1),		DT_NEEDED },
308 
309 	{ MSG_ORIG(MSG_DT_PLTRELSZ),		DT_PLTRELSZ },
310 	{ MSG_ORIG(MSG_DT_PLTRELSZ_ALT1),	DT_PLTRELSZ },
311 
312 	{ MSG_ORIG(MSG_DT_PLTGOT),		DT_PLTGOT },
313 	{ MSG_ORIG(MSG_DT_PLTGOT_ALT1),		DT_PLTGOT },
314 
315 	{ MSG_ORIG(MSG_DT_HASH),		DT_HASH },
316 	{ MSG_ORIG(MSG_DT_HASH_ALT1),		DT_HASH },
317 
318 	{ MSG_ORIG(MSG_DT_STRTAB),		DT_STRTAB },
319 	{ MSG_ORIG(MSG_DT_STRTAB_ALT1),		DT_STRTAB },
320 
321 	{ MSG_ORIG(MSG_DT_SYMTAB),		DT_SYMTAB },
322 	{ MSG_ORIG(MSG_DT_SYMTAB_ALT1),		DT_SYMTAB },
323 
324 	{ MSG_ORIG(MSG_DT_RELA),		DT_RELA },
325 	{ MSG_ORIG(MSG_DT_RELA_ALT1),		DT_RELA },
326 
327 	{ MSG_ORIG(MSG_DT_RELASZ),		DT_RELASZ },
328 	{ MSG_ORIG(MSG_DT_RELASZ_ALT1),		DT_RELASZ },
329 
330 	{ MSG_ORIG(MSG_DT_RELAENT),		DT_RELAENT },
331 	{ MSG_ORIG(MSG_DT_RELAENT_ALT1),	DT_RELAENT },
332 
333 	{ MSG_ORIG(MSG_DT_STRSZ),		DT_STRSZ },
334 	{ MSG_ORIG(MSG_DT_STRSZ_ALT1),		DT_STRSZ },
335 
336 	{ MSG_ORIG(MSG_DT_SYMENT),		DT_SYMENT },
337 	{ MSG_ORIG(MSG_DT_SYMENT_ALT1),		DT_SYMENT },
338 
339 	{ MSG_ORIG(MSG_DT_INIT),		DT_INIT },
340 	{ MSG_ORIG(MSG_DT_INIT_ALT1),		DT_INIT },
341 
342 	{ MSG_ORIG(MSG_DT_FINI),		DT_FINI },
343 	{ MSG_ORIG(MSG_DT_FINI_ALT1),		DT_FINI },
344 
345 	{ MSG_ORIG(MSG_DT_SONAME),		DT_SONAME },
346 	{ MSG_ORIG(MSG_DT_SONAME_ALT1),		DT_SONAME },
347 
348 	{ MSG_ORIG(MSG_DT_RPATH),		DT_RPATH },
349 	{ MSG_ORIG(MSG_DT_RPATH_ALT1),		DT_RPATH },
350 
351 	{ MSG_ORIG(MSG_DT_SYMBOLIC),		DT_SYMBOLIC },
352 	{ MSG_ORIG(MSG_DT_SYMBOLIC_ALT1),	DT_SYMBOLIC },
353 
354 	{ MSG_ORIG(MSG_DT_REL),			DT_REL },
355 	{ MSG_ORIG(MSG_DT_REL_ALT1),		DT_REL },
356 
357 	{ MSG_ORIG(MSG_DT_RELSZ),		DT_RELSZ },
358 	{ MSG_ORIG(MSG_DT_RELSZ_ALT1),		DT_RELSZ },
359 
360 	{ MSG_ORIG(MSG_DT_RELENT),		DT_RELENT },
361 	{ MSG_ORIG(MSG_DT_RELENT_ALT1),		DT_RELENT },
362 
363 	{ MSG_ORIG(MSG_DT_PLTREL),		DT_PLTREL },
364 	{ MSG_ORIG(MSG_DT_PLTREL_ALT1),		DT_PLTREL },
365 
366 	{ MSG_ORIG(MSG_DT_DEBUG),		DT_DEBUG },
367 	{ MSG_ORIG(MSG_DT_DEBUG_ALT1),		DT_DEBUG },
368 
369 	{ MSG_ORIG(MSG_DT_TEXTREL),		DT_TEXTREL },
370 	{ MSG_ORIG(MSG_DT_TEXTREL_ALT1),	DT_TEXTREL },
371 
372 	{ MSG_ORIG(MSG_DT_JMPREL),		DT_JMPREL },
373 	{ MSG_ORIG(MSG_DT_JMPREL_ALT1),		DT_JMPREL },
374 
375 	{ MSG_ORIG(MSG_DT_BIND_NOW),		DT_BIND_NOW },
376 	{ MSG_ORIG(MSG_DT_BIND_NOW_ALT1),	DT_BIND_NOW },
377 
378 	{ MSG_ORIG(MSG_DT_INIT_ARRAY),		DT_INIT_ARRAY },
379 	{ MSG_ORIG(MSG_DT_INIT_ARRAY_ALT1),	DT_INIT_ARRAY },
380 
381 	{ MSG_ORIG(MSG_DT_FINI_ARRAY),		DT_FINI_ARRAY },
382 	{ MSG_ORIG(MSG_DT_FINI_ARRAY_ALT1),	DT_FINI_ARRAY },
383 
384 	{ MSG_ORIG(MSG_DT_INIT_ARRAYSZ),	DT_INIT_ARRAYSZ },
385 	{ MSG_ORIG(MSG_DT_INIT_ARRAYSZ_ALT1),	DT_INIT_ARRAYSZ },
386 
387 	{ MSG_ORIG(MSG_DT_FINI_ARRAYSZ),	DT_FINI_ARRAYSZ },
388 	{ MSG_ORIG(MSG_DT_FINI_ARRAYSZ_ALT1),	DT_FINI_ARRAYSZ },
389 
390 	{ MSG_ORIG(MSG_DT_RUNPATH),		DT_RUNPATH },
391 	{ MSG_ORIG(MSG_DT_RUNPATH_ALT1),	DT_RUNPATH },
392 
393 	{ MSG_ORIG(MSG_DT_FLAGS),		DT_FLAGS },
394 	{ MSG_ORIG(MSG_DT_FLAGS_ALT1),		DT_FLAGS },
395 
396 	{ MSG_ORIG(MSG_DT_PREINIT_ARRAY),	DT_PREINIT_ARRAY },
397 	{ MSG_ORIG(MSG_DT_PREINIT_ARRAY_ALT1),	DT_PREINIT_ARRAY },
398 
399 	{ MSG_ORIG(MSG_DT_PREINIT_ARRAYSZ),	DT_PREINIT_ARRAYSZ },
400 	{ MSG_ORIG(MSG_DT_PREINIT_ARRAYSZ_ALT1), DT_PREINIT_ARRAYSZ },
401 
402 	{ MSG_ORIG(MSG_DT_SUNW_AUXILIARY),	DT_SUNW_AUXILIARY },
403 	{ MSG_ORIG(MSG_DT_SUNW_AUXILIARY_ALT1),	DT_SUNW_AUXILIARY },
404 
405 	{ MSG_ORIG(MSG_DT_SUNW_RTLDINF),	DT_SUNW_RTLDINF },
406 	{ MSG_ORIG(MSG_DT_SUNW_RTLDINF_ALT1),	DT_SUNW_RTLDINF },
407 
408 	{ MSG_ORIG(MSG_DT_SUNW_FILTER),		DT_SUNW_FILTER },
409 	{ MSG_ORIG(MSG_DT_SUNW_FILTER_ALT1),	DT_SUNW_FILTER },
410 
411 	{ MSG_ORIG(MSG_DT_SUNW_CAP),		DT_SUNW_CAP },
412 	{ MSG_ORIG(MSG_DT_SUNW_CAP_ALT1),	DT_SUNW_CAP },
413 
414 	{ MSG_ORIG(MSG_DT_SUNW_SYMTAB),		DT_SUNW_SYMTAB },
415 	{ MSG_ORIG(MSG_DT_SUNW_SYMTAB_ALT1),	DT_SUNW_SYMTAB },
416 
417 	{ MSG_ORIG(MSG_DT_SUNW_SYMSZ),		DT_SUNW_SYMSZ },
418 	{ MSG_ORIG(MSG_DT_SUNW_SYMSZ_ALT1),	DT_SUNW_SYMSZ },
419 
420 	{ MSG_ORIG(MSG_DT_SUNW_SORTENT),	DT_SUNW_SORTENT },
421 	{ MSG_ORIG(MSG_DT_SUNW_SORTENT_ALT1),	DT_SUNW_SORTENT },
422 
423 	{ MSG_ORIG(MSG_DT_SUNW_SYMSORT),	DT_SUNW_SYMSORT },
424 	{ MSG_ORIG(MSG_DT_SUNW_SYMSORT_ALT1),	DT_SUNW_SYMSORT },
425 
426 	{ MSG_ORIG(MSG_DT_SUNW_SYMSORTSZ),	DT_SUNW_SYMSORTSZ },
427 	{ MSG_ORIG(MSG_DT_SUNW_SYMSORTSZ_ALT1),	DT_SUNW_SYMSORTSZ },
428 
429 	{ MSG_ORIG(MSG_DT_SUNW_TLSSORT),	DT_SUNW_TLSSORT },
430 	{ MSG_ORIG(MSG_DT_SUNW_TLSSORT_ALT1),	DT_SUNW_TLSSORT },
431 
432 	{ MSG_ORIG(MSG_DT_SUNW_TLSSORTSZ),	DT_SUNW_TLSSORTSZ },
433 	{ MSG_ORIG(MSG_DT_SUNW_TLSSORTSZ_ALT1),	DT_SUNW_TLSSORTSZ },
434 
435 	{ MSG_ORIG(MSG_DT_SUNW_STRPAD),		DT_SUNW_STRPAD },
436 	{ MSG_ORIG(MSG_DT_SUNW_STRPAD_ALT1),	DT_SUNW_STRPAD },
437 
438 	{ MSG_ORIG(MSG_DT_SUNW_LDMACH),		DT_SUNW_LDMACH },
439 	{ MSG_ORIG(MSG_DT_SUNW_LDMACH_ALT1),	DT_SUNW_LDMACH },
440 
441 	{ MSG_ORIG(MSG_DT_SPARC_REGISTER),	DT_SPARC_REGISTER },
442 	{ MSG_ORIG(MSG_DT_SPARC_REGISTER_ALT1),	DT_SPARC_REGISTER },
443 
444 	{ MSG_ORIG(MSG_DT_DEPRECATED_SPARC_REGISTER),
445 						DT_DEPRECATED_SPARC_REGISTER },
446 	{ MSG_ORIG(MSG_DT_DEPRECATED_SPARC_REGISTER_ALT1),
447 						DT_DEPRECATED_SPARC_REGISTER },
448 
449 	{ MSG_ORIG(MSG_DT_CHECKSUM),		DT_CHECKSUM },
450 	{ MSG_ORIG(MSG_DT_CHECKSUM_ALT1),	DT_CHECKSUM },
451 
452 	{ MSG_ORIG(MSG_DT_PLTPADSZ),		DT_PLTPADSZ },
453 	{ MSG_ORIG(MSG_DT_PLTPADSZ_ALT1),	DT_PLTPADSZ },
454 
455 	{ MSG_ORIG(MSG_DT_MOVEENT),		DT_MOVEENT },
456 	{ MSG_ORIG(MSG_DT_MOVEENT_ALT1),	DT_MOVEENT },
457 
458 	{ MSG_ORIG(MSG_DT_MOVESZ),		DT_MOVESZ },
459 	{ MSG_ORIG(MSG_DT_MOVESZ_ALT1),		DT_MOVESZ },
460 
461 	{ MSG_ORIG(MSG_DT_FEATURE_1),		DT_FEATURE_1 },
462 	{ MSG_ORIG(MSG_DT_FEATURE_1_ALT1),	DT_FEATURE_1 },
463 
464 	{ MSG_ORIG(MSG_DT_POSFLAG_1),		DT_POSFLAG_1 },
465 	{ MSG_ORIG(MSG_DT_POSFLAG_1_ALT1),	DT_POSFLAG_1 },
466 
467 	{ MSG_ORIG(MSG_DT_SYMINSZ),		DT_SYMINSZ },
468 	{ MSG_ORIG(MSG_DT_SYMINSZ_ALT1),	DT_SYMINSZ },
469 
470 	{ MSG_ORIG(MSG_DT_SYMINENT),		DT_SYMINENT },
471 	{ MSG_ORIG(MSG_DT_SYMINENT_ALT1),	DT_SYMINENT },
472 
473 	{ MSG_ORIG(MSG_DT_CONFIG),		DT_CONFIG },
474 	{ MSG_ORIG(MSG_DT_CONFIG_ALT1),		DT_CONFIG },
475 
476 	{ MSG_ORIG(MSG_DT_DEPAUDIT),		DT_DEPAUDIT },
477 	{ MSG_ORIG(MSG_DT_DEPAUDIT_ALT1),	DT_DEPAUDIT },
478 
479 	{ MSG_ORIG(MSG_DT_AUDIT),		DT_AUDIT },
480 	{ MSG_ORIG(MSG_DT_AUDIT_ALT1),		DT_AUDIT },
481 
482 	{ MSG_ORIG(MSG_DT_PLTPAD),		DT_PLTPAD },
483 	{ MSG_ORIG(MSG_DT_PLTPAD_ALT1),		DT_PLTPAD },
484 
485 	{ MSG_ORIG(MSG_DT_MOVETAB),		DT_MOVETAB },
486 	{ MSG_ORIG(MSG_DT_MOVETAB_ALT1),	DT_MOVETAB },
487 
488 	{ MSG_ORIG(MSG_DT_SYMINFO),		DT_SYMINFO },
489 	{ MSG_ORIG(MSG_DT_SYMINFO_ALT1),	DT_SYMINFO },
490 
491 	{ MSG_ORIG(MSG_DT_VERSYM),		DT_VERSYM },
492 	{ MSG_ORIG(MSG_DT_VERSYM_ALT1),		DT_VERSYM },
493 
494 	{ MSG_ORIG(MSG_DT_RELACOUNT),		DT_RELACOUNT },
495 	{ MSG_ORIG(MSG_DT_RELACOUNT_ALT1),	DT_RELACOUNT },
496 
497 	{ MSG_ORIG(MSG_DT_RELCOUNT),		DT_RELCOUNT },
498 	{ MSG_ORIG(MSG_DT_RELCOUNT_ALT1),	DT_RELCOUNT },
499 
500 	{ MSG_ORIG(MSG_DT_FLAGS_1),		DT_FLAGS_1 },
501 	{ MSG_ORIG(MSG_DT_FLAGS_1_ALT1),	DT_FLAGS_1 },
502 
503 	{ MSG_ORIG(MSG_DT_VERDEF),		DT_VERDEF },
504 	{ MSG_ORIG(MSG_DT_VERDEF_ALT1),		DT_VERDEF },
505 
506 	{ MSG_ORIG(MSG_DT_VERDEFNUM),		DT_VERDEFNUM },
507 	{ MSG_ORIG(MSG_DT_VERDEFNUM_ALT1),	DT_VERDEFNUM },
508 
509 	{ MSG_ORIG(MSG_DT_VERNEED),		DT_VERNEED },
510 	{ MSG_ORIG(MSG_DT_VERNEED_ALT1),	DT_VERNEED },
511 
512 	{ MSG_ORIG(MSG_DT_VERNEEDNUM),		DT_VERNEEDNUM },
513 	{ MSG_ORIG(MSG_DT_VERNEEDNUM_ALT1),	DT_VERNEEDNUM },
514 
515 	{ MSG_ORIG(MSG_DT_AUXILIARY),		DT_AUXILIARY },
516 	{ MSG_ORIG(MSG_DT_AUXILIARY_ALT1),	DT_AUXILIARY },
517 
518 	{ MSG_ORIG(MSG_DT_USED),		DT_USED },
519 	{ MSG_ORIG(MSG_DT_USED_ALT1),		DT_USED },
520 
521 	{ MSG_ORIG(MSG_DT_FILTER),		DT_FILTER },
522 	{ MSG_ORIG(MSG_DT_FILTER_ALT1),		DT_FILTER },
523 
524 	{ NULL }
525 };
526 
527 
528 /*
529  * ELF DT_FLAGS DF_* values
530  */
531 static elfedit_atoui_sym_t sym_df[] = {
532 	{ MSG_ORIG(MSG_DF_ORIGIN),		DF_ORIGIN },
533 	{ MSG_ORIG(MSG_DF_ORIGIN_ALT1),		DF_ORIGIN },
534 
535 	{ MSG_ORIG(MSG_DF_SYMBOLIC),		DF_SYMBOLIC },
536 	{ MSG_ORIG(MSG_DF_SYMBOLIC_ALT1),	DF_SYMBOLIC },
537 
538 	{ MSG_ORIG(MSG_DF_TEXTREL),		DF_TEXTREL },
539 	{ MSG_ORIG(MSG_DF_TEXTREL_ALT1),	DF_TEXTREL },
540 
541 	{ MSG_ORIG(MSG_DF_BIND_NOW),		DF_BIND_NOW },
542 	{ MSG_ORIG(MSG_DF_BIND_NOW_ALT1),	DF_BIND_NOW },
543 
544 	{ MSG_ORIG(MSG_DF_STATIC_TLS),		DF_STATIC_TLS },
545 	{ MSG_ORIG(MSG_DF_STATIC_TLS_ALT1),	DF_STATIC_TLS },
546 
547 	{ NULL }
548 };
549 
550 
551 /*
552  * ELF DT_POSFLAG_1 DF_P1_* values
553  */
554 static elfedit_atoui_sym_t sym_df_p1[] = {
555 	{ MSG_ORIG(MSG_DF_P1_LAZYLOAD),		DF_P1_LAZYLOAD },
556 	{ MSG_ORIG(MSG_DF_P1_LAZYLOAD_ALT1),	DF_P1_LAZYLOAD },
557 
558 	{ MSG_ORIG(MSG_DF_P1_GROUPPERM),	DF_P1_GROUPPERM },
559 	{ MSG_ORIG(MSG_DF_P1_GROUPPERM_ALT1),	DF_P1_GROUPPERM },
560 
561 	{ NULL }
562 };
563 
564 
565 /*
566  * ELF DT_FLAGS_1 DF_1_* values
567  */
568 static elfedit_atoui_sym_t sym_df_1[] = {
569 	{ MSG_ORIG(MSG_DF_1_NOW),		DF_1_NOW },
570 	{ MSG_ORIG(MSG_DF_1_NOW_ALT1),		DF_1_NOW },
571 
572 	{ MSG_ORIG(MSG_DF_1_GLOBAL),		DF_1_GLOBAL },
573 	{ MSG_ORIG(MSG_DF_1_GLOBAL_ALT1),	DF_1_GLOBAL },
574 
575 	{ MSG_ORIG(MSG_DF_1_GROUP),		DF_1_GROUP },
576 	{ MSG_ORIG(MSG_DF_1_GROUP_ALT1),	DF_1_GROUP },
577 
578 	{ MSG_ORIG(MSG_DF_1_NODELETE),		DF_1_NODELETE },
579 	{ MSG_ORIG(MSG_DF_1_NODELETE_ALT1),	DF_1_NODELETE },
580 
581 	{ MSG_ORIG(MSG_DF_1_LOADFLTR),		DF_1_LOADFLTR },
582 	{ MSG_ORIG(MSG_DF_1_LOADFLTR_ALT1),	DF_1_LOADFLTR },
583 
584 	{ MSG_ORIG(MSG_DF_1_INITFIRST),		DF_1_INITFIRST },
585 	{ MSG_ORIG(MSG_DF_1_INITFIRST_ALT1),	DF_1_INITFIRST },
586 
587 	{ MSG_ORIG(MSG_DF_1_NOOPEN),		DF_1_NOOPEN },
588 	{ MSG_ORIG(MSG_DF_1_NOOPEN_ALT1),	DF_1_NOOPEN },
589 
590 	{ MSG_ORIG(MSG_DF_1_ORIGIN),		DF_1_ORIGIN },
591 	{ MSG_ORIG(MSG_DF_1_ORIGIN_ALT1),	DF_1_ORIGIN },
592 
593 	{ MSG_ORIG(MSG_DF_1_DIRECT),		DF_1_DIRECT },
594 	{ MSG_ORIG(MSG_DF_1_DIRECT_ALT1),	DF_1_DIRECT },
595 
596 	{ MSG_ORIG(MSG_DF_1_TRANS),		DF_1_TRANS },
597 	{ MSG_ORIG(MSG_DF_1_TRANS_ALT1),	DF_1_TRANS },
598 
599 	{ MSG_ORIG(MSG_DF_1_INTERPOSE),		DF_1_INTERPOSE },
600 	{ MSG_ORIG(MSG_DF_1_INTERPOSE_ALT1),	DF_1_INTERPOSE },
601 
602 	{ MSG_ORIG(MSG_DF_1_NODEFLIB),		DF_1_NODEFLIB },
603 	{ MSG_ORIG(MSG_DF_1_NODEFLIB_ALT1),	DF_1_NODEFLIB },
604 
605 	{ MSG_ORIG(MSG_DF_1_NODUMP),		DF_1_NODUMP },
606 	{ MSG_ORIG(MSG_DF_1_NODUMP_ALT1),	DF_1_NODUMP },
607 
608 	{ MSG_ORIG(MSG_DF_1_CONFALT),		DF_1_CONFALT },
609 	{ MSG_ORIG(MSG_DF_1_CONFALT_ALT1),	DF_1_CONFALT },
610 
611 	{ MSG_ORIG(MSG_DF_1_ENDFILTEE),		DF_1_ENDFILTEE },
612 	{ MSG_ORIG(MSG_DF_1_ENDFILTEE_ALT1),	DF_1_ENDFILTEE },
613 
614 	{ MSG_ORIG(MSG_DF_1_DISPRELDNE),	DF_1_DISPRELDNE },
615 	{ MSG_ORIG(MSG_DF_1_DISPRELDNE_ALT1),	DF_1_DISPRELDNE },
616 
617 	{ MSG_ORIG(MSG_DF_1_DISPRELPND),	DF_1_DISPRELPND },
618 	{ MSG_ORIG(MSG_DF_1_DISPRELPND_ALT1),	DF_1_DISPRELPND },
619 
620 	{ MSG_ORIG(MSG_DF_1_NODIRECT),		DF_1_NODIRECT },
621 	{ MSG_ORIG(MSG_DF_1_NODIRECT_ALT1),	DF_1_NODIRECT },
622 
623 	{ MSG_ORIG(MSG_DF_1_IGNMULDEF),		DF_1_IGNMULDEF },
624 	{ MSG_ORIG(MSG_DF_1_IGNMULDEF_ALT1),	DF_1_IGNMULDEF },
625 
626 	{ MSG_ORIG(MSG_DF_1_NOKSYMS),		DF_1_NOKSYMS },
627 	{ MSG_ORIG(MSG_DF_1_NOKSYMS_ALT1),	DF_1_NOKSYMS },
628 
629 	{ MSG_ORIG(MSG_DF_1_NOHDR),		DF_1_NOHDR },
630 	{ MSG_ORIG(MSG_DF_1_NOHDR_ALT1),	DF_1_NOHDR },
631 
632 	{ MSG_ORIG(MSG_DF_1_EDITED),		DF_1_EDITED },
633 	{ MSG_ORIG(MSG_DF_1_EDITED_ALT1),	DF_1_EDITED },
634 
635 	{ MSG_ORIG(MSG_DF_1_NORELOC),		DF_1_NORELOC },
636 	{ MSG_ORIG(MSG_DF_1_NORELOC_ALT1),	DF_1_NORELOC },
637 
638 	{ MSG_ORIG(MSG_DF_1_SYMINTPOSE),	DF_1_SYMINTPOSE },
639 	{ MSG_ORIG(MSG_DF_1_SYMINTPOSE_ALT1),	DF_1_SYMINTPOSE },
640 
641 	{ MSG_ORIG(MSG_DF_1_GLOBAUDIT),		DF_1_GLOBAUDIT },
642 	{ MSG_ORIG(MSG_DF_1_GLOBAUDIT_ALT1),	DF_1_GLOBAUDIT },
643 
644 	{ NULL }
645 };
646 
647 
648 /*
649  * ELF DT_FEATURE_1 DTF_1_* values
650  */
651 static elfedit_atoui_sym_t sym_dtf_1[] = {
652 	{ MSG_ORIG(MSG_DTF_1_PARINIT),		DTF_1_PARINIT },
653 	{ MSG_ORIG(MSG_DTF_1_PARINIT_ALT1),	DTF_1_PARINIT },
654 
655 	{ MSG_ORIG(MSG_DTF_1_CONFEXP),		DTF_1_CONFEXP },
656 	{ MSG_ORIG(MSG_DTF_1_CONFEXP_ALT1),	DTF_1_CONFEXP },
657 
658 	{ NULL }
659 };
660 
661 /*
662  * ELF header EI_* indexes
663  */
664 static elfedit_atoui_sym_t sym_ei[] = {
665 	{ MSG_ORIG(MSG_EI_MAG0),		EI_MAG0 },
666 	{ MSG_ORIG(MSG_EI_MAG0_ALT1),		EI_MAG0 },
667 
668 	{ MSG_ORIG(MSG_EI_MAG1),		EI_MAG1 },
669 	{ MSG_ORIG(MSG_EI_MAG1_ALT1),		EI_MAG1 },
670 
671 	{ MSG_ORIG(MSG_EI_MAG2),		EI_MAG2 },
672 	{ MSG_ORIG(MSG_EI_MAG2_ALT1),		EI_MAG2 },
673 
674 	{ MSG_ORIG(MSG_EI_MAG3),		EI_MAG3 },
675 	{ MSG_ORIG(MSG_EI_MAG3_ALT1),		EI_MAG3 },
676 
677 	{ MSG_ORIG(MSG_EI_CLASS),		EI_CLASS },
678 	{ MSG_ORIG(MSG_EI_CLASS_ALT1),		EI_CLASS },
679 
680 	{ MSG_ORIG(MSG_EI_DATA),		EI_DATA },
681 	{ MSG_ORIG(MSG_EI_DATA_ALT1),		EI_DATA },
682 
683 	{ MSG_ORIG(MSG_EI_VERSION),		EI_VERSION },
684 	{ MSG_ORIG(MSG_EI_VERSION_ALT1),	EI_VERSION },
685 
686 	{ MSG_ORIG(MSG_EI_OSABI),		EI_OSABI },
687 	{ MSG_ORIG(MSG_EI_OSABI_ALT1),		EI_OSABI },
688 
689 	{ MSG_ORIG(MSG_EI_ABIVERSION),		EI_ABIVERSION },
690 	{ MSG_ORIG(MSG_EI_ABIVERSION_ALT1),	EI_ABIVERSION },
691 
692 	{ NULL }
693 };
694 
695 /*
696  * ELF header ET_* file type values
697  */
698 static elfedit_atoui_sym_t sym_et[] = {
699 	{ MSG_ORIG(MSG_ET_NONE),		ET_NONE },
700 	{ MSG_ORIG(MSG_ET_NONE_ALT1),		ET_NONE },
701 
702 	{ MSG_ORIG(MSG_ET_REL),			ET_REL },
703 	{ MSG_ORIG(MSG_ET_REL_ALT1),		ET_REL },
704 
705 	{ MSG_ORIG(MSG_ET_EXEC),		ET_EXEC },
706 	{ MSG_ORIG(MSG_ET_EXEC_ALT1),		ET_EXEC },
707 
708 	{ MSG_ORIG(MSG_ET_DYN),			ET_DYN },
709 	{ MSG_ORIG(MSG_ET_DYN_ALT1),		ET_DYN },
710 
711 	{ MSG_ORIG(MSG_ET_CORE),		ET_CORE },
712 	{ MSG_ORIG(MSG_ET_CORE_ALT1),		ET_CORE },
713 
714 	{ NULL }
715 };
716 
717 /*
718  * ELFCLASS
719  */
720 static elfedit_atoui_sym_t sym_elfclass[] = {
721 	{ MSG_ORIG(MSG_ELFCLASSNONE),		ELFCLASSNONE },
722 	{ MSG_ORIG(MSG_ELFCLASSNONE_ALT1),	ELFCLASSNONE },
723 
724 	{ MSG_ORIG(MSG_ELFCLASS32),		ELFCLASS32 },
725 	{ MSG_ORIG(MSG_ELFCLASS32_ALT1),	ELFCLASS32 },
726 
727 	{ MSG_ORIG(MSG_ELFCLASS64),		ELFCLASS64 },
728 	{ MSG_ORIG(MSG_ELFCLASS64_ALT1),	ELFCLASS64 },
729 
730 	{ NULL }
731 };
732 
733 /*
734  * ELFDATA
735  */
736 static elfedit_atoui_sym_t sym_elfdata[] = {
737 	{ MSG_ORIG(MSG_ELFDATANONE),		ELFDATANONE },
738 	{ MSG_ORIG(MSG_ELFDATANONE_ALT1),	ELFDATANONE },
739 
740 	{ MSG_ORIG(MSG_ELFDATA2LSB),		ELFDATA2LSB },
741 	{ MSG_ORIG(MSG_ELFDATA2LSB_ALT1),	ELFDATA2LSB },
742 
743 	{ MSG_ORIG(MSG_ELFDATA2MSB),		ELFDATA2MSB },
744 	{ MSG_ORIG(MSG_ELFDATA2MSB_ALT1),	ELFDATA2MSB },
745 
746 	{ NULL }
747 };
748 
749 /*
750  * ELF header EF_* flags
751  */
752 static elfedit_atoui_sym_t sym_ef[] = {
753 	{ MSG_ORIG(MSG_EF_SPARC_32PLUS),	EF_SPARC_32PLUS },
754 	{ MSG_ORIG(MSG_EF_SPARC_32PLUS_ALT1),	EF_SPARC_32PLUS },
755 
756 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US1),	EF_SPARC_SUN_US1 },
757 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US1_ALT1),	EF_SPARC_SUN_US1 },
758 
759 	{ MSG_ORIG(MSG_EF_SPARC_HAL_R1),	EF_SPARC_HAL_R1 },
760 	{ MSG_ORIG(MSG_EF_SPARC_HAL_R1_ALT1),	EF_SPARC_HAL_R1 },
761 
762 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US3),	EF_SPARC_SUN_US3 },
763 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US3_ALT1),	EF_SPARC_SUN_US3 },
764 
765 	{ MSG_ORIG(MSG_EF_SPARCV9_MM),		EF_SPARCV9_MM },
766 	{ MSG_ORIG(MSG_EF_SPARCV9_MM_ALT1),	EF_SPARCV9_MM },
767 
768 	{ MSG_ORIG(MSG_EF_SPARCV9_TSO),		EF_SPARCV9_TSO },
769 	{ MSG_ORIG(MSG_EF_SPARCV9_TSO_ALT1),	EF_SPARCV9_TSO },
770 
771 	{ MSG_ORIG(MSG_EF_SPARCV9_PSO),		EF_SPARCV9_PSO },
772 	{ MSG_ORIG(MSG_EF_SPARCV9_PSO_ALT1),	EF_SPARCV9_PSO },
773 
774 	{ MSG_ORIG(MSG_EF_SPARCV9_RMO),		EF_SPARCV9_RMO },
775 	{ MSG_ORIG(MSG_EF_SPARCV9_RMO_ALT1),	EF_SPARCV9_RMO },
776 
777 	{ NULL }
778 };
779 
780 /*
781  * ELF header EV_* versions
782  */
783 static elfedit_atoui_sym_t sym_ev[] = {
784 	{ MSG_ORIG(MSG_EV_NONE),		EV_NONE },
785 	{ MSG_ORIG(MSG_EV_NONE_ALT1),		EV_NONE },
786 
787 	{ MSG_ORIG(MSG_EV_CURRENT),		EV_CURRENT },
788 	{ MSG_ORIG(MSG_EV_CURRENT_ALT1),	EV_CURRENT },
789 
790 	{ NULL }
791 };
792 
793 /*
794  * ELF EM_* machine types
795  */
796 static elfedit_atoui_sym_t sym_em[] = {
797 	{ MSG_ORIG(MSG_EM_NONE),		EM_NONE },
798 	{ MSG_ORIG(MSG_EM_NONE_ALT1),		EM_NONE },
799 
800 	{ MSG_ORIG(MSG_EM_M32),			EM_M32 },
801 	{ MSG_ORIG(MSG_EM_M32_ALT1),		EM_M32 },
802 	{ MSG_ORIG(MSG_EM_M32_ALT2),		EM_M32 },
803 
804 	{ MSG_ORIG(MSG_EM_SPARC),		EM_SPARC },
805 	{ MSG_ORIG(MSG_EM_SPARC_ALT1),		EM_SPARC },
806 
807 	{ MSG_ORIG(MSG_EM_386),			EM_386 },
808 	{ MSG_ORIG(MSG_EM_386_ALT1),		EM_386 },
809 	{ MSG_ORIG(MSG_EM_386_ALT2),		EM_386 },
810 
811 	{ MSG_ORIG(MSG_EM_68K),			EM_68K },
812 	{ MSG_ORIG(MSG_EM_68K_ALT1),		EM_68K },
813 	{ MSG_ORIG(MSG_EM_68K_ALT2),		EM_68K },
814 
815 	{ MSG_ORIG(MSG_EM_88K),			EM_88K },
816 	{ MSG_ORIG(MSG_EM_88K_ALT1),		EM_88K },
817 	{ MSG_ORIG(MSG_EM_88K_ALT2),		EM_88K },
818 
819 	{ MSG_ORIG(MSG_EM_486),			EM_486 },
820 	{ MSG_ORIG(MSG_EM_486_ALT1),		EM_486 },
821 	{ MSG_ORIG(MSG_EM_486_ALT2),		EM_486 },
822 
823 	{ MSG_ORIG(MSG_EM_860),			EM_860 },
824 	{ MSG_ORIG(MSG_EM_860_ALT1),		EM_860 },
825 	{ MSG_ORIG(MSG_EM_860_ALT2),		EM_860 },
826 
827 	{ MSG_ORIG(MSG_EM_MIPS),		EM_MIPS },
828 	{ MSG_ORIG(MSG_EM_MIPS_ALT1),		EM_MIPS },
829 	{ MSG_ORIG(MSG_EM_MIPS_ALT2),		EM_MIPS },
830 
831 	{ MSG_ORIG(MSG_EM_S370),		EM_S370 },
832 	{ MSG_ORIG(MSG_EM_S370_ALT1),		EM_S370 },
833 
834 	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE),		EM_MIPS_RS3_LE },
835 	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE_ALT1),	EM_MIPS_RS3_LE },
836 	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE_ALT2),	EM_MIPS_RS3_LE },
837 
838 	{ MSG_ORIG(MSG_EM_RS6000),		EM_RS6000 },
839 	{ MSG_ORIG(MSG_EM_RS6000_ALT1),		EM_RS6000 },
840 
841 	{ MSG_ORIG(MSG_EM_PA_RISC),		EM_PA_RISC },
842 	{ MSG_ORIG(MSG_EM_PA_RISC_ALT1),	EM_PA_RISC },
843 
844 	{ MSG_ORIG(MSG_EM_NCUBE),		EM_nCUBE },
845 	{ MSG_ORIG(MSG_EM_NCUBE_ALT1),		EM_nCUBE },
846 
847 	{ MSG_ORIG(MSG_EM_VPP500),		EM_VPP500 },
848 	{ MSG_ORIG(MSG_EM_VPP500_ALT1),		EM_VPP500 },
849 
850 	{ MSG_ORIG(MSG_EM_SPARC32PLUS),		EM_SPARC32PLUS },
851 	{ MSG_ORIG(MSG_EM_SPARC32PLUS_ALT1),	EM_SPARC32PLUS },
852 
853 	{ MSG_ORIG(MSG_EM_960),			EM_960 },
854 	{ MSG_ORIG(MSG_EM_960_ALT1),		EM_960 },
855 
856 	{ MSG_ORIG(MSG_EM_PPC),			EM_PPC },
857 	{ MSG_ORIG(MSG_EM_PPC_ALT1),		EM_PPC },
858 	{ MSG_ORIG(MSG_EM_PPC_ALT2),		EM_PPC },
859 
860 	{ MSG_ORIG(MSG_EM_PPC64),		EM_PPC64 },
861 	{ MSG_ORIG(MSG_EM_PPC64_ALT1),		EM_PPC64 },
862 	{ MSG_ORIG(MSG_EM_PPC64_ALT2),		EM_PPC64 },
863 
864 	{ MSG_ORIG(MSG_EM_S390),		EM_S390 },
865 	{ MSG_ORIG(MSG_EM_S390_ALT1),		EM_S390 },
866 
867 	{ MSG_ORIG(MSG_EM_V800),		EM_V800 },
868 	{ MSG_ORIG(MSG_EM_V800_ALT1),		EM_V800 },
869 
870 	{ MSG_ORIG(MSG_EM_FR20),		EM_FR20 },
871 	{ MSG_ORIG(MSG_EM_FR20_ALT1),		EM_FR20 },
872 
873 	{ MSG_ORIG(MSG_EM_RH32),		EM_RH32 },
874 	{ MSG_ORIG(MSG_EM_RH32_ALT1),		EM_RH32 },
875 
876 	{ MSG_ORIG(MSG_EM_RCE),			EM_RCE },
877 	{ MSG_ORIG(MSG_EM_RCE_ALT1),		EM_RCE },
878 
879 	{ MSG_ORIG(MSG_EM_ARM),			EM_ARM },
880 	{ MSG_ORIG(MSG_EM_ARM_ALT1),		EM_ARM },
881 
882 	{ MSG_ORIG(MSG_EM_ALPHA),		EM_ALPHA },
883 	{ MSG_ORIG(MSG_EM_ALPHA_ALT1),		EM_ALPHA },
884 
885 	{ MSG_ORIG(MSG_EM_SH),			EM_SH },
886 	{ MSG_ORIG(MSG_EM_SH_ALT1),		EM_SH },
887 
888 	{ MSG_ORIG(MSG_EM_SPARCV9),		EM_SPARCV9 },
889 	{ MSG_ORIG(MSG_EM_SPARCV9_ALT1),	EM_SPARCV9 },
890 
891 	{ MSG_ORIG(MSG_EM_TRICORE),		EM_TRICORE },
892 	{ MSG_ORIG(MSG_EM_TRICORE_ALT1),	EM_TRICORE },
893 
894 	{ MSG_ORIG(MSG_EM_ARC),			EM_ARC },
895 	{ MSG_ORIG(MSG_EM_ARC_ALT1),		EM_ARC },
896 
897 	{ MSG_ORIG(MSG_EM_H8_300),		EM_H8_300 },
898 	{ MSG_ORIG(MSG_EM_H8_300_ALT1),		EM_H8_300 },
899 
900 	{ MSG_ORIG(MSG_EM_H8_300H),		EM_H8_300H },
901 	{ MSG_ORIG(MSG_EM_H8_300H_ALT1),	EM_H8_300H },
902 
903 	{ MSG_ORIG(MSG_EM_H8S),			EM_H8S },
904 	{ MSG_ORIG(MSG_EM_H8S_ALT1),		EM_H8S },
905 
906 	{ MSG_ORIG(MSG_EM_H8_500),		EM_H8_500 },
907 	{ MSG_ORIG(MSG_EM_H8_500_ALT1),		EM_H8_500 },
908 
909 	{ MSG_ORIG(MSG_EM_IA_64),		EM_IA_64 },
910 	{ MSG_ORIG(MSG_EM_IA_64_ALT1),		EM_IA_64 },
911 
912 	{ MSG_ORIG(MSG_EM_MIPS_X),		EM_MIPS_X },
913 	{ MSG_ORIG(MSG_EM_MIPS_X_ALT1),		EM_MIPS_X },
914 
915 	{ MSG_ORIG(MSG_EM_COLDFIRE),		EM_COLDFIRE },
916 	{ MSG_ORIG(MSG_EM_COLDFIRE_ALT1),	EM_COLDFIRE },
917 
918 	{ MSG_ORIG(MSG_EM_68HC12),		EM_68HC12 },
919 	{ MSG_ORIG(MSG_EM_68HC12_ALT1),		EM_68HC12 },
920 
921 	{ MSG_ORIG(MSG_EM_MMA),			EM_MMA },
922 	{ MSG_ORIG(MSG_EM_MMA_ALT1),		EM_MMA },
923 
924 	{ MSG_ORIG(MSG_EM_PCP),			EM_PCP },
925 	{ MSG_ORIG(MSG_EM_PCP_ALT1),		EM_PCP },
926 
927 	{ MSG_ORIG(MSG_EM_NCPU),		EM_NCPU },
928 	{ MSG_ORIG(MSG_EM_NCPU_ALT1),		EM_NCPU },
929 
930 	{ MSG_ORIG(MSG_EM_NDR1),		EM_NDR1 },
931 	{ MSG_ORIG(MSG_EM_NDR1_ALT1),		EM_NDR1 },
932 
933 	{ MSG_ORIG(MSG_EM_STARCORE),		EM_STARCORE },
934 	{ MSG_ORIG(MSG_EM_STARCORE_ALT1),	EM_STARCORE },
935 
936 	{ MSG_ORIG(MSG_EM_ME16),		EM_ME16 },
937 	{ MSG_ORIG(MSG_EM_ME16_ALT1),		EM_ME16 },
938 
939 	{ MSG_ORIG(MSG_EM_ST100),		EM_ST100 },
940 	{ MSG_ORIG(MSG_EM_ST100_ALT1),		EM_ST100 },
941 
942 	{ MSG_ORIG(MSG_EM_TINYJ),		EM_TINYJ },
943 	{ MSG_ORIG(MSG_EM_TINYJ_ALT1),		EM_TINYJ },
944 
945 	{ MSG_ORIG(MSG_EM_AMD64),		EM_AMD64 },
946 	{ MSG_ORIG(MSG_EM_AMD64_ALT1),		EM_AMD64 },
947 
948 	{ MSG_ORIG(MSG_EM_PDSP),		EM_PDSP },
949 	{ MSG_ORIG(MSG_EM_PDSP_ALT1),		EM_PDSP },
950 
951 	{ MSG_ORIG(MSG_EM_FX66),		EM_FX66 },
952 	{ MSG_ORIG(MSG_EM_FX66_ALT1),		EM_FX66 },
953 
954 	{ MSG_ORIG(MSG_EM_ST9PLUS),		EM_ST9PLUS },
955 	{ MSG_ORIG(MSG_EM_ST9PLUS_ALT1),	EM_ST9PLUS },
956 
957 	{ MSG_ORIG(MSG_EM_ST7),			EM_ST7 },
958 	{ MSG_ORIG(MSG_EM_ST7_ALT1),		EM_ST7 },
959 
960 	{ MSG_ORIG(MSG_EM_68HC16),		EM_68HC16 },
961 	{ MSG_ORIG(MSG_EM_68HC16_ALT1),		EM_68HC16 },
962 
963 	{ MSG_ORIG(MSG_EM_68HC11),		EM_68HC11 },
964 	{ MSG_ORIG(MSG_EM_68HC11_ALT1),		EM_68HC11 },
965 
966 	{ MSG_ORIG(MSG_EM_68HC08),		EM_68HC08 },
967 	{ MSG_ORIG(MSG_EM_68HC08_ALT1),		EM_68HC08 },
968 
969 	{ MSG_ORIG(MSG_EM_68HC05),		EM_68HC05 },
970 	{ MSG_ORIG(MSG_EM_68HC05_ALT1),		EM_68HC05 },
971 
972 	{ MSG_ORIG(MSG_EM_SVX),			EM_SVX },
973 	{ MSG_ORIG(MSG_EM_SVX_ALT1),		EM_SVX },
974 
975 	{ MSG_ORIG(MSG_EM_ST19),		EM_ST19 },
976 	{ MSG_ORIG(MSG_EM_ST19_ALT1),		EM_ST19 },
977 
978 	{ MSG_ORIG(MSG_EM_VAX),			EM_VAX },
979 	{ MSG_ORIG(MSG_EM_VAX_ALT1),		EM_VAX },
980 
981 	{ MSG_ORIG(MSG_EM_CRIS),		EM_CRIS },
982 	{ MSG_ORIG(MSG_EM_CRIS_ALT1),		EM_CRIS },
983 
984 	{ MSG_ORIG(MSG_EM_JAVELIN),		EM_JAVELIN },
985 	{ MSG_ORIG(MSG_EM_JAVELIN_ALT1),	EM_JAVELIN },
986 
987 	{ MSG_ORIG(MSG_EM_FIREPATH),		EM_FIREPATH },
988 	{ MSG_ORIG(MSG_EM_FIREPATH_ALT1),	EM_FIREPATH },
989 
990 	{ MSG_ORIG(MSG_EM_ZSP),			EM_ZSP },
991 	{ MSG_ORIG(MSG_EM_ZSP_ALT1),		EM_ZSP },
992 
993 	{ MSG_ORIG(MSG_EM_MMIX),		EM_MMIX },
994 	{ MSG_ORIG(MSG_EM_MMIX_ALT1),		EM_MMIX },
995 
996 	{ MSG_ORIG(MSG_EM_HUANY),		EM_HUANY },
997 	{ MSG_ORIG(MSG_EM_HUANY_ALT1),		EM_HUANY },
998 
999 	{ MSG_ORIG(MSG_EM_PRISM),		EM_PRISM },
1000 	{ MSG_ORIG(MSG_EM_PRISM_ALT1),		EM_PRISM },
1001 
1002 	{ MSG_ORIG(MSG_EM_AVR),			EM_AVR },
1003 	{ MSG_ORIG(MSG_EM_AVR_ALT1),		EM_AVR },
1004 
1005 	{ MSG_ORIG(MSG_EM_FR30),		EM_FR30 },
1006 	{ MSG_ORIG(MSG_EM_FR30_ALT1),		EM_FR30 },
1007 
1008 	{ MSG_ORIG(MSG_EM_D10V),		EM_D10V },
1009 	{ MSG_ORIG(MSG_EM_D10V_ALT1),		EM_D10V },
1010 
1011 	{ MSG_ORIG(MSG_EM_D30V),		EM_D30V },
1012 	{ MSG_ORIG(MSG_EM_D30V_ALT1),		EM_D30V },
1013 
1014 	{ MSG_ORIG(MSG_EM_V850),		EM_V850 },
1015 	{ MSG_ORIG(MSG_EM_V850_ALT1),		EM_V850 },
1016 
1017 	{ MSG_ORIG(MSG_EM_M32R),		EM_M32R },
1018 	{ MSG_ORIG(MSG_EM_M32R_ALT1),		EM_M32R },
1019 
1020 	{ MSG_ORIG(MSG_EM_MN10300),		EM_MN10300 },
1021 	{ MSG_ORIG(MSG_EM_MN10300_ALT1),	EM_MN10300 },
1022 
1023 	{ MSG_ORIG(MSG_EM_MN10200),		EM_MN10200 },
1024 	{ MSG_ORIG(MSG_EM_MN10200_ALT1),	EM_MN10200 },
1025 
1026 	{ MSG_ORIG(MSG_EM_PJ),			EM_PJ },
1027 	{ MSG_ORIG(MSG_EM_PJ_ALT1),		EM_PJ },
1028 
1029 	{ MSG_ORIG(MSG_EM_OPENRISC),		EM_OPENRISC },
1030 	{ MSG_ORIG(MSG_EM_OPENRISC_ALT1),	EM_OPENRISC },
1031 
1032 	{ MSG_ORIG(MSG_EM_ARC_A5),		EM_ARC_A5 },
1033 	{ MSG_ORIG(MSG_EM_ARC_A5_ALT1),		EM_ARC_A5 },
1034 
1035 	{ MSG_ORIG(MSG_EM_XTENSA),		EM_XTENSA },
1036 	{ MSG_ORIG(MSG_EM_XTENSA_ALT1),		EM_XTENSA },
1037 
1038 	{ NULL }
1039 };
1040 #if	(EM_NUM != (EM_XTENSA + 1))
1041 #error	"EM_NUM has grown"
1042 #endif
1043 
1044 
1045 /*
1046  * ELF header ELFOSABI_* values (and common aliases)
1047  */
1048 static elfedit_atoui_sym_t sym_elfosabi[] = {
1049 	{ MSG_ORIG(MSG_ELFOSABI_NONE),		ELFOSABI_NONE },
1050 	{ MSG_ORIG(MSG_ELFOSABI_NONE_ALT1),	ELFOSABI_NONE },
1051 
1052 	{ MSG_ORIG(MSG_ELFOSABI_SYSV),		ELFOSABI_SYSV },
1053 	{ MSG_ORIG(MSG_ELFOSABI_SYSV_ALT1),	ELFOSABI_SYSV },
1054 
1055 	{ MSG_ORIG(MSG_ELFOSABI_HPUX),		ELFOSABI_HPUX },
1056 	{ MSG_ORIG(MSG_ELFOSABI_HPUX_ALT1),	ELFOSABI_HPUX },
1057 
1058 	{ MSG_ORIG(MSG_ELFOSABI_NETBSD),	ELFOSABI_NETBSD },
1059 	{ MSG_ORIG(MSG_ELFOSABI_NETBSD_ALT1),	ELFOSABI_NETBSD },
1060 
1061 	{ MSG_ORIG(MSG_ELFOSABI_LINUX),		ELFOSABI_LINUX },
1062 	{ MSG_ORIG(MSG_ELFOSABI_LINUX_ALT1),	ELFOSABI_LINUX },
1063 
1064 	{ MSG_ORIG(MSG_ELFOSABI_SOLARIS),	ELFOSABI_SOLARIS },
1065 	{ MSG_ORIG(MSG_ELFOSABI_SOLARIS_ALT1),	ELFOSABI_SOLARIS },
1066 
1067 	{ MSG_ORIG(MSG_ELFOSABI_AIX),		ELFOSABI_AIX },
1068 	{ MSG_ORIG(MSG_ELFOSABI_AIX_ALT1),	ELFOSABI_AIX },
1069 
1070 	{ MSG_ORIG(MSG_ELFOSABI_IRIX),		ELFOSABI_IRIX },
1071 	{ MSG_ORIG(MSG_ELFOSABI_IRIX_ALT1),	ELFOSABI_IRIX },
1072 
1073 	{ MSG_ORIG(MSG_ELFOSABI_FREEBSD),	ELFOSABI_FREEBSD },
1074 	{ MSG_ORIG(MSG_ELFOSABI_FREEBSD_ALT1),	ELFOSABI_FREEBSD },
1075 
1076 	{ MSG_ORIG(MSG_ELFOSABI_TRU64),		ELFOSABI_TRU64 },
1077 	{ MSG_ORIG(MSG_ELFOSABI_TRU64_ALT1),	ELFOSABI_TRU64 },
1078 
1079 	{ MSG_ORIG(MSG_ELFOSABI_MODESTO),	ELFOSABI_MODESTO },
1080 	{ MSG_ORIG(MSG_ELFOSABI_MODESTO_ALT1),	ELFOSABI_MODESTO },
1081 
1082 	{ MSG_ORIG(MSG_ELFOSABI_OPENBSD),	ELFOSABI_OPENBSD },
1083 	{ MSG_ORIG(MSG_ELFOSABI_OPENBSD_ALT1),	ELFOSABI_OPENBSD },
1084 
1085 	{ MSG_ORIG(MSG_ELFOSABI_OPENVMS),	ELFOSABI_OPENVMS },
1086 	{ MSG_ORIG(MSG_ELFOSABI_OPENVMS_ALT1),	ELFOSABI_OPENVMS },
1087 
1088 	{ MSG_ORIG(MSG_ELFOSABI_NSK),		ELFOSABI_NSK },
1089 	{ MSG_ORIG(MSG_ELFOSABI_NSK_ALT1),	ELFOSABI_NSK },
1090 
1091 	{ MSG_ORIG(MSG_ELFOSABI_AROS),		ELFOSABI_AROS },
1092 	{ MSG_ORIG(MSG_ELFOSABI_AROS_ALT1),	ELFOSABI_AROS },
1093 
1094 	{ MSG_ORIG(MSG_ELFOSABI_ARM),		ELFOSABI_ARM },
1095 	{ MSG_ORIG(MSG_ELFOSABI_ARM_ALT1),	ELFOSABI_ARM },
1096 
1097 	{ MSG_ORIG(MSG_ELFOSABI_STANDALONE),	ELFOSABI_STANDALONE },
1098 	{ MSG_ORIG(MSG_ELFOSABI_STANDALONE_ALT1), ELFOSABI_STANDALONE },
1099 
1100 	{ NULL }
1101 };
1102 
1103 
1104 /*
1105  * Program header PT_* type values
1106  */
1107 static elfedit_atoui_sym_t sym_pt[] = {
1108 	{ MSG_ORIG(MSG_PT_NULL),		PT_NULL },
1109 	{ MSG_ORIG(MSG_PT_NULL_ALT1),		PT_NULL },
1110 
1111 	{ MSG_ORIG(MSG_PT_LOAD),		PT_LOAD },
1112 	{ MSG_ORIG(MSG_PT_LOAD_ALT1),		PT_LOAD },
1113 
1114 	{ MSG_ORIG(MSG_PT_DYNAMIC),		PT_DYNAMIC },
1115 	{ MSG_ORIG(MSG_PT_DYNAMIC_ALT1),	PT_DYNAMIC },
1116 
1117 	{ MSG_ORIG(MSG_PT_INTERP),		PT_INTERP },
1118 	{ MSG_ORIG(MSG_PT_INTERP_ALT1),		PT_INTERP },
1119 
1120 	{ MSG_ORIG(MSG_PT_NOTE),		PT_NOTE },
1121 	{ MSG_ORIG(MSG_PT_NOTE_ALT1),		PT_NOTE },
1122 
1123 	{ MSG_ORIG(MSG_PT_SHLIB),		PT_SHLIB },
1124 	{ MSG_ORIG(MSG_PT_SHLIB_ALT1),		PT_SHLIB },
1125 
1126 	{ MSG_ORIG(MSG_PT_PHDR),		PT_PHDR },
1127 	{ MSG_ORIG(MSG_PT_PHDR_ALT1),		PT_PHDR },
1128 
1129 	{ MSG_ORIG(MSG_PT_TLS),			PT_TLS },
1130 	{ MSG_ORIG(MSG_PT_TLS_ALT1),		PT_TLS },
1131 
1132 	{ MSG_ORIG(MSG_PT_SUNW_UNWIND),		PT_SUNW_UNWIND },
1133 	{ MSG_ORIG(MSG_PT_SUNW_UNWIND_ALT1),	PT_SUNW_UNWIND },
1134 
1135 	{ MSG_ORIG(MSG_PT_SUNW_EH_FRAME),	PT_SUNW_EH_FRAME },
1136 	{ MSG_ORIG(MSG_PT_SUNW_EH_FRAME_ALT1),	PT_SUNW_EH_FRAME },
1137 
1138 	{ MSG_ORIG(MSG_PT_SUNWBSS),		PT_SUNWBSS },
1139 	{ MSG_ORIG(MSG_PT_SUNWBSS_ALT1),	PT_SUNWBSS },
1140 
1141 	{ MSG_ORIG(MSG_PT_SUNWSTACK),		PT_SUNWSTACK },
1142 	{ MSG_ORIG(MSG_PT_SUNWSTACK_ALT1),	PT_SUNWSTACK },
1143 
1144 	{ MSG_ORIG(MSG_PT_SUNWDTRACE),		PT_SUNWDTRACE },
1145 	{ MSG_ORIG(MSG_PT_SUNWDTRACE_ALT1),	PT_SUNWDTRACE },
1146 
1147 	{ MSG_ORIG(MSG_PT_SUNWCAP),		PT_SUNWCAP },
1148 	{ MSG_ORIG(MSG_PT_SUNWCAP_ALT1),	PT_SUNWCAP },
1149 
1150 	{ NULL }
1151 };
1152 
1153 
1154 /*
1155  * Program header PF_* flag values
1156  */
1157 static elfedit_atoui_sym_t sym_pf[] = {
1158 	{ MSG_ORIG(MSG_PF_X),			PF_X },
1159 	{ MSG_ORIG(MSG_PF_X_ALT1),		PF_X },
1160 
1161 	{ MSG_ORIG(MSG_PF_W),			PF_W },
1162 	{ MSG_ORIG(MSG_PF_W_ALT1),		PF_W },
1163 
1164 	{ MSG_ORIG(MSG_PF_R),			PF_R },
1165 	{ MSG_ORIG(MSG_PF_R_ALT1),		PF_R },
1166 
1167 	{ NULL }
1168 };
1169 
1170 
1171 /*
1172  * Section header SHF_* flag values
1173  */
1174 static elfedit_atoui_sym_t sym_shf[] = {
1175 	{ MSG_ORIG(MSG_SHF_WRITE),		SHF_WRITE },
1176 	{ MSG_ORIG(MSG_SHF_WRITE_ALT1),		SHF_WRITE },
1177 
1178 	{ MSG_ORIG(MSG_SHF_ALLOC),		SHF_ALLOC },
1179 	{ MSG_ORIG(MSG_SHF_ALLOC_ALT1),		SHF_ALLOC },
1180 
1181 	{ MSG_ORIG(MSG_SHF_EXECINSTR),		SHF_EXECINSTR },
1182 	{ MSG_ORIG(MSG_SHF_EXECINSTR_ALT1),	SHF_EXECINSTR },
1183 
1184 	{ MSG_ORIG(MSG_SHF_MERGE),		SHF_MERGE },
1185 	{ MSG_ORIG(MSG_SHF_MERGE_ALT1),		SHF_MERGE },
1186 
1187 	{ MSG_ORIG(MSG_SHF_STRINGS),		SHF_STRINGS },
1188 	{ MSG_ORIG(MSG_SHF_STRINGS_ALT1),	SHF_STRINGS },
1189 
1190 	{ MSG_ORIG(MSG_SHF_INFO_LINK),		SHF_INFO_LINK },
1191 	{ MSG_ORIG(MSG_SHF_INFO_LINK_ALT1),	SHF_INFO_LINK },
1192 
1193 	{ MSG_ORIG(MSG_SHF_LINK_ORDER),		SHF_LINK_ORDER },
1194 	{ MSG_ORIG(MSG_SHF_LINK_ORDER_ALT1),	SHF_LINK_ORDER },
1195 
1196 	{ MSG_ORIG(MSG_SHF_OS_NONCONFORMING),	SHF_OS_NONCONFORMING },
1197 	{ MSG_ORIG(MSG_SHF_OS_NONCONFORMING_ALT1), SHF_OS_NONCONFORMING },
1198 
1199 	{ MSG_ORIG(MSG_SHF_GROUP),		SHF_GROUP },
1200 	{ MSG_ORIG(MSG_SHF_GROUP_ALT1),		SHF_GROUP },
1201 
1202 	{ MSG_ORIG(MSG_SHF_TLS),		SHF_TLS },
1203 	{ MSG_ORIG(MSG_SHF_TLS_ALT1),		SHF_TLS },
1204 
1205 	{ MSG_ORIG(MSG_SHF_AMD64_LARGE),	SHF_AMD64_LARGE },
1206 	{ MSG_ORIG(MSG_SHF_AMD64_LARGE_ALT1),	SHF_AMD64_LARGE },
1207 
1208 	{ MSG_ORIG(MSG_SHF_ORDERED),		SHF_ORDERED },
1209 	{ MSG_ORIG(MSG_SHF_ORDERED_ALT1),	SHF_ORDERED },
1210 
1211 	{ MSG_ORIG(MSG_SHF_EXCLUDE),		SHF_EXCLUDE },
1212 	{ MSG_ORIG(MSG_SHF_EXCLUDE_ALT1),	SHF_EXCLUDE },
1213 
1214 	{ NULL }
1215 };
1216 
1217 /*
1218  * ELF symbol bindings (st_info ELF_ST_BIND)
1219  */
1220 static elfedit_atoui_sym_t sym_stb[] = {
1221 	{ MSG_ORIG(MSG_STB_LOCAL),		STB_LOCAL },
1222 	{ MSG_ORIG(MSG_STB_LOCAL_ALT1),		STB_LOCAL },
1223 
1224 	{ MSG_ORIG(MSG_STB_GLOBAL),		STB_GLOBAL },
1225 	{ MSG_ORIG(MSG_STB_GLOBAL_ALT1),	STB_GLOBAL },
1226 
1227 	{ MSG_ORIG(MSG_STB_WEAK),		STB_WEAK },
1228 	{ MSG_ORIG(MSG_STB_WEAK_ALT1),		STB_WEAK },
1229 
1230 	{ NULL }
1231 };
1232 
1233 /*
1234  * ELF symbol types (st_info ELF_ST_TYPE)
1235  */
1236 static elfedit_atoui_sym_t sym_stt[] = {
1237 	{ MSG_ORIG(MSG_STT_NOTYPE),		STT_NOTYPE },
1238 	{ MSG_ORIG(MSG_STT_NOTYPE_ALT1),	STT_NOTYPE },
1239 
1240 	{ MSG_ORIG(MSG_STT_OBJECT),		STT_OBJECT },
1241 	{ MSG_ORIG(MSG_STT_OBJECT_ALT1),	STT_OBJECT },
1242 
1243 	{ MSG_ORIG(MSG_STT_FUNC),		STT_FUNC },
1244 	{ MSG_ORIG(MSG_STT_FUNC_ALT1),		STT_FUNC },
1245 
1246 	{ MSG_ORIG(MSG_STT_SECTION),		STT_SECTION },
1247 	{ MSG_ORIG(MSG_STT_SECTION_ALT1),	STT_SECTION },
1248 
1249 	{ MSG_ORIG(MSG_STT_FILE),		STT_FILE },
1250 	{ MSG_ORIG(MSG_STT_FILE_ALT1),		STT_FILE },
1251 
1252 	{ MSG_ORIG(MSG_STT_COMMON),		STT_COMMON },
1253 	{ MSG_ORIG(MSG_STT_COMMON_ALT1),	STT_COMMON },
1254 
1255 	{ MSG_ORIG(MSG_STT_TLS),		STT_TLS },
1256 	{ MSG_ORIG(MSG_STT_TLS_ALT1),		STT_TLS },
1257 
1258 	{ NULL }
1259 };
1260 
1261 /*
1262  * ELF symbol visibility (st_other ELF_ST_VISIBILITY)
1263  */
1264 static elfedit_atoui_sym_t sym_stv[] = {
1265 	{ MSG_ORIG(MSG_STV_DEFAULT),		STV_DEFAULT },
1266 	{ MSG_ORIG(MSG_STV_DEFAULT_ALT1),	STV_DEFAULT },
1267 
1268 	{ MSG_ORIG(MSG_STV_INTERNAL),		STV_INTERNAL },
1269 	{ MSG_ORIG(MSG_STV_INTERNAL_ALT1),	STV_INTERNAL },
1270 
1271 	{ MSG_ORIG(MSG_STV_HIDDEN),		STV_HIDDEN },
1272 	{ MSG_ORIG(MSG_STV_HIDDEN_ALT1),	STV_HIDDEN },
1273 
1274 	{ MSG_ORIG(MSG_STV_PROTECTED),		STV_PROTECTED },
1275 	{ MSG_ORIG(MSG_STV_PROTECTED_ALT1),	STV_PROTECTED },
1276 
1277 	{ MSG_ORIG(MSG_STV_EXPORTED),		STV_EXPORTED },
1278 	{ MSG_ORIG(MSG_STV_EXPORTED_ALT1),	STV_EXPORTED },
1279 
1280 	{ MSG_ORIG(MSG_STV_SINGLETON),		STV_SINGLETON },
1281 	{ MSG_ORIG(MSG_STV_SINGLETON_ALT1),	STV_SINGLETON },
1282 
1283 	{ MSG_ORIG(MSG_STV_ELIMINATE),		STV_ELIMINATE },
1284 	{ MSG_ORIG(MSG_STV_ELIMINATE_ALT1),	STV_ELIMINATE },
1285 
1286 	{ NULL }
1287 };
1288 
1289 /*
1290  * ELF syminfo SYMINFO_BT_ special boundto values
1291  */
1292 static elfedit_atoui_sym_t sym_syminfo_bt[] = {
1293 	{ MSG_ORIG(MSG_SYMINFO_BT_SELF),	SYMINFO_BT_SELF },
1294 	{ MSG_ORIG(MSG_SYMINFO_BT_SELF_ALT1),	SYMINFO_BT_SELF },
1295 
1296 	{ MSG_ORIG(MSG_SYMINFO_BT_PARENT),	SYMINFO_BT_PARENT },
1297 	{ MSG_ORIG(MSG_SYMINFO_BT_PARENT_ALT1),	SYMINFO_BT_PARENT },
1298 
1299 	{ MSG_ORIG(MSG_SYMINFO_BT_NONE),	SYMINFO_BT_NONE },
1300 	{ MSG_ORIG(MSG_SYMINFO_BT_NONE_ALT1),	SYMINFO_BT_NONE },
1301 
1302 	{ NULL }
1303 };
1304 
1305 
1306 /*
1307  * ELF syminfo SYMINFO_FLG_ flags
1308  */
1309 static elfedit_atoui_sym_t sym_syminfo_flg[] = {
1310 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECT),	SYMINFO_FLG_DIRECT },
1311 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECT_ALT1), SYMINFO_FLG_DIRECT },
1312 
1313 	{ MSG_ORIG(MSG_SYMINFO_FLG_COPY),	SYMINFO_FLG_COPY },
1314 	{ MSG_ORIG(MSG_SYMINFO_FLG_COPY_ALT1),	SYMINFO_FLG_COPY },
1315 
1316 	{ MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD),	SYMINFO_FLG_LAZYLOAD },
1317 	{ MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD_ALT1), SYMINFO_FLG_LAZYLOAD },
1318 
1319 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND),	SYMINFO_FLG_DIRECTBIND },
1320 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND_ALT1), SYMINFO_FLG_DIRECTBIND },
1321 
1322 	{ MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT), SYMINFO_FLG_NOEXTDIRECT },
1323 	{ MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT_ALT1), SYMINFO_FLG_NOEXTDIRECT },
1324 
1325 	{ NULL }
1326 };
1327 
1328 
1329 /*
1330  * ELF capabilities tag CA_ values
1331  */
1332 static elfedit_atoui_sym_t sym_ca[] = {
1333 	{ MSG_ORIG(MSG_CA_SUNW_NULL),		CA_SUNW_NULL },
1334 	{ MSG_ORIG(MSG_CA_SUNW_NULL_ALT1),	CA_SUNW_NULL },
1335 
1336 	{ MSG_ORIG(MSG_CA_SUNW_HW_1),		CA_SUNW_HW_1 },
1337 	{ MSG_ORIG(MSG_CA_SUNW_HW_1_ALT1),	CA_SUNW_HW_1 },
1338 
1339 	{ MSG_ORIG(MSG_CA_SUNW_SF_1),		CA_SUNW_SF_1 },
1340 	{ MSG_ORIG(MSG_CA_SUNW_SF_1_ALT1),	CA_SUNW_SF_1 },
1341 
1342 	{ NULL }
1343 };
1344 
1345 
1346 /*
1347  * AV_386 flags used for CA_SUNW_HW_1 capabilities
1348  *
1349  * The space for this is reserved at compile time, but the values are
1350  * filled in at runtime on demand from the usr/src/common/elfcap code.
1351  * Note that we need two slots for every capability, one for the full
1352  * string, and another for the informal lowercase version.
1353  */
1354 static elfedit_atoui_sym_t sym_av_386[(2 * ELFCAP_NUM_HW1_386) + 1];
1355 
1356 /*
1357  * AV_SPARC flags used for CA_SUNW_HW_1 capabilities
1358  *
1359  * The space for this is reserved at compile time, but the values are
1360  * filled in at runtime on demand from the usr/src/common/elfcap code.
1361  * Note that we need two slots for every capability, one for the full
1362  * string, and another for the informal lowercase version.
1363  */
1364 static elfedit_atoui_sym_t sym_av_sparc[(2 * ELFCAP_NUM_HW1_SPARC) + 1];
1365 
1366 /*
1367  * SF1_SUNW flags used for CA_SUNW_SF_1 capabilities
1368  *
1369  * The space for this is reserved at compile time, but the values are
1370  * filled in at runtime on demand from the usr/src/common/elfcap code.
1371  * Note that we need two slots for every capability, one for the full
1372  * string, and another for the informal lowercase version.
1373  */
1374 static elfedit_atoui_sym_t sym_sf1_sunw[(2 * ELFCAP_NUM_SF1) + 1];
1375 
1376 
1377 
1378 
1379 
1380 
1381 
1382 
1383 /*
1384  * Array of pointers to atoui arrays for each constant type, indexed
1385  * by elfedit_const_t value. The number and order of entries in this
1386  * table must agree with the definition of elfedit_const_t in elfedit.h.
1387  */
1388 static elfedit_atoui_sym_t *sym_table[] = {
1389 	sym_outstyle,		/* 0: ELFEDIT_CONST_OUTSTYLE */
1390 	sym_minus_o_outstyle,	/* 1: ELFEDIT_CONST_OUTSTYLE_MO */
1391 	sym_bool,		/* 2: ELFEDIT_CONST_BOOL */
1392 	sym_shn,		/* 3: ELFEDIT_CONST_SHN */
1393 	sym_sht,		/* 4: ELFEDIT_CONST_SHT */
1394 	sym_sht_strtab,		/* 5: ELFEDIT_CONST_SHT_STRTAB */
1395 	sym_sht_allsymtab,	/* 6: ELFEDIT_CONST_SHT_ALLSYMTAB */
1396 	sym_sht_symtab,		/* 7: ELFEDIT_CONST_SHT_SYMTAB */
1397 	sym_sht_dynsym,		/* 8: ELFEDIT_CONST_SHT_DYNSYM */
1398 	sym_sht_ldynsym,	/* 9: ELFEDIT_CONST_SHT_LDYNSYM */
1399 	sym_dt,			/* 10: ELFEDIT_CONST_DT: Dynamic tags */
1400 	sym_df,			/* 11: ELFEDIT_CONST_DF: DT_FLAGS */
1401 	sym_df_p1,		/* 12: ELFEDIT_CONST_DF_P1: DF_POSFLAG_1 */
1402 	sym_df_1,		/* 13: ELFEDIT_CONST_DF_1: DT_FLAGS_1 */
1403 	sym_dtf_1,		/* 14: ELFEDIT_CONST_DTF_1: DT_FEATURE_1 */
1404 	sym_ei,			/* 15: ELFEDIT_CONST_EI: Ehdr e_ident indexes */
1405 	sym_et,			/* 16: ELFEDIT_CONST_ET: Ehdr obj type */
1406 	sym_elfclass,		/* 17: ELFEDIT_CONST_ELFCLASS: Ehdr class */
1407 	sym_elfdata,		/* 18: ELFEDIT_CONST_ELFDATA: Ehdr endian */
1408 	sym_ef,			/* 19: ELFEDIT_CONST_EF: Ehdr flags */
1409 	sym_ev,			/* 20: ELFEDIT_CONST_EV: Ehdr version */
1410 	sym_em,			/* 21: ELFEDIT_CONST_EM: Ehdr machine */
1411 	sym_elfosabi,		/* 22: ELFEDIT_CONST_ELFOSABI: Ehdr ABI */
1412 	sym_pt,			/* 23: ELFEDIT_CONST_PT: Phdr type */
1413 	sym_pf,			/* 24: ELFEDIT_CONST_PF: Phdr flags */
1414 	sym_shf,		/* 25: ELFEDIT_CONST_SHF: Shdr flags */
1415 	sym_stb,		/* 26: ELFEDIT_CONST_STB: Sym binding */
1416 	sym_stt,		/* 27: ELFEDIT_CONST_STT: Sym type */
1417 	sym_stv,		/* 28: ELFEDIT_CONST_STV: Sym visibility */
1418 	sym_syminfo_bt,		/* 29: ELFEDIT_CONST_SYMINFO_BT:Syminfo bndto */
1419 	sym_syminfo_flg,	/* 30: ELFEDIT_CONST_SYMINFO_FLG:Syminfo flag */
1420 	sym_ca,			/* 31: ELFEDIT_CONST_CA: Capabilities tags */
1421 	NULL,			/* 32: ELFEDIT_CONST_AV_386: X86 HW caps */
1422 	NULL,			/* 33: ELFEDIT_CONST_AV_SPARC: sparc HW caps */
1423 	NULL,			/* 34: ELFEDIT_CONST_SF1_SUNW: software caps */
1424 };
1425 
1426 
1427 
1428 
1429 
1430 
1431 
1432 /*
1433  * Fill in the specified hardware/software capability array
1434  * with data from usr/src/common/elfcap.
1435  *
1436  * entry:
1437  *	const_type - Index of constant item being filled
1438  *	arr - elfedit_atoui_sym_t array to be filled
1439  *	desc - Array of capability descriptors from elfcap
1440  *	cnt - # of capability descriptors.
1441  *
1442  * exit:
1443  *	arr is expected to have [(2 * cnt) + 1] elements, all zero filled.
1444  *	For each descriptor, 2 array elements are filled in. The first one
1445  *	has the full name, and the second has the lowecase informal version.
1446  *	The final element of arr is left as NULL, to serve as termination.
1447  */
1448 static void
1449 fill_capability_array(elfedit_const_t const_type,
1450     elfedit_atoui_sym_t *arr, const elfcap_desc_t *desc, size_t cnt)
1451 {
1452 	sym_table[const_type] = arr;
1453 
1454 	for (; cnt-- > 0; desc++) {
1455 		/*
1456 		 * Ignore "placeholder" items. These represent
1457 		 * unallocated holes in the capability bits.
1458 		 */
1459 		if (desc->c_val == 0)
1460 			continue;
1461 
1462 		arr->sym_name = desc->c_full.s_str;
1463 		arr->sym_value = desc->c_val;
1464 		arr++;
1465 
1466 		arr->sym_name = desc->c_lc.s_str;
1467 		arr->sym_value = desc->c_val;
1468 		arr++;
1469 	}
1470 
1471 }
1472 
1473 
1474 
1475 /*
1476  * Given an elfedit_const_t value, return the array of elfedit_atoui_sym_t
1477  * entries that it represents.
1478  */
1479 elfedit_atoui_sym_t *
1480 elfedit_const_to_atoui(elfedit_const_t const_type)
1481 {
1482 	if ((const_type < 0) ||
1483 	    (const_type >= (sizeof (sym_table) / sizeof (sym_table[0]))))
1484 		elfedit_msg(ELFEDIT_MSG_ERR, MSG_INTL(MSG_ERR_BADCONST));
1485 
1486 	/* Fill capability constant array on demand? */
1487 	switch (const_type) {
1488 	case ELFEDIT_CONST_AV_386:
1489 		if (sym_table[ELFEDIT_CONST_AV_386] == NULL)
1490 			fill_capability_array(ELFEDIT_CONST_AV_386,
1491 			    sym_av_386, elfcap_getdesc_hw1_386(),
1492 			    ELFCAP_NUM_HW1_386);
1493 		break;
1494 	case ELFEDIT_CONST_AV_SPARC:
1495 		if (sym_table[ELFEDIT_CONST_AV_SPARC] == NULL)
1496 			fill_capability_array(ELFEDIT_CONST_AV_SPARC,
1497 			    sym_av_sparc, elfcap_getdesc_hw1_sparc(),
1498 			    ELFCAP_NUM_HW1_SPARC);
1499 		break;
1500 	case ELFEDIT_CONST_SF1_SUNW:
1501 		if (sym_table[ELFEDIT_CONST_SF1_SUNW] == NULL)
1502 			fill_capability_array(ELFEDIT_CONST_SF1_SUNW,
1503 			    sym_sf1_sunw, elfcap_getdesc_sf1(), ELFCAP_NUM_SF1);
1504 		break;
1505 	}
1506 
1507 	return (sym_table[const_type]);
1508 }
1509 
1510 
1511 
1512 /*
1513  * Return the elfedit_atoui_t array that corresponds to the
1514  * CA_SUNW_HW_1 hardware capabiliies field for a given
1515  * machine type.
1516  *
1517  * This routine will return NULL if there is no definition for the
1518  * machine specified.
1519  */
1520 elfedit_atoui_sym_t *
1521 elfedit_mach_sunw_hw1_to_atoui(int mach)
1522 {
1523 	switch (mach) {
1524 	case EM_386:
1525 	case EM_486:
1526 	case EM_AMD64:
1527 		return (elfedit_const_to_atoui(ELFEDIT_CONST_AV_386));
1528 
1529 	case EM_SPARC:
1530 	case EM_SPARC32PLUS:
1531 	case EM_SPARCV9:
1532 		return (elfedit_const_to_atoui(ELFEDIT_CONST_AV_SPARC));
1533 	}
1534 
1535 	/* A machine we don't know about */
1536 	return (NULL);
1537 }
1538