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