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_SUNW_LDMACH),		DT_SUNW_LDMACH },
440 	{ MSG_ORIG(MSG_DT_SUNW_LDMACH_ALT1),	DT_SUNW_LDMACH },
441 
442 	{ MSG_ORIG(MSG_DT_SPARC_REGISTER),	DT_SPARC_REGISTER },
443 	{ MSG_ORIG(MSG_DT_SPARC_REGISTER_ALT1),	DT_SPARC_REGISTER },
444 
445 	{ MSG_ORIG(MSG_DT_DEPRECATED_SPARC_REGISTER),
446 						DT_DEPRECATED_SPARC_REGISTER },
447 	{ MSG_ORIG(MSG_DT_DEPRECATED_SPARC_REGISTER_ALT1),
448 						DT_DEPRECATED_SPARC_REGISTER },
449 
450 	{ MSG_ORIG(MSG_DT_CHECKSUM),		DT_CHECKSUM },
451 	{ MSG_ORIG(MSG_DT_CHECKSUM_ALT1),	DT_CHECKSUM },
452 
453 	{ MSG_ORIG(MSG_DT_PLTPADSZ),		DT_PLTPADSZ },
454 	{ MSG_ORIG(MSG_DT_PLTPADSZ_ALT1),	DT_PLTPADSZ },
455 
456 	{ MSG_ORIG(MSG_DT_MOVEENT),		DT_MOVEENT },
457 	{ MSG_ORIG(MSG_DT_MOVEENT_ALT1),	DT_MOVEENT },
458 
459 	{ MSG_ORIG(MSG_DT_MOVESZ),		DT_MOVESZ },
460 	{ MSG_ORIG(MSG_DT_MOVESZ_ALT1),		DT_MOVESZ },
461 
462 	{ MSG_ORIG(MSG_DT_FEATURE_1),		DT_FEATURE_1 },
463 	{ MSG_ORIG(MSG_DT_FEATURE_1_ALT1),	DT_FEATURE_1 },
464 
465 	{ MSG_ORIG(MSG_DT_POSFLAG_1),		DT_POSFLAG_1 },
466 	{ MSG_ORIG(MSG_DT_POSFLAG_1_ALT1),	DT_POSFLAG_1 },
467 
468 	{ MSG_ORIG(MSG_DT_SYMINSZ),		DT_SYMINSZ },
469 	{ MSG_ORIG(MSG_DT_SYMINSZ_ALT1),	DT_SYMINSZ },
470 
471 	{ MSG_ORIG(MSG_DT_SYMINENT),		DT_SYMINENT },
472 	{ MSG_ORIG(MSG_DT_SYMINENT_ALT1),	DT_SYMINENT },
473 
474 	{ MSG_ORIG(MSG_DT_CONFIG),		DT_CONFIG },
475 	{ MSG_ORIG(MSG_DT_CONFIG_ALT1),		DT_CONFIG },
476 
477 	{ MSG_ORIG(MSG_DT_DEPAUDIT),		DT_DEPAUDIT },
478 	{ MSG_ORIG(MSG_DT_DEPAUDIT_ALT1),	DT_DEPAUDIT },
479 
480 	{ MSG_ORIG(MSG_DT_AUDIT),		DT_AUDIT },
481 	{ MSG_ORIG(MSG_DT_AUDIT_ALT1),		DT_AUDIT },
482 
483 	{ MSG_ORIG(MSG_DT_PLTPAD),		DT_PLTPAD },
484 	{ MSG_ORIG(MSG_DT_PLTPAD_ALT1),		DT_PLTPAD },
485 
486 	{ MSG_ORIG(MSG_DT_MOVETAB),		DT_MOVETAB },
487 	{ MSG_ORIG(MSG_DT_MOVETAB_ALT1),	DT_MOVETAB },
488 
489 	{ MSG_ORIG(MSG_DT_SYMINFO),		DT_SYMINFO },
490 	{ MSG_ORIG(MSG_DT_SYMINFO_ALT1),	DT_SYMINFO },
491 
492 	{ MSG_ORIG(MSG_DT_VERSYM),		DT_VERSYM },
493 	{ MSG_ORIG(MSG_DT_VERSYM_ALT1),		DT_VERSYM },
494 
495 	{ MSG_ORIG(MSG_DT_RELACOUNT),		DT_RELACOUNT },
496 	{ MSG_ORIG(MSG_DT_RELACOUNT_ALT1),	DT_RELACOUNT },
497 
498 	{ MSG_ORIG(MSG_DT_RELCOUNT),		DT_RELCOUNT },
499 	{ MSG_ORIG(MSG_DT_RELCOUNT_ALT1),	DT_RELCOUNT },
500 
501 	{ MSG_ORIG(MSG_DT_FLAGS_1),		DT_FLAGS_1 },
502 	{ MSG_ORIG(MSG_DT_FLAGS_1_ALT1),	DT_FLAGS_1 },
503 
504 	{ MSG_ORIG(MSG_DT_VERDEF),		DT_VERDEF },
505 	{ MSG_ORIG(MSG_DT_VERDEF_ALT1),		DT_VERDEF },
506 
507 	{ MSG_ORIG(MSG_DT_VERDEFNUM),		DT_VERDEFNUM },
508 	{ MSG_ORIG(MSG_DT_VERDEFNUM_ALT1),	DT_VERDEFNUM },
509 
510 	{ MSG_ORIG(MSG_DT_VERNEED),		DT_VERNEED },
511 	{ MSG_ORIG(MSG_DT_VERNEED_ALT1),	DT_VERNEED },
512 
513 	{ MSG_ORIG(MSG_DT_VERNEEDNUM),		DT_VERNEEDNUM },
514 	{ MSG_ORIG(MSG_DT_VERNEEDNUM_ALT1),	DT_VERNEEDNUM },
515 
516 	{ MSG_ORIG(MSG_DT_AUXILIARY),		DT_AUXILIARY },
517 	{ MSG_ORIG(MSG_DT_AUXILIARY_ALT1),	DT_AUXILIARY },
518 
519 	{ MSG_ORIG(MSG_DT_USED),		DT_USED },
520 	{ MSG_ORIG(MSG_DT_USED_ALT1),		DT_USED },
521 
522 	{ MSG_ORIG(MSG_DT_FILTER),		DT_FILTER },
523 	{ MSG_ORIG(MSG_DT_FILTER_ALT1),		DT_FILTER },
524 
525 	{ NULL }
526 };
527 
528 
529 /*
530  * ELF DT_FLAGS DF_* values
531  */
532 static elfedit_atoui_sym_t sym_df[] = {
533 	{ MSG_ORIG(MSG_DF_ORIGIN),		DF_ORIGIN },
534 	{ MSG_ORIG(MSG_DF_ORIGIN_ALT1),		DF_ORIGIN },
535 
536 	{ MSG_ORIG(MSG_DF_SYMBOLIC),		DF_SYMBOLIC },
537 	{ MSG_ORIG(MSG_DF_SYMBOLIC_ALT1),	DF_SYMBOLIC },
538 
539 	{ MSG_ORIG(MSG_DF_TEXTREL),		DF_TEXTREL },
540 	{ MSG_ORIG(MSG_DF_TEXTREL_ALT1),	DF_TEXTREL },
541 
542 	{ MSG_ORIG(MSG_DF_BIND_NOW),		DF_BIND_NOW },
543 	{ MSG_ORIG(MSG_DF_BIND_NOW_ALT1),	DF_BIND_NOW },
544 
545 	{ MSG_ORIG(MSG_DF_STATIC_TLS),		DF_STATIC_TLS },
546 	{ MSG_ORIG(MSG_DF_STATIC_TLS_ALT1),	DF_STATIC_TLS },
547 
548 	{ NULL }
549 };
550 
551 
552 /*
553  * ELF DT_POSFLAG_1 DF_P1_* values
554  */
555 static elfedit_atoui_sym_t sym_df_p1[] = {
556 	{ MSG_ORIG(MSG_DF_P1_LAZYLOAD),		DF_P1_LAZYLOAD },
557 	{ MSG_ORIG(MSG_DF_P1_LAZYLOAD_ALT1),	DF_P1_LAZYLOAD },
558 
559 	{ MSG_ORIG(MSG_DF_P1_GROUPPERM),	DF_P1_GROUPPERM },
560 	{ MSG_ORIG(MSG_DF_P1_GROUPPERM_ALT1),	DF_P1_GROUPPERM },
561 
562 	{ NULL }
563 };
564 
565 
566 /*
567  * ELF DT_FLAGS_1 DF_1_* values
568  */
569 static elfedit_atoui_sym_t sym_df_1[] = {
570 	{ MSG_ORIG(MSG_DF_1_NOW),		DF_1_NOW },
571 	{ MSG_ORIG(MSG_DF_1_NOW_ALT1),		DF_1_NOW },
572 
573 	{ MSG_ORIG(MSG_DF_1_GLOBAL),		DF_1_GLOBAL },
574 	{ MSG_ORIG(MSG_DF_1_GLOBAL_ALT1),	DF_1_GLOBAL },
575 
576 	{ MSG_ORIG(MSG_DF_1_GROUP),		DF_1_GROUP },
577 	{ MSG_ORIG(MSG_DF_1_GROUP_ALT1),	DF_1_GROUP },
578 
579 	{ MSG_ORIG(MSG_DF_1_NODELETE),		DF_1_NODELETE },
580 	{ MSG_ORIG(MSG_DF_1_NODELETE_ALT1),	DF_1_NODELETE },
581 
582 	{ MSG_ORIG(MSG_DF_1_LOADFLTR),		DF_1_LOADFLTR },
583 	{ MSG_ORIG(MSG_DF_1_LOADFLTR_ALT1),	DF_1_LOADFLTR },
584 
585 	{ MSG_ORIG(MSG_DF_1_INITFIRST),		DF_1_INITFIRST },
586 	{ MSG_ORIG(MSG_DF_1_INITFIRST_ALT1),	DF_1_INITFIRST },
587 
588 	{ MSG_ORIG(MSG_DF_1_NOOPEN),		DF_1_NOOPEN },
589 	{ MSG_ORIG(MSG_DF_1_NOOPEN_ALT1),	DF_1_NOOPEN },
590 
591 	{ MSG_ORIG(MSG_DF_1_ORIGIN),		DF_1_ORIGIN },
592 	{ MSG_ORIG(MSG_DF_1_ORIGIN_ALT1),	DF_1_ORIGIN },
593 
594 	{ MSG_ORIG(MSG_DF_1_DIRECT),		DF_1_DIRECT },
595 	{ MSG_ORIG(MSG_DF_1_DIRECT_ALT1),	DF_1_DIRECT },
596 
597 	{ MSG_ORIG(MSG_DF_1_TRANS),		DF_1_TRANS },
598 	{ MSG_ORIG(MSG_DF_1_TRANS_ALT1),	DF_1_TRANS },
599 
600 	{ MSG_ORIG(MSG_DF_1_INTERPOSE),		DF_1_INTERPOSE },
601 	{ MSG_ORIG(MSG_DF_1_INTERPOSE_ALT1),	DF_1_INTERPOSE },
602 
603 	{ MSG_ORIG(MSG_DF_1_NODEFLIB),		DF_1_NODEFLIB },
604 	{ MSG_ORIG(MSG_DF_1_NODEFLIB_ALT1),	DF_1_NODEFLIB },
605 
606 	{ MSG_ORIG(MSG_DF_1_NODUMP),		DF_1_NODUMP },
607 	{ MSG_ORIG(MSG_DF_1_NODUMP_ALT1),	DF_1_NODUMP },
608 
609 	{ MSG_ORIG(MSG_DF_1_CONFALT),		DF_1_CONFALT },
610 	{ MSG_ORIG(MSG_DF_1_CONFALT_ALT1),	DF_1_CONFALT },
611 
612 	{ MSG_ORIG(MSG_DF_1_ENDFILTEE),		DF_1_ENDFILTEE },
613 	{ MSG_ORIG(MSG_DF_1_ENDFILTEE_ALT1),	DF_1_ENDFILTEE },
614 
615 	{ MSG_ORIG(MSG_DF_1_DISPRELDNE),	DF_1_DISPRELDNE },
616 	{ MSG_ORIG(MSG_DF_1_DISPRELDNE_ALT1),	DF_1_DISPRELDNE },
617 
618 	{ MSG_ORIG(MSG_DF_1_DISPRELPND),	DF_1_DISPRELPND },
619 	{ MSG_ORIG(MSG_DF_1_DISPRELPND_ALT1),	DF_1_DISPRELPND },
620 
621 	{ MSG_ORIG(MSG_DF_1_NODIRECT),		DF_1_NODIRECT },
622 	{ MSG_ORIG(MSG_DF_1_NODIRECT_ALT1),	DF_1_NODIRECT },
623 
624 	{ MSG_ORIG(MSG_DF_1_IGNMULDEF),		DF_1_IGNMULDEF },
625 	{ MSG_ORIG(MSG_DF_1_IGNMULDEF_ALT1),	DF_1_IGNMULDEF },
626 
627 	{ MSG_ORIG(MSG_DF_1_NOKSYMS),		DF_1_NOKSYMS },
628 	{ MSG_ORIG(MSG_DF_1_NOKSYMS_ALT1),	DF_1_NOKSYMS },
629 
630 	{ MSG_ORIG(MSG_DF_1_NOHDR),		DF_1_NOHDR },
631 	{ MSG_ORIG(MSG_DF_1_NOHDR_ALT1),	DF_1_NOHDR },
632 
633 	{ MSG_ORIG(MSG_DF_1_EDITED),		DF_1_EDITED },
634 	{ MSG_ORIG(MSG_DF_1_EDITED_ALT1),	DF_1_EDITED },
635 
636 	{ MSG_ORIG(MSG_DF_1_NORELOC),		DF_1_NORELOC },
637 	{ MSG_ORIG(MSG_DF_1_NORELOC_ALT1),	DF_1_NORELOC },
638 
639 	{ MSG_ORIG(MSG_DF_1_SYMINTPOSE),	DF_1_SYMINTPOSE },
640 	{ MSG_ORIG(MSG_DF_1_SYMINTPOSE_ALT1),	DF_1_SYMINTPOSE },
641 
642 	{ MSG_ORIG(MSG_DF_1_GLOBAUDIT),		DF_1_GLOBAUDIT },
643 	{ MSG_ORIG(MSG_DF_1_GLOBAUDIT_ALT1),	DF_1_GLOBAUDIT },
644 
645 	{ NULL }
646 };
647 
648 
649 /*
650  * ELF DT_FEATURE_1 DTF_1_* values
651  */
652 static elfedit_atoui_sym_t sym_dtf_1[] = {
653 	{ MSG_ORIG(MSG_DTF_1_PARINIT),		DTF_1_PARINIT },
654 	{ MSG_ORIG(MSG_DTF_1_PARINIT_ALT1),	DTF_1_PARINIT },
655 
656 	{ MSG_ORIG(MSG_DTF_1_CONFEXP),		DTF_1_CONFEXP },
657 	{ MSG_ORIG(MSG_DTF_1_CONFEXP_ALT1),	DTF_1_CONFEXP },
658 
659 	{ NULL }
660 };
661 
662 /*
663  * ELF header EI_* indexes
664  */
665 static elfedit_atoui_sym_t sym_ei[] = {
666 	{ MSG_ORIG(MSG_EI_MAG0),		EI_MAG0 },
667 	{ MSG_ORIG(MSG_EI_MAG0_ALT1),		EI_MAG0 },
668 
669 	{ MSG_ORIG(MSG_EI_MAG1),		EI_MAG1 },
670 	{ MSG_ORIG(MSG_EI_MAG1_ALT1),		EI_MAG1 },
671 
672 	{ MSG_ORIG(MSG_EI_MAG2),		EI_MAG2 },
673 	{ MSG_ORIG(MSG_EI_MAG2_ALT1),		EI_MAG2 },
674 
675 	{ MSG_ORIG(MSG_EI_MAG3),		EI_MAG3 },
676 	{ MSG_ORIG(MSG_EI_MAG3_ALT1),		EI_MAG3 },
677 
678 	{ MSG_ORIG(MSG_EI_CLASS),		EI_CLASS },
679 	{ MSG_ORIG(MSG_EI_CLASS_ALT1),		EI_CLASS },
680 
681 	{ MSG_ORIG(MSG_EI_DATA),		EI_DATA },
682 	{ MSG_ORIG(MSG_EI_DATA_ALT1),		EI_DATA },
683 
684 	{ MSG_ORIG(MSG_EI_VERSION),		EI_VERSION },
685 	{ MSG_ORIG(MSG_EI_VERSION_ALT1),	EI_VERSION },
686 
687 	{ MSG_ORIG(MSG_EI_OSABI),		EI_OSABI },
688 	{ MSG_ORIG(MSG_EI_OSABI_ALT1),		EI_OSABI },
689 
690 	{ MSG_ORIG(MSG_EI_ABIVERSION),		EI_ABIVERSION },
691 	{ MSG_ORIG(MSG_EI_ABIVERSION_ALT1),	EI_ABIVERSION },
692 
693 	{ NULL }
694 };
695 
696 /*
697  * ELF header ET_* file type values
698  */
699 static elfedit_atoui_sym_t sym_et[] = {
700 	{ MSG_ORIG(MSG_ET_NONE),		ET_NONE },
701 	{ MSG_ORIG(MSG_ET_NONE_ALT1),		ET_NONE },
702 
703 	{ MSG_ORIG(MSG_ET_REL),			ET_REL },
704 	{ MSG_ORIG(MSG_ET_REL_ALT1),		ET_REL },
705 
706 	{ MSG_ORIG(MSG_ET_EXEC),		ET_EXEC },
707 	{ MSG_ORIG(MSG_ET_EXEC_ALT1),		ET_EXEC },
708 
709 	{ MSG_ORIG(MSG_ET_DYN),			ET_DYN },
710 	{ MSG_ORIG(MSG_ET_DYN_ALT1),		ET_DYN },
711 
712 	{ MSG_ORIG(MSG_ET_CORE),		ET_CORE },
713 	{ MSG_ORIG(MSG_ET_CORE_ALT1),		ET_CORE },
714 
715 	{ NULL }
716 };
717 
718 /*
719  * ELFCLASS
720  */
721 static elfedit_atoui_sym_t sym_elfclass[] = {
722 	{ MSG_ORIG(MSG_ELFCLASSNONE),		ELFCLASSNONE },
723 	{ MSG_ORIG(MSG_ELFCLASSNONE_ALT1),	ELFCLASSNONE },
724 
725 	{ MSG_ORIG(MSG_ELFCLASS32),		ELFCLASS32 },
726 	{ MSG_ORIG(MSG_ELFCLASS32_ALT1),	ELFCLASS32 },
727 
728 	{ MSG_ORIG(MSG_ELFCLASS64),		ELFCLASS64 },
729 	{ MSG_ORIG(MSG_ELFCLASS64_ALT1),	ELFCLASS64 },
730 
731 	{ NULL }
732 };
733 
734 /*
735  * ELFDATA
736  */
737 static elfedit_atoui_sym_t sym_elfdata[] = {
738 	{ MSG_ORIG(MSG_ELFDATANONE),		ELFDATANONE },
739 	{ MSG_ORIG(MSG_ELFDATANONE_ALT1),	ELFDATANONE },
740 
741 	{ MSG_ORIG(MSG_ELFDATA2LSB),		ELFDATA2LSB },
742 	{ MSG_ORIG(MSG_ELFDATA2LSB_ALT1),	ELFDATA2LSB },
743 
744 	{ MSG_ORIG(MSG_ELFDATA2MSB),		ELFDATA2MSB },
745 	{ MSG_ORIG(MSG_ELFDATA2MSB_ALT1),	ELFDATA2MSB },
746 
747 	{ NULL }
748 };
749 
750 /*
751  * ELF header EF_* flags
752  */
753 static elfedit_atoui_sym_t sym_ef[] = {
754 	{ MSG_ORIG(MSG_EF_SPARC_32PLUS),	EF_SPARC_32PLUS },
755 	{ MSG_ORIG(MSG_EF_SPARC_32PLUS_ALT1),	EF_SPARC_32PLUS },
756 
757 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US1),	EF_SPARC_SUN_US1 },
758 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US1_ALT1),	EF_SPARC_SUN_US1 },
759 
760 	{ MSG_ORIG(MSG_EF_SPARC_HAL_R1),	EF_SPARC_HAL_R1 },
761 	{ MSG_ORIG(MSG_EF_SPARC_HAL_R1_ALT1),	EF_SPARC_HAL_R1 },
762 
763 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US3),	EF_SPARC_SUN_US3 },
764 	{ MSG_ORIG(MSG_EF_SPARC_SUN_US3_ALT1),	EF_SPARC_SUN_US3 },
765 
766 	{ MSG_ORIG(MSG_EF_SPARCV9_MM),		EF_SPARCV9_MM },
767 	{ MSG_ORIG(MSG_EF_SPARCV9_MM_ALT1),	EF_SPARCV9_MM },
768 
769 	{ MSG_ORIG(MSG_EF_SPARCV9_TSO),		EF_SPARCV9_TSO },
770 	{ MSG_ORIG(MSG_EF_SPARCV9_TSO_ALT1),	EF_SPARCV9_TSO },
771 
772 	{ MSG_ORIG(MSG_EF_SPARCV9_PSO),		EF_SPARCV9_PSO },
773 	{ MSG_ORIG(MSG_EF_SPARCV9_PSO_ALT1),	EF_SPARCV9_PSO },
774 
775 	{ MSG_ORIG(MSG_EF_SPARCV9_RMO),		EF_SPARCV9_RMO },
776 	{ MSG_ORIG(MSG_EF_SPARCV9_RMO_ALT1),	EF_SPARCV9_RMO },
777 
778 	{ NULL }
779 };
780 
781 /*
782  * ELF header EV_* versions
783  */
784 static elfedit_atoui_sym_t sym_ev[] = {
785 	{ MSG_ORIG(MSG_EV_NONE),		EV_NONE },
786 	{ MSG_ORIG(MSG_EV_NONE_ALT1),		EV_NONE },
787 
788 	{ MSG_ORIG(MSG_EV_CURRENT),		EV_CURRENT },
789 	{ MSG_ORIG(MSG_EV_CURRENT_ALT1),	EV_CURRENT },
790 
791 	{ NULL }
792 };
793 
794 /*
795  * ELF EM_* machine types
796  */
797 static elfedit_atoui_sym_t sym_em[] = {
798 	{ MSG_ORIG(MSG_EM_NONE),		EM_NONE },
799 	{ MSG_ORIG(MSG_EM_NONE_ALT1),		EM_NONE },
800 
801 	{ MSG_ORIG(MSG_EM_M32),			EM_M32 },
802 	{ MSG_ORIG(MSG_EM_M32_ALT1),		EM_M32 },
803 	{ MSG_ORIG(MSG_EM_M32_ALT2),		EM_M32 },
804 
805 	{ MSG_ORIG(MSG_EM_SPARC),		EM_SPARC },
806 	{ MSG_ORIG(MSG_EM_SPARC_ALT1),		EM_SPARC },
807 
808 	{ MSG_ORIG(MSG_EM_386),			EM_386 },
809 	{ MSG_ORIG(MSG_EM_386_ALT1),		EM_386 },
810 	{ MSG_ORIG(MSG_EM_386_ALT2),		EM_386 },
811 
812 	{ MSG_ORIG(MSG_EM_68K),			EM_68K },
813 	{ MSG_ORIG(MSG_EM_68K_ALT1),		EM_68K },
814 	{ MSG_ORIG(MSG_EM_68K_ALT2),		EM_68K },
815 
816 	{ MSG_ORIG(MSG_EM_88K),			EM_88K },
817 	{ MSG_ORIG(MSG_EM_88K_ALT1),		EM_88K },
818 	{ MSG_ORIG(MSG_EM_88K_ALT2),		EM_88K },
819 
820 	{ MSG_ORIG(MSG_EM_486),			EM_486 },
821 	{ MSG_ORIG(MSG_EM_486_ALT1),		EM_486 },
822 	{ MSG_ORIG(MSG_EM_486_ALT2),		EM_486 },
823 
824 	{ MSG_ORIG(MSG_EM_860),			EM_860 },
825 	{ MSG_ORIG(MSG_EM_860_ALT1),		EM_860 },
826 	{ MSG_ORIG(MSG_EM_860_ALT2),		EM_860 },
827 
828 	{ MSG_ORIG(MSG_EM_MIPS),		EM_MIPS },
829 	{ MSG_ORIG(MSG_EM_MIPS_ALT1),		EM_MIPS },
830 	{ MSG_ORIG(MSG_EM_MIPS_ALT2),		EM_MIPS },
831 
832 	{ MSG_ORIG(MSG_EM_S370),		EM_S370 },
833 	{ MSG_ORIG(MSG_EM_S370_ALT1),		EM_S370 },
834 
835 	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE),		EM_MIPS_RS3_LE },
836 	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE_ALT1),	EM_MIPS_RS3_LE },
837 	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE_ALT2),	EM_MIPS_RS3_LE },
838 
839 	{ MSG_ORIG(MSG_EM_RS6000),		EM_RS6000 },
840 	{ MSG_ORIG(MSG_EM_RS6000_ALT1),		EM_RS6000 },
841 
842 	{ MSG_ORIG(MSG_EM_PA_RISC),		EM_PA_RISC },
843 	{ MSG_ORIG(MSG_EM_PA_RISC_ALT1),	EM_PA_RISC },
844 
845 	{ MSG_ORIG(MSG_EM_NCUBE),		EM_nCUBE },
846 	{ MSG_ORIG(MSG_EM_NCUBE_ALT1),		EM_nCUBE },
847 
848 	{ MSG_ORIG(MSG_EM_VPP500),		EM_VPP500 },
849 	{ MSG_ORIG(MSG_EM_VPP500_ALT1),		EM_VPP500 },
850 
851 	{ MSG_ORIG(MSG_EM_SPARC32PLUS),		EM_SPARC32PLUS },
852 	{ MSG_ORIG(MSG_EM_SPARC32PLUS_ALT1),	EM_SPARC32PLUS },
853 
854 	{ MSG_ORIG(MSG_EM_960),			EM_960 },
855 	{ MSG_ORIG(MSG_EM_960_ALT1),		EM_960 },
856 
857 	{ MSG_ORIG(MSG_EM_PPC),			EM_PPC },
858 	{ MSG_ORIG(MSG_EM_PPC_ALT1),		EM_PPC },
859 	{ MSG_ORIG(MSG_EM_PPC_ALT2),		EM_PPC },
860 
861 	{ MSG_ORIG(MSG_EM_PPC64),		EM_PPC64 },
862 	{ MSG_ORIG(MSG_EM_PPC64_ALT1),		EM_PPC64 },
863 	{ MSG_ORIG(MSG_EM_PPC64_ALT2),		EM_PPC64 },
864 
865 	{ MSG_ORIG(MSG_EM_S390),		EM_S390 },
866 	{ MSG_ORIG(MSG_EM_S390_ALT1),		EM_S390 },
867 
868 	{ MSG_ORIG(MSG_EM_V800),		EM_V800 },
869 	{ MSG_ORIG(MSG_EM_V800_ALT1),		EM_V800 },
870 
871 	{ MSG_ORIG(MSG_EM_FR20),		EM_FR20 },
872 	{ MSG_ORIG(MSG_EM_FR20_ALT1),		EM_FR20 },
873 
874 	{ MSG_ORIG(MSG_EM_RH32),		EM_RH32 },
875 	{ MSG_ORIG(MSG_EM_RH32_ALT1),		EM_RH32 },
876 
877 	{ MSG_ORIG(MSG_EM_RCE),			EM_RCE },
878 	{ MSG_ORIG(MSG_EM_RCE_ALT1),		EM_RCE },
879 
880 	{ MSG_ORIG(MSG_EM_ARM),			EM_ARM },
881 	{ MSG_ORIG(MSG_EM_ARM_ALT1),		EM_ARM },
882 
883 	{ MSG_ORIG(MSG_EM_ALPHA),		EM_ALPHA },
884 	{ MSG_ORIG(MSG_EM_ALPHA_ALT1),		EM_ALPHA },
885 
886 	{ MSG_ORIG(MSG_EM_SH),			EM_SH },
887 	{ MSG_ORIG(MSG_EM_SH_ALT1),		EM_SH },
888 
889 	{ MSG_ORIG(MSG_EM_SPARCV9),		EM_SPARCV9 },
890 	{ MSG_ORIG(MSG_EM_SPARCV9_ALT1),	EM_SPARCV9 },
891 
892 	{ MSG_ORIG(MSG_EM_TRICORE),		EM_TRICORE },
893 	{ MSG_ORIG(MSG_EM_TRICORE_ALT1),	EM_TRICORE },
894 
895 	{ MSG_ORIG(MSG_EM_ARC),			EM_ARC },
896 	{ MSG_ORIG(MSG_EM_ARC_ALT1),		EM_ARC },
897 
898 	{ MSG_ORIG(MSG_EM_H8_300),		EM_H8_300 },
899 	{ MSG_ORIG(MSG_EM_H8_300_ALT1),		EM_H8_300 },
900 
901 	{ MSG_ORIG(MSG_EM_H8_300H),		EM_H8_300H },
902 	{ MSG_ORIG(MSG_EM_H8_300H_ALT1),	EM_H8_300H },
903 
904 	{ MSG_ORIG(MSG_EM_H8S),			EM_H8S },
905 	{ MSG_ORIG(MSG_EM_H8S_ALT1),		EM_H8S },
906 
907 	{ MSG_ORIG(MSG_EM_H8_500),		EM_H8_500 },
908 	{ MSG_ORIG(MSG_EM_H8_500_ALT1),		EM_H8_500 },
909 
910 	{ MSG_ORIG(MSG_EM_IA_64),		EM_IA_64 },
911 	{ MSG_ORIG(MSG_EM_IA_64_ALT1),		EM_IA_64 },
912 
913 	{ MSG_ORIG(MSG_EM_MIPS_X),		EM_MIPS_X },
914 	{ MSG_ORIG(MSG_EM_MIPS_X_ALT1),		EM_MIPS_X },
915 
916 	{ MSG_ORIG(MSG_EM_COLDFIRE),		EM_COLDFIRE },
917 	{ MSG_ORIG(MSG_EM_COLDFIRE_ALT1),	EM_COLDFIRE },
918 
919 	{ MSG_ORIG(MSG_EM_68HC12),		EM_68HC12 },
920 	{ MSG_ORIG(MSG_EM_68HC12_ALT1),		EM_68HC12 },
921 
922 	{ MSG_ORIG(MSG_EM_MMA),			EM_MMA },
923 	{ MSG_ORIG(MSG_EM_MMA_ALT1),		EM_MMA },
924 
925 	{ MSG_ORIG(MSG_EM_PCP),			EM_PCP },
926 	{ MSG_ORIG(MSG_EM_PCP_ALT1),		EM_PCP },
927 
928 	{ MSG_ORIG(MSG_EM_NCPU),		EM_NCPU },
929 	{ MSG_ORIG(MSG_EM_NCPU_ALT1),		EM_NCPU },
930 
931 	{ MSG_ORIG(MSG_EM_NDR1),		EM_NDR1 },
932 	{ MSG_ORIG(MSG_EM_NDR1_ALT1),		EM_NDR1 },
933 
934 	{ MSG_ORIG(MSG_EM_STARCORE),		EM_STARCORE },
935 	{ MSG_ORIG(MSG_EM_STARCORE_ALT1),	EM_STARCORE },
936 
937 	{ MSG_ORIG(MSG_EM_ME16),		EM_ME16 },
938 	{ MSG_ORIG(MSG_EM_ME16_ALT1),		EM_ME16 },
939 
940 	{ MSG_ORIG(MSG_EM_ST100),		EM_ST100 },
941 	{ MSG_ORIG(MSG_EM_ST100_ALT1),		EM_ST100 },
942 
943 	{ MSG_ORIG(MSG_EM_TINYJ),		EM_TINYJ },
944 	{ MSG_ORIG(MSG_EM_TINYJ_ALT1),		EM_TINYJ },
945 
946 	{ MSG_ORIG(MSG_EM_AMD64),		EM_AMD64 },
947 	{ MSG_ORIG(MSG_EM_AMD64_ALT1),		EM_AMD64 },
948 
949 	{ MSG_ORIG(MSG_EM_PDSP),		EM_PDSP },
950 	{ MSG_ORIG(MSG_EM_PDSP_ALT1),		EM_PDSP },
951 
952 	{ MSG_ORIG(MSG_EM_FX66),		EM_FX66 },
953 	{ MSG_ORIG(MSG_EM_FX66_ALT1),		EM_FX66 },
954 
955 	{ MSG_ORIG(MSG_EM_ST9PLUS),		EM_ST9PLUS },
956 	{ MSG_ORIG(MSG_EM_ST9PLUS_ALT1),	EM_ST9PLUS },
957 
958 	{ MSG_ORIG(MSG_EM_ST7),			EM_ST7 },
959 	{ MSG_ORIG(MSG_EM_ST7_ALT1),		EM_ST7 },
960 
961 	{ MSG_ORIG(MSG_EM_68HC16),		EM_68HC16 },
962 	{ MSG_ORIG(MSG_EM_68HC16_ALT1),		EM_68HC16 },
963 
964 	{ MSG_ORIG(MSG_EM_68HC11),		EM_68HC11 },
965 	{ MSG_ORIG(MSG_EM_68HC11_ALT1),		EM_68HC11 },
966 
967 	{ MSG_ORIG(MSG_EM_68HC08),		EM_68HC08 },
968 	{ MSG_ORIG(MSG_EM_68HC08_ALT1),		EM_68HC08 },
969 
970 	{ MSG_ORIG(MSG_EM_68HC05),		EM_68HC05 },
971 	{ MSG_ORIG(MSG_EM_68HC05_ALT1),		EM_68HC05 },
972 
973 	{ MSG_ORIG(MSG_EM_SVX),			EM_SVX },
974 	{ MSG_ORIG(MSG_EM_SVX_ALT1),		EM_SVX },
975 
976 	{ MSG_ORIG(MSG_EM_ST19),		EM_ST19 },
977 	{ MSG_ORIG(MSG_EM_ST19_ALT1),		EM_ST19 },
978 
979 	{ MSG_ORIG(MSG_EM_VAX),			EM_VAX },
980 	{ MSG_ORIG(MSG_EM_VAX_ALT1),		EM_VAX },
981 
982 	{ MSG_ORIG(MSG_EM_CRIS),		EM_CRIS },
983 	{ MSG_ORIG(MSG_EM_CRIS_ALT1),		EM_CRIS },
984 
985 	{ MSG_ORIG(MSG_EM_JAVELIN),		EM_JAVELIN },
986 	{ MSG_ORIG(MSG_EM_JAVELIN_ALT1),	EM_JAVELIN },
987 
988 	{ MSG_ORIG(MSG_EM_FIREPATH),		EM_FIREPATH },
989 	{ MSG_ORIG(MSG_EM_FIREPATH_ALT1),	EM_FIREPATH },
990 
991 	{ MSG_ORIG(MSG_EM_ZSP),			EM_ZSP },
992 	{ MSG_ORIG(MSG_EM_ZSP_ALT1),		EM_ZSP },
993 
994 	{ MSG_ORIG(MSG_EM_MMIX),		EM_MMIX },
995 	{ MSG_ORIG(MSG_EM_MMIX_ALT1),		EM_MMIX },
996 
997 	{ MSG_ORIG(MSG_EM_HUANY),		EM_HUANY },
998 	{ MSG_ORIG(MSG_EM_HUANY_ALT1),		EM_HUANY },
999 
1000 	{ MSG_ORIG(MSG_EM_PRISM),		EM_PRISM },
1001 	{ MSG_ORIG(MSG_EM_PRISM_ALT1),		EM_PRISM },
1002 
1003 	{ MSG_ORIG(MSG_EM_AVR),			EM_AVR },
1004 	{ MSG_ORIG(MSG_EM_AVR_ALT1),		EM_AVR },
1005 
1006 	{ MSG_ORIG(MSG_EM_FR30),		EM_FR30 },
1007 	{ MSG_ORIG(MSG_EM_FR30_ALT1),		EM_FR30 },
1008 
1009 	{ MSG_ORIG(MSG_EM_D10V),		EM_D10V },
1010 	{ MSG_ORIG(MSG_EM_D10V_ALT1),		EM_D10V },
1011 
1012 	{ MSG_ORIG(MSG_EM_D30V),		EM_D30V },
1013 	{ MSG_ORIG(MSG_EM_D30V_ALT1),		EM_D30V },
1014 
1015 	{ MSG_ORIG(MSG_EM_V850),		EM_V850 },
1016 	{ MSG_ORIG(MSG_EM_V850_ALT1),		EM_V850 },
1017 
1018 	{ MSG_ORIG(MSG_EM_M32R),		EM_M32R },
1019 	{ MSG_ORIG(MSG_EM_M32R_ALT1),		EM_M32R },
1020 
1021 	{ MSG_ORIG(MSG_EM_MN10300),		EM_MN10300 },
1022 	{ MSG_ORIG(MSG_EM_MN10300_ALT1),	EM_MN10300 },
1023 
1024 	{ MSG_ORIG(MSG_EM_MN10200),		EM_MN10200 },
1025 	{ MSG_ORIG(MSG_EM_MN10200_ALT1),	EM_MN10200 },
1026 
1027 	{ MSG_ORIG(MSG_EM_PJ),			EM_PJ },
1028 	{ MSG_ORIG(MSG_EM_PJ_ALT1),		EM_PJ },
1029 
1030 	{ MSG_ORIG(MSG_EM_OPENRISC),		EM_OPENRISC },
1031 	{ MSG_ORIG(MSG_EM_OPENRISC_ALT1),	EM_OPENRISC },
1032 
1033 	{ MSG_ORIG(MSG_EM_ARC_A5),		EM_ARC_A5 },
1034 	{ MSG_ORIG(MSG_EM_ARC_A5_ALT1),		EM_ARC_A5 },
1035 
1036 	{ MSG_ORIG(MSG_EM_XTENSA),		EM_XTENSA },
1037 	{ MSG_ORIG(MSG_EM_XTENSA_ALT1),		EM_XTENSA },
1038 
1039 	{ NULL }
1040 };
1041 #if	(EM_NUM != (EM_XTENSA + 1))
1042 #error	"EM_NUM has grown"
1043 #endif
1044 
1045 
1046 /*
1047  * ELF header ELFOSABI_* values (and common aliases)
1048  */
1049 static elfedit_atoui_sym_t sym_elfosabi[] = {
1050 	{ MSG_ORIG(MSG_ELFOSABI_NONE),		ELFOSABI_NONE },
1051 	{ MSG_ORIG(MSG_ELFOSABI_NONE_ALT1),	ELFOSABI_NONE },
1052 
1053 	{ MSG_ORIG(MSG_ELFOSABI_SYSV),		ELFOSABI_SYSV },
1054 	{ MSG_ORIG(MSG_ELFOSABI_SYSV_ALT1),	ELFOSABI_SYSV },
1055 
1056 	{ MSG_ORIG(MSG_ELFOSABI_HPUX),		ELFOSABI_HPUX },
1057 	{ MSG_ORIG(MSG_ELFOSABI_HPUX_ALT1),	ELFOSABI_HPUX },
1058 
1059 	{ MSG_ORIG(MSG_ELFOSABI_NETBSD),	ELFOSABI_NETBSD },
1060 	{ MSG_ORIG(MSG_ELFOSABI_NETBSD_ALT1),	ELFOSABI_NETBSD },
1061 
1062 	{ MSG_ORIG(MSG_ELFOSABI_LINUX),		ELFOSABI_LINUX },
1063 	{ MSG_ORIG(MSG_ELFOSABI_LINUX_ALT1),	ELFOSABI_LINUX },
1064 
1065 	{ MSG_ORIG(MSG_ELFOSABI_SOLARIS),	ELFOSABI_SOLARIS },
1066 	{ MSG_ORIG(MSG_ELFOSABI_SOLARIS_ALT1),	ELFOSABI_SOLARIS },
1067 
1068 	{ MSG_ORIG(MSG_ELFOSABI_AIX),		ELFOSABI_AIX },
1069 	{ MSG_ORIG(MSG_ELFOSABI_AIX_ALT1),	ELFOSABI_AIX },
1070 
1071 	{ MSG_ORIG(MSG_ELFOSABI_IRIX),		ELFOSABI_IRIX },
1072 	{ MSG_ORIG(MSG_ELFOSABI_IRIX_ALT1),	ELFOSABI_IRIX },
1073 
1074 	{ MSG_ORIG(MSG_ELFOSABI_FREEBSD),	ELFOSABI_FREEBSD },
1075 	{ MSG_ORIG(MSG_ELFOSABI_FREEBSD_ALT1),	ELFOSABI_FREEBSD },
1076 
1077 	{ MSG_ORIG(MSG_ELFOSABI_TRU64),		ELFOSABI_TRU64 },
1078 	{ MSG_ORIG(MSG_ELFOSABI_TRU64_ALT1),	ELFOSABI_TRU64 },
1079 
1080 	{ MSG_ORIG(MSG_ELFOSABI_MODESTO),	ELFOSABI_MODESTO },
1081 	{ MSG_ORIG(MSG_ELFOSABI_MODESTO_ALT1),	ELFOSABI_MODESTO },
1082 
1083 	{ MSG_ORIG(MSG_ELFOSABI_OPENBSD),	ELFOSABI_OPENBSD },
1084 	{ MSG_ORIG(MSG_ELFOSABI_OPENBSD_ALT1),	ELFOSABI_OPENBSD },
1085 
1086 	{ MSG_ORIG(MSG_ELFOSABI_OPENVMS),	ELFOSABI_OPENVMS },
1087 	{ MSG_ORIG(MSG_ELFOSABI_OPENVMS_ALT1),	ELFOSABI_OPENVMS },
1088 
1089 	{ MSG_ORIG(MSG_ELFOSABI_NSK),		ELFOSABI_NSK },
1090 	{ MSG_ORIG(MSG_ELFOSABI_NSK_ALT1),	ELFOSABI_NSK },
1091 
1092 	{ MSG_ORIG(MSG_ELFOSABI_AROS),		ELFOSABI_AROS },
1093 	{ MSG_ORIG(MSG_ELFOSABI_AROS_ALT1),	ELFOSABI_AROS },
1094 
1095 	{ MSG_ORIG(MSG_ELFOSABI_ARM),		ELFOSABI_ARM },
1096 	{ MSG_ORIG(MSG_ELFOSABI_ARM_ALT1),	ELFOSABI_ARM },
1097 
1098 	{ MSG_ORIG(MSG_ELFOSABI_STANDALONE),	ELFOSABI_STANDALONE },
1099 	{ MSG_ORIG(MSG_ELFOSABI_STANDALONE_ALT1), ELFOSABI_STANDALONE },
1100 
1101 	{ NULL }
1102 };
1103 
1104 
1105 /*
1106  * Program header PT_* type values
1107  */
1108 static elfedit_atoui_sym_t sym_pt[] = {
1109 	{ MSG_ORIG(MSG_PT_NULL),		PT_NULL },
1110 	{ MSG_ORIG(MSG_PT_NULL_ALT1),		PT_NULL },
1111 
1112 	{ MSG_ORIG(MSG_PT_LOAD),		PT_LOAD },
1113 	{ MSG_ORIG(MSG_PT_LOAD_ALT1),		PT_LOAD },
1114 
1115 	{ MSG_ORIG(MSG_PT_DYNAMIC),		PT_DYNAMIC },
1116 	{ MSG_ORIG(MSG_PT_DYNAMIC_ALT1),	PT_DYNAMIC },
1117 
1118 	{ MSG_ORIG(MSG_PT_INTERP),		PT_INTERP },
1119 	{ MSG_ORIG(MSG_PT_INTERP_ALT1),		PT_INTERP },
1120 
1121 	{ MSG_ORIG(MSG_PT_NOTE),		PT_NOTE },
1122 	{ MSG_ORIG(MSG_PT_NOTE_ALT1),		PT_NOTE },
1123 
1124 	{ MSG_ORIG(MSG_PT_SHLIB),		PT_SHLIB },
1125 	{ MSG_ORIG(MSG_PT_SHLIB_ALT1),		PT_SHLIB },
1126 
1127 	{ MSG_ORIG(MSG_PT_PHDR),		PT_PHDR },
1128 	{ MSG_ORIG(MSG_PT_PHDR_ALT1),		PT_PHDR },
1129 
1130 	{ MSG_ORIG(MSG_PT_TLS),			PT_TLS },
1131 	{ MSG_ORIG(MSG_PT_TLS_ALT1),		PT_TLS },
1132 
1133 	{ MSG_ORIG(MSG_PT_SUNW_UNWIND),		PT_SUNW_UNWIND },
1134 	{ MSG_ORIG(MSG_PT_SUNW_UNWIND_ALT1),	PT_SUNW_UNWIND },
1135 
1136 	{ MSG_ORIG(MSG_PT_SUNWBSS),		PT_SUNWBSS },
1137 	{ MSG_ORIG(MSG_PT_SUNWBSS_ALT1),	PT_SUNWBSS },
1138 
1139 	{ MSG_ORIG(MSG_PT_SUNWSTACK),		PT_SUNWSTACK },
1140 	{ MSG_ORIG(MSG_PT_SUNWSTACK_ALT1),	PT_SUNWSTACK },
1141 
1142 	{ MSG_ORIG(MSG_PT_SUNWDTRACE),		PT_SUNWDTRACE },
1143 	{ MSG_ORIG(MSG_PT_SUNWDTRACE_ALT1),	PT_SUNWDTRACE },
1144 
1145 	{ MSG_ORIG(MSG_PT_SUNWCAP),		PT_SUNWCAP },
1146 	{ MSG_ORIG(MSG_PT_SUNWCAP_ALT1),	PT_SUNWCAP },
1147 
1148 	{ NULL }
1149 };
1150 
1151 
1152 /*
1153  * Program header PF_* flag values
1154  */
1155 static elfedit_atoui_sym_t sym_pf[] = {
1156 	{ MSG_ORIG(MSG_PF_X),			PF_X },
1157 	{ MSG_ORIG(MSG_PF_X_ALT1),		PF_X },
1158 
1159 	{ MSG_ORIG(MSG_PF_W),			PF_W },
1160 	{ MSG_ORIG(MSG_PF_W_ALT1),		PF_W },
1161 
1162 	{ MSG_ORIG(MSG_PF_R),			PF_R },
1163 	{ MSG_ORIG(MSG_PF_R_ALT1),		PF_R },
1164 
1165 	{ NULL }
1166 };
1167 
1168 
1169 /*
1170  * Section header SHF_* flag values
1171  */
1172 static elfedit_atoui_sym_t sym_shf[] = {
1173 	{ MSG_ORIG(MSG_SHF_WRITE),		SHF_WRITE },
1174 	{ MSG_ORIG(MSG_SHF_WRITE_ALT1),		SHF_WRITE },
1175 
1176 	{ MSG_ORIG(MSG_SHF_ALLOC),		SHF_ALLOC },
1177 	{ MSG_ORIG(MSG_SHF_ALLOC_ALT1),		SHF_ALLOC },
1178 
1179 	{ MSG_ORIG(MSG_SHF_EXECINSTR),		SHF_EXECINSTR },
1180 	{ MSG_ORIG(MSG_SHF_EXECINSTR_ALT1),	SHF_EXECINSTR },
1181 
1182 	{ MSG_ORIG(MSG_SHF_MERGE),		SHF_MERGE },
1183 	{ MSG_ORIG(MSG_SHF_MERGE_ALT1),		SHF_MERGE },
1184 
1185 	{ MSG_ORIG(MSG_SHF_STRINGS),		SHF_STRINGS },
1186 	{ MSG_ORIG(MSG_SHF_STRINGS_ALT1),	SHF_STRINGS },
1187 
1188 	{ MSG_ORIG(MSG_SHF_INFO_LINK),		SHF_INFO_LINK },
1189 	{ MSG_ORIG(MSG_SHF_INFO_LINK_ALT1),	SHF_INFO_LINK },
1190 
1191 	{ MSG_ORIG(MSG_SHF_LINK_ORDER),		SHF_LINK_ORDER },
1192 	{ MSG_ORIG(MSG_SHF_LINK_ORDER_ALT1),	SHF_LINK_ORDER },
1193 
1194 	{ MSG_ORIG(MSG_SHF_OS_NONCONFORMING),	SHF_OS_NONCONFORMING },
1195 	{ MSG_ORIG(MSG_SHF_OS_NONCONFORMING_ALT1), SHF_OS_NONCONFORMING },
1196 
1197 	{ MSG_ORIG(MSG_SHF_GROUP),		SHF_GROUP },
1198 	{ MSG_ORIG(MSG_SHF_GROUP_ALT1),		SHF_GROUP },
1199 
1200 	{ MSG_ORIG(MSG_SHF_TLS),		SHF_TLS },
1201 	{ MSG_ORIG(MSG_SHF_TLS_ALT1),		SHF_TLS },
1202 
1203 	{ MSG_ORIG(MSG_SHF_AMD64_LARGE),	SHF_AMD64_LARGE },
1204 	{ MSG_ORIG(MSG_SHF_AMD64_LARGE_ALT1),	SHF_AMD64_LARGE },
1205 
1206 	{ MSG_ORIG(MSG_SHF_ORDERED),		SHF_ORDERED },
1207 	{ MSG_ORIG(MSG_SHF_ORDERED_ALT1),	SHF_ORDERED },
1208 
1209 	{ MSG_ORIG(MSG_SHF_EXCLUDE),		SHF_EXCLUDE },
1210 	{ MSG_ORIG(MSG_SHF_EXCLUDE_ALT1),	SHF_EXCLUDE },
1211 
1212 	{ NULL }
1213 };
1214 
1215 /*
1216  * ELF symbol bindings (st_info ELF_ST_BIND)
1217  */
1218 static elfedit_atoui_sym_t sym_stb[] = {
1219 	{ MSG_ORIG(MSG_STB_LOCAL),		STB_LOCAL },
1220 	{ MSG_ORIG(MSG_STB_LOCAL_ALT1),		STB_LOCAL },
1221 
1222 	{ MSG_ORIG(MSG_STB_GLOBAL),		STB_GLOBAL },
1223 	{ MSG_ORIG(MSG_STB_GLOBAL_ALT1),	STB_GLOBAL },
1224 
1225 	{ MSG_ORIG(MSG_STB_WEAK),		STB_WEAK },
1226 	{ MSG_ORIG(MSG_STB_WEAK_ALT1),		STB_WEAK },
1227 
1228 	{ NULL }
1229 };
1230 
1231 /*
1232  * ELF symbol types (st_info ELF_ST_TYPE)
1233  */
1234 static elfedit_atoui_sym_t sym_stt[] = {
1235 	{ MSG_ORIG(MSG_STT_NOTYPE),		STT_NOTYPE },
1236 	{ MSG_ORIG(MSG_STT_NOTYPE_ALT1),	STT_NOTYPE },
1237 
1238 	{ MSG_ORIG(MSG_STT_OBJECT),		STT_OBJECT },
1239 	{ MSG_ORIG(MSG_STT_OBJECT_ALT1),	STT_OBJECT },
1240 
1241 	{ MSG_ORIG(MSG_STT_FUNC),		STT_FUNC },
1242 	{ MSG_ORIG(MSG_STT_FUNC_ALT1),		STT_FUNC },
1243 
1244 	{ MSG_ORIG(MSG_STT_SECTION),		STT_SECTION },
1245 	{ MSG_ORIG(MSG_STT_SECTION_ALT1),	STT_SECTION },
1246 
1247 	{ MSG_ORIG(MSG_STT_FILE),		STT_FILE },
1248 	{ MSG_ORIG(MSG_STT_FILE_ALT1),		STT_FILE },
1249 
1250 	{ MSG_ORIG(MSG_STT_COMMON),		STT_COMMON },
1251 	{ MSG_ORIG(MSG_STT_COMMON_ALT1),	STT_COMMON },
1252 
1253 	{ MSG_ORIG(MSG_STT_TLS),		STT_TLS },
1254 	{ MSG_ORIG(MSG_STT_TLS_ALT1),		STT_TLS },
1255 
1256 	{ NULL }
1257 };
1258 
1259 /*
1260  * ELF symbol visibility (st_other ELF_ST_VISIBILITY)
1261  */
1262 static elfedit_atoui_sym_t sym_stv[] = {
1263 	{ MSG_ORIG(MSG_STV_DEFAULT),		STV_DEFAULT },
1264 	{ MSG_ORIG(MSG_STV_DEFAULT_ALT1),	STV_DEFAULT },
1265 
1266 	{ MSG_ORIG(MSG_STV_INTERNAL),		STV_INTERNAL },
1267 	{ MSG_ORIG(MSG_STV_INTERNAL_ALT1),	STV_INTERNAL },
1268 
1269 	{ MSG_ORIG(MSG_STV_HIDDEN),		STV_HIDDEN },
1270 	{ MSG_ORIG(MSG_STV_HIDDEN_ALT1),	STV_HIDDEN },
1271 
1272 	{ MSG_ORIG(MSG_STV_PROTECTED),		STV_PROTECTED },
1273 	{ MSG_ORIG(MSG_STV_PROTECTED_ALT1),	STV_PROTECTED },
1274 
1275 	{ MSG_ORIG(MSG_STV_EXPORTED),		STV_EXPORTED },
1276 	{ MSG_ORIG(MSG_STV_EXPORTED_ALT1),	STV_EXPORTED },
1277 
1278 	{ MSG_ORIG(MSG_STV_SINGLETON),		STV_SINGLETON },
1279 	{ MSG_ORIG(MSG_STV_SINGLETON_ALT1),	STV_SINGLETON },
1280 
1281 	{ MSG_ORIG(MSG_STV_ELIMINATE),		STV_ELIMINATE },
1282 	{ MSG_ORIG(MSG_STV_ELIMINATE_ALT1),	STV_ELIMINATE },
1283 
1284 	{ NULL }
1285 };
1286 
1287 /*
1288  * ELF syminfo SYMINFO_BT_ special boundto values
1289  */
1290 static elfedit_atoui_sym_t sym_syminfo_bt[] = {
1291 	{ MSG_ORIG(MSG_SYMINFO_BT_SELF),	SYMINFO_BT_SELF },
1292 	{ MSG_ORIG(MSG_SYMINFO_BT_SELF_ALT1),	SYMINFO_BT_SELF },
1293 
1294 	{ MSG_ORIG(MSG_SYMINFO_BT_PARENT),	SYMINFO_BT_PARENT },
1295 	{ MSG_ORIG(MSG_SYMINFO_BT_PARENT_ALT1),	SYMINFO_BT_PARENT },
1296 
1297 	{ MSG_ORIG(MSG_SYMINFO_BT_NONE),	SYMINFO_BT_NONE },
1298 	{ MSG_ORIG(MSG_SYMINFO_BT_NONE_ALT1),	SYMINFO_BT_NONE },
1299 
1300 	{ NULL }
1301 };
1302 
1303 
1304 /*
1305  * ELF syminfo SYMINFO_FLG_ flags
1306  */
1307 static elfedit_atoui_sym_t sym_syminfo_flg[] = {
1308 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECT),	SYMINFO_FLG_DIRECT },
1309 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECT_ALT1), SYMINFO_FLG_DIRECT },
1310 
1311 	{ MSG_ORIG(MSG_SYMINFO_FLG_COPY),	SYMINFO_FLG_COPY },
1312 	{ MSG_ORIG(MSG_SYMINFO_FLG_COPY_ALT1),	SYMINFO_FLG_COPY },
1313 
1314 	{ MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD),	SYMINFO_FLG_LAZYLOAD },
1315 	{ MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD_ALT1), SYMINFO_FLG_LAZYLOAD },
1316 
1317 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND),	SYMINFO_FLG_DIRECTBIND },
1318 	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND_ALT1), SYMINFO_FLG_DIRECTBIND },
1319 
1320 	{ MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT), SYMINFO_FLG_NOEXTDIRECT },
1321 	{ MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT_ALT1), SYMINFO_FLG_NOEXTDIRECT },
1322 
1323 	{ NULL }
1324 };
1325 
1326 
1327 /*
1328  * ELF capabilities tag CA_ values
1329  */
1330 static elfedit_atoui_sym_t sym_ca[] = {
1331 	{ MSG_ORIG(MSG_CA_SUNW_NULL),		CA_SUNW_NULL },
1332 	{ MSG_ORIG(MSG_CA_SUNW_NULL_ALT1),	CA_SUNW_NULL },
1333 
1334 	{ MSG_ORIG(MSG_CA_SUNW_HW_1),		CA_SUNW_HW_1 },
1335 	{ MSG_ORIG(MSG_CA_SUNW_HW_1_ALT1),	CA_SUNW_HW_1 },
1336 
1337 	{ MSG_ORIG(MSG_CA_SUNW_SF_1),		CA_SUNW_SF_1 },
1338 	{ MSG_ORIG(MSG_CA_SUNW_SF_1_ALT1),	CA_SUNW_SF_1 },
1339 
1340 	{ NULL }
1341 };
1342 
1343 
1344 /*
1345  * AV_386 flags used for CA_SUNW_HW_1 capabilities
1346  *
1347  * The space for this is reserved at compile time, but the values are
1348  * filled in at runtime on demand from the usr/src/common/elfcap code.
1349  * Note that we need two slots for every capability, one for the full
1350  * string, and another for the informal lowercase version.
1351  */
1352 static elfedit_atoui_sym_t sym_av_386[(2 * ELFCAP_NUM_HW1_386) + 1];
1353 
1354 /*
1355  * AV_SPARC flags used for CA_SUNW_HW_1 capabilities
1356  *
1357  * The space for this is reserved at compile time, but the values are
1358  * filled in at runtime on demand from the usr/src/common/elfcap code.
1359  * Note that we need two slots for every capability, one for the full
1360  * string, and another for the informal lowercase version.
1361  */
1362 static elfedit_atoui_sym_t sym_av_sparc[(2 * ELFCAP_NUM_HW1_SPARC) + 1];
1363 
1364 /*
1365  * SF1_SUNW flags used for CA_SUNW_SF_1 capabilities
1366  *
1367  * The space for this is reserved at compile time, but the values are
1368  * filled in at runtime on demand from the usr/src/common/elfcap code.
1369  * Note that we need two slots for every capability, one for the full
1370  * string, and another for the informal lowercase version.
1371  */
1372 static elfedit_atoui_sym_t sym_sf1_sunw[(2 * ELFCAP_NUM_SF1) + 1];
1373 
1374 
1375 
1376 
1377 
1378 
1379 
1380 
1381 /*
1382  * Array of pointers to atoui arrays for each constant type, indexed
1383  * by elfedit_const_t value. The number and order of entries in this
1384  * table must agree with the definition of elfedit_const_t in elfedit.h.
1385  */
1386 static elfedit_atoui_sym_t *sym_table[] = {
1387 	sym_outstyle,		/* 0: ELFEDIT_CONST_OUTSTYLE */
1388 	sym_minus_o_outstyle,	/* 1: ELFEDIT_CONST_OUTSTYLE_MO */
1389 	sym_bool,		/* 2: ELFEDIT_CONST_BOOL */
1390 	sym_shn,		/* 3: ELFEDIT_CONST_SHN */
1391 	sym_sht,		/* 4: ELFEDIT_CONST_SHT */
1392 	sym_sht_strtab,		/* 5: ELFEDIT_CONST_SHT_STRTAB */
1393 	sym_sht_allsymtab,	/* 6: ELFEDIT_CONST_SHT_ALLSYMTAB */
1394 	sym_sht_symtab,		/* 7: ELFEDIT_CONST_SHT_SYMTAB */
1395 	sym_sht_dynsym,		/* 8: ELFEDIT_CONST_SHT_DYNSYM */
1396 	sym_sht_ldynsym,	/* 9: ELFEDIT_CONST_SHT_LDYNSYM */
1397 	sym_dt,			/* 10: ELFEDIT_CONST_DT: Dynamic tags */
1398 	sym_df,			/* 11: ELFEDIT_CONST_DF: DT_FLAGS */
1399 	sym_df_p1,		/* 12: ELFEDIT_CONST_DF_P1: DF_POSFLAG_1 */
1400 	sym_df_1,		/* 13: ELFEDIT_CONST_DF_1: DT_FLAGS_1 */
1401 	sym_dtf_1,		/* 14: ELFEDIT_CONST_DTF_1: DT_FEATURE_1 */
1402 	sym_ei,			/* 15: ELFEDIT_CONST_EI: Ehdr e_ident indexes */
1403 	sym_et,			/* 16: ELFEDIT_CONST_ET: Ehdr obj type */
1404 	sym_elfclass,		/* 17: ELFEDIT_CONST_ELFCLASS: Ehdr class */
1405 	sym_elfdata,		/* 18: ELFEDIT_CONST_ELFDATA: Ehdr endian */
1406 	sym_ef,			/* 19: ELFEDIT_CONST_EF: Ehdr flags */
1407 	sym_ev,			/* 20: ELFEDIT_CONST_EV: Ehdr version */
1408 	sym_em,			/* 21: ELFEDIT_CONST_EM: Ehdr machine */
1409 	sym_elfosabi,		/* 22: ELFEDIT_CONST_ELFOSABI: Ehdr ABI */
1410 	sym_pt,			/* 23: ELFEDIT_CONST_PT: Phdr type */
1411 	sym_pf,			/* 24: ELFEDIT_CONST_PF: Phdr flags */
1412 	sym_shf,		/* 25: ELFEDIT_CONST_SHF: Shdr flags */
1413 	sym_stb,		/* 26: ELFEDIT_CONST_STB: Sym binding */
1414 	sym_stt,		/* 27: ELFEDIT_CONST_STT: Sym type */
1415 	sym_stv,		/* 28: ELFEDIT_CONST_STV: Sym visibility */
1416 	sym_syminfo_bt,		/* 29: ELFEDIT_CONST_SYMINFO_BT:Syminfo bndto */
1417 	sym_syminfo_flg,	/* 30: ELFEDIT_CONST_SYMINFO_FLG:Syminfo flag */
1418 	sym_ca,			/* 31: ELFEDIT_CONST_CA: Capabilities tags */
1419 	NULL,			/* 32: ELFEDIT_CONST_AV_386: X86 HW caps */
1420 	NULL,			/* 33: ELFEDIT_CONST_AV_SPARC: sparc HW caps */
1421 	NULL,			/* 34: ELFEDIT_CONST_SF1_SUNW: software caps */
1422 };
1423 
1424 
1425 
1426 
1427 
1428 
1429 
1430 /*
1431  * Fill in the specified hardware/software capability array
1432  * with data from usr/src/common/elfcap.
1433  *
1434  * entry:
1435  *	const_type - Index of constant item being filled
1436  *	arr - elfedit_atoui_sym_t array to be filled
1437  *	desc - Array of capability descriptors from elfcap
1438  *	cnt - # of capability descriptors.
1439  *
1440  * exit:
1441  *	arr is expected to have [(2 * cnt) + 1] elements, all zero filled.
1442  *	For each descriptor, 2 array elements are filled in. The first one
1443  *	has the full name, and the second has the lowecase informal version.
1444  *	The final element of arr is left as NULL, to serve as termination.
1445  */
1446 static void
1447 fill_capability_array(elfedit_const_t const_type,
1448     elfedit_atoui_sym_t *arr, const elfcap_desc_t *desc, size_t cnt)
1449 {
1450 	sym_table[const_type] = arr;
1451 
1452 	for (; cnt-- > 0; desc++) {
1453 		/*
1454 		 * Ignore "placeholder" items. These represent
1455 		 * unallocated holes in the capability bits.
1456 		 */
1457 		if (desc->c_val == 0)
1458 			continue;
1459 
1460 		arr->sym_name = desc->c_full.s_str;
1461 		arr->sym_value = desc->c_val;
1462 		arr++;
1463 
1464 		arr->sym_name = desc->c_lc.s_str;
1465 		arr->sym_value = desc->c_val;
1466 		arr++;
1467 	}
1468 
1469 }
1470 
1471 
1472 
1473 /*
1474  * Given an elfedit_const_t value, return the array of elfedit_atoui_sym_t
1475  * entries that it represents.
1476  */
1477 elfedit_atoui_sym_t *
1478 elfedit_const_to_atoui(elfedit_const_t const_type)
1479 {
1480 	if ((const_type < 0) ||
1481 	    (const_type >= (sizeof (sym_table) / sizeof (sym_table[0]))))
1482 		elfedit_msg(ELFEDIT_MSG_ERR, MSG_INTL(MSG_ERR_BADCONST));
1483 
1484 	/* Fill capability constant array on demand? */
1485 	switch (const_type) {
1486 	case ELFEDIT_CONST_AV_386:
1487 		if (sym_table[ELFEDIT_CONST_AV_386] == NULL)
1488 			fill_capability_array(ELFEDIT_CONST_AV_386,
1489 			    sym_av_386, elfcap_getdesc_hw1_386(),
1490 			    ELFCAP_NUM_HW1_386);
1491 		break;
1492 	case ELFEDIT_CONST_AV_SPARC:
1493 		if (sym_table[ELFEDIT_CONST_AV_SPARC] == NULL)
1494 			fill_capability_array(ELFEDIT_CONST_AV_SPARC,
1495 			    sym_av_sparc, elfcap_getdesc_hw1_sparc(),
1496 			    ELFCAP_NUM_HW1_SPARC);
1497 		break;
1498 	case ELFEDIT_CONST_SF1_SUNW:
1499 		if (sym_table[ELFEDIT_CONST_SF1_SUNW] == NULL)
1500 			fill_capability_array(ELFEDIT_CONST_SF1_SUNW,
1501 			    sym_sf1_sunw, elfcap_getdesc_sf1(), ELFCAP_NUM_SF1);
1502 		break;
1503 	}
1504 
1505 	return (sym_table[const_type]);
1506 }
1507 
1508 
1509 
1510 /*
1511  * Return the elfedit_atoui_t array that corresponds to the
1512  * CA_SUNW_HW_1 hardware capabiliies field for a given
1513  * machine type.
1514  *
1515  * This routine will return NULL if there is no definition for the
1516  * machine specified.
1517  */
1518 elfedit_atoui_sym_t *
1519 elfedit_mach_sunw_hw1_to_atoui(int mach)
1520 {
1521 	switch (mach) {
1522 	case EM_386:
1523 	case EM_486:
1524 	case EM_AMD64:
1525 		return (elfedit_const_to_atoui(ELFEDIT_CONST_AV_386));
1526 
1527 	case EM_SPARC:
1528 	case EM_SPARC32PLUS:
1529 	case EM_SPARCV9:
1530 		return (elfedit_const_to_atoui(ELFEDIT_CONST_AV_SPARC));
1531 	}
1532 
1533 	/* A machine we don't know about */
1534 	return (NULL);
1535 }
1536