/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */

/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */
#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include	<stdlib.h>
#include	<stdio.h>
#include	<unistd.h>
#include	<libintl.h>
#include	<libelf.h>
#include	<sys/machelf.h>
#include	<link.h>
#include	<strings.h>
#include	<ctype.h>
#include	<elfedit.h>
#include	<_elfedit.h>
#include	<sys/elf_SPARC.h>
#include	<sys/elf_amd64.h>
#include	<sys/auxv_386.h>
#include	<sys/auxv_SPARC.h>
#include	<msg.h>
#include	<elfcap.h>



/*
 * This file contains support for mapping well known ELF constants
 * to their numeric values. It is a layer on top of the elfedit_atoui()
 * routines defined in util.c. The idea is that centralizing all the
 * support for such constants will improve consistency between modules,
 * allow for sharing of commonly needed items, and make the modules
 * simpler.
 */




/*
 * elfedit output style, with and without leading -o
 */
static elfedit_atoui_sym_t sym_outstyle[] = {
	{ MSG_ORIG(MSG_STR_DEFAULT),		ELFEDIT_OUTSTYLE_DEFAULT },
	{ MSG_ORIG(MSG_STR_SIMPLE),		ELFEDIT_OUTSTYLE_SIMPLE },
	{ MSG_ORIG(MSG_STR_NUM),		ELFEDIT_OUTSTYLE_NUM },
	{ NULL }
};
static elfedit_atoui_sym_t sym_minus_o_outstyle[] = {
	{ MSG_ORIG(MSG_STR_MINUS_O_DEFAULT),	ELFEDIT_OUTSTYLE_DEFAULT },
	{ MSG_ORIG(MSG_STR_MINUS_O_SIMPLE),	ELFEDIT_OUTSTYLE_SIMPLE },
	{ MSG_ORIG(MSG_STR_MINUS_O_NUM),	ELFEDIT_OUTSTYLE_NUM },
	{ NULL }
};


/*
 * Booleans
 */
static elfedit_atoui_sym_t sym_bool[] = {
	{ MSG_ORIG(MSG_STR_T),			1 },
	{ MSG_ORIG(MSG_STR_F),			0 },
	{ MSG_ORIG(MSG_STR_TRUE),		1 },
	{ MSG_ORIG(MSG_STR_FALSE),		0 },
	{ MSG_ORIG(MSG_STR_ON),			1 },
	{ MSG_ORIG(MSG_STR_OFF),		0 },
	{ MSG_ORIG(MSG_STR_YES),		1 },
	{ MSG_ORIG(MSG_STR_NO),			0 },
	{ MSG_ORIG(MSG_STR_Y),			1 },
	{ MSG_ORIG(MSG_STR_N),			0 },
	{ NULL }
};

/*
 * ELF section indexes with support for the special index names.
 */
static elfedit_atoui_sym_t sym_shn[] = {
	{ MSG_ORIG(MSG_SHN_UNDEF),		SHN_UNDEF },
	{ MSG_ORIG(MSG_SHN_UNDEF_ALT1),		SHN_UNDEF },

	{ MSG_ORIG(MSG_SHN_SUNW_IGNORE),	SHN_SUNW_IGNORE },
	{ MSG_ORIG(MSG_SHN_SUNW_IGNORE_ALT1),	SHN_SUNW_IGNORE },

	{ MSG_ORIG(MSG_SHN_BEFORE),		SHN_BEFORE },
	{ MSG_ORIG(MSG_SHN_BEFORE_ALT1),	SHN_BEFORE },

	{ MSG_ORIG(MSG_SHN_AFTER),		SHN_AFTER },
	{ MSG_ORIG(MSG_SHN_AFTER_ALT1), 	SHN_AFTER },

	{ MSG_ORIG(MSG_SHN_AMD64_LCOMMON), 	SHN_AMD64_LCOMMON },
	{ MSG_ORIG(MSG_SHN_AMD64_LCOMMON_ALT1),	SHN_AMD64_LCOMMON },

	{ MSG_ORIG(MSG_SHN_ABS),		SHN_ABS },
	{ MSG_ORIG(MSG_SHN_ABS_ALT1),		SHN_ABS },

	{ MSG_ORIG(MSG_SHN_COMMON),		SHN_COMMON },
	{ MSG_ORIG(MSG_SHN_COMMON_ALT1),	SHN_COMMON },

	{ MSG_ORIG(MSG_SHN_XINDEX),		SHN_XINDEX },
	{ MSG_ORIG(MSG_SHN_XINDEX_ALT1),	SHN_XINDEX },

	{ NULL }
};

/*
 * ELF section types.
 */
static elfedit_atoui_sym_t sym_sht[] = {
	{ MSG_ORIG(MSG_SHT_NULL),		SHT_NULL },
	{ MSG_ORIG(MSG_SHT_NULL_ALT1),		SHT_NULL },

	{ MSG_ORIG(MSG_SHT_PROGBITS),		SHT_PROGBITS },
	{ MSG_ORIG(MSG_SHT_PROGBITS_ALT1),	SHT_PROGBITS },

	{ MSG_ORIG(MSG_SHT_SYMTAB),		SHT_SYMTAB },
	{ MSG_ORIG(MSG_SHT_SYMTAB_ALT1),	SHT_SYMTAB },

	{ MSG_ORIG(MSG_SHT_STRTAB),		SHT_STRTAB },
	{ MSG_ORIG(MSG_SHT_STRTAB_ALT1),	SHT_STRTAB },

	{ MSG_ORIG(MSG_SHT_RELA),		SHT_RELA },
	{ MSG_ORIG(MSG_SHT_RELA_ALT1),		SHT_RELA },

	{ MSG_ORIG(MSG_SHT_HASH),		SHT_HASH },
	{ MSG_ORIG(MSG_SHT_HASH_ALT1),		SHT_HASH },

	{ MSG_ORIG(MSG_SHT_DYNAMIC),		SHT_DYNAMIC },
	{ MSG_ORIG(MSG_SHT_DYNAMIC_ALT1),	SHT_DYNAMIC },

	{ MSG_ORIG(MSG_SHT_NOTE),		SHT_NOTE },
	{ MSG_ORIG(MSG_SHT_NOTE_ALT1),		SHT_NOTE },

	{ MSG_ORIG(MSG_SHT_NOBITS),		SHT_NOBITS },
	{ MSG_ORIG(MSG_SHT_NOBITS_ALT1),	SHT_NOBITS },

	{ MSG_ORIG(MSG_SHT_REL),		SHT_REL },
	{ MSG_ORIG(MSG_SHT_REL_ALT1),		SHT_REL },

	{ MSG_ORIG(MSG_SHT_SHLIB),		SHT_SHLIB },
	{ MSG_ORIG(MSG_SHT_SHLIB_ALT1),		SHT_SHLIB },

	{ MSG_ORIG(MSG_SHT_DYNSYM),		SHT_DYNSYM },
	{ MSG_ORIG(MSG_SHT_DYNSYM_ALT1),	SHT_DYNSYM },

	{ MSG_ORIG(MSG_SHT_INIT_ARRAY),		SHT_INIT_ARRAY },
	{ MSG_ORIG(MSG_SHT_INIT_ARRAY_ALT1),	SHT_INIT_ARRAY },

	{ MSG_ORIG(MSG_SHT_FINI_ARRAY),		SHT_FINI_ARRAY },
	{ MSG_ORIG(MSG_SHT_FINI_ARRAY_ALT1),	SHT_FINI_ARRAY },

	{ MSG_ORIG(MSG_SHT_PREINIT_ARRAY),	SHT_PREINIT_ARRAY },
	{ MSG_ORIG(MSG_SHT_PREINIT_ARRAY_ALT1),	SHT_PREINIT_ARRAY },

	{ MSG_ORIG(MSG_SHT_GROUP),		SHT_GROUP },
	{ MSG_ORIG(MSG_SHT_GROUP_ALT1),		SHT_GROUP },

	{ MSG_ORIG(MSG_SHT_SYMTAB_SHNDX),	SHT_SYMTAB_SHNDX },
	{ MSG_ORIG(MSG_SHT_SYMTAB_SHNDX_ALT1),	SHT_SYMTAB_SHNDX },

	{ MSG_ORIG(MSG_SHT_SUNW_SYMSORT),	SHT_SUNW_symsort },
	{ MSG_ORIG(MSG_SHT_SUNW_SYMSORT_ALT1),	SHT_SUNW_symsort },

	{ MSG_ORIG(MSG_SHT_SUNW_TLSSORT),	SHT_SUNW_tlssort },
	{ MSG_ORIG(MSG_SHT_SUNW_TLSSORT_ALT1),	SHT_SUNW_tlssort },

	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM),	SHT_SUNW_LDYNSYM },
	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM_ALT1),	SHT_SUNW_LDYNSYM },

	{ MSG_ORIG(MSG_SHT_SUNW_DOF),		SHT_SUNW_dof },
	{ MSG_ORIG(MSG_SHT_SUNW_DOF_ALT1),	SHT_SUNW_dof },

	{ MSG_ORIG(MSG_SHT_SUNW_CAP),		SHT_SUNW_cap },
	{ MSG_ORIG(MSG_SHT_SUNW_CAP_ALT1),	SHT_SUNW_cap },

	{ MSG_ORIG(MSG_SHT_SUNW_SIGNATURE),	SHT_SUNW_SIGNATURE },
	{ MSG_ORIG(MSG_SHT_SUNW_SIGNATURE_ALT1), SHT_SUNW_SIGNATURE },

	{ MSG_ORIG(MSG_SHT_SUNW_ANNOTATE),	SHT_SUNW_ANNOTATE },
	{ MSG_ORIG(MSG_SHT_SUNW_ANNOTATE_ALT1),	SHT_SUNW_ANNOTATE },

	{ MSG_ORIG(MSG_SHT_SUNW_DEBUGSTR),	SHT_SUNW_DEBUGSTR },
	{ MSG_ORIG(MSG_SHT_SUNW_DEBUGSTR_ALT1),	SHT_SUNW_DEBUGSTR },

	{ MSG_ORIG(MSG_SHT_SUNW_DEBUG),		SHT_SUNW_DEBUG },
	{ MSG_ORIG(MSG_SHT_SUNW_DEBUG_ALT1),	SHT_SUNW_DEBUG },

	{ MSG_ORIG(MSG_SHT_SUNW_MOVE),		SHT_SUNW_move },
	{ MSG_ORIG(MSG_SHT_SUNW_MOVE_ALT1),	SHT_SUNW_move },

	{ MSG_ORIG(MSG_SHT_SUNW_COMDAT),	SHT_SUNW_COMDAT },
	{ MSG_ORIG(MSG_SHT_SUNW_COMDAT_ALT1),	SHT_SUNW_COMDAT },

	{ MSG_ORIG(MSG_SHT_SUNW_SYMINFO),	SHT_SUNW_syminfo },
	{ MSG_ORIG(MSG_SHT_SUNW_SYMINFO_ALT1),	SHT_SUNW_syminfo },

	{ MSG_ORIG(MSG_SHT_SUNW_VERDEF),	SHT_SUNW_verdef },
	{ MSG_ORIG(MSG_SHT_SUNW_VERDEF_ALT1),	SHT_SUNW_verdef },

	{ MSG_ORIG(MSG_SHT_GNU_VERDEF),		SHT_GNU_verdef },
	{ MSG_ORIG(MSG_SHT_GNU_VERDEF_ALT1),	SHT_GNU_verdef },

	{ MSG_ORIG(MSG_SHT_SUNW_VERNEED),	SHT_SUNW_verneed },
	{ MSG_ORIG(MSG_SHT_SUNW_VERNEED_ALT1),	SHT_SUNW_verneed },

	{ MSG_ORIG(MSG_SHT_GNU_VERNEED),	SHT_GNU_verneed },
	{ MSG_ORIG(MSG_SHT_GNU_VERNEED_ALT1),	SHT_GNU_verneed },

	{ MSG_ORIG(MSG_SHT_SUNW_VERSYM),	SHT_SUNW_versym },
	{ MSG_ORIG(MSG_SHT_SUNW_VERSYM_ALT1),	SHT_SUNW_versym },

	{ MSG_ORIG(MSG_SHT_GNU_VERSYM),		SHT_GNU_versym },
	{ MSG_ORIG(MSG_SHT_GNU_VERSYM_ALT1),	SHT_GNU_versym },

	{ MSG_ORIG(MSG_SHT_SPARC_GOTDATA),	SHT_SPARC_GOTDATA },
	{ MSG_ORIG(MSG_SHT_SPARC_GOTDATA_ALT1),	SHT_SPARC_GOTDATA },

	{ MSG_ORIG(MSG_SHT_AMD64_UNWIND),	SHT_AMD64_UNWIND },
	{ MSG_ORIG(MSG_SHT_AMD64_UNWIND_ALT1),	SHT_AMD64_UNWIND },

	{ NULL }
};

/*
 * ELF section types.
 */
static elfedit_atoui_sym_t sym_sht_strtab[] = {
	{ MSG_ORIG(MSG_SHT_STRTAB),		SHT_STRTAB },
	{ MSG_ORIG(MSG_SHT_STRTAB_ALT1),	SHT_STRTAB },

	{ NULL }
};


/*
 * ELF section types for symbol tables
 */
static elfedit_atoui_sym_t sym_sht_allsymtab[] = {
	{ MSG_ORIG(MSG_SHT_SYMTAB),		SHT_SYMTAB },
	{ MSG_ORIG(MSG_SHT_SYMTAB_ALT1),	SHT_SYMTAB },

	{ MSG_ORIG(MSG_SHT_DYNSYM),		SHT_DYNSYM },
	{ MSG_ORIG(MSG_SHT_DYNSYM_ALT1),	SHT_DYNSYM },

	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM),	SHT_SUNW_LDYNSYM },
	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM_ALT1),	SHT_SUNW_LDYNSYM },

	{ NULL }
};

/*
 * ELF section types for SHT_SYMTAB
 */
static elfedit_atoui_sym_t sym_sht_symtab[] = {
	{ MSG_ORIG(MSG_SHT_SYMTAB),		SHT_SYMTAB },
	{ MSG_ORIG(MSG_SHT_SYMTAB_ALT1),	SHT_SYMTAB },

	{ NULL }
};

/*
 * ELF section types for SHT_SYMTAB
 */
static elfedit_atoui_sym_t sym_sht_dynsym[] = {
	{ MSG_ORIG(MSG_SHT_DYNSYM),		SHT_DYNSYM },
	{ MSG_ORIG(MSG_SHT_DYNSYM_ALT1),	SHT_DYNSYM },

	{ NULL }
};

/*
 * ELF section types for SHT_SUNW_LDYNSYM
 */
static elfedit_atoui_sym_t sym_sht_ldynsym[] = {
	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM),	SHT_SUNW_LDYNSYM },
	{ MSG_ORIG(MSG_SHT_SUNW_LDYNSYM_ALT1),	SHT_SUNW_LDYNSYM },

	{ NULL }
};

/*
 * ELF dynamic tag DT_ values
 */
static elfedit_atoui_sym_t sym_dt[] = {
	{ MSG_ORIG(MSG_DT_NULL),		DT_NULL },
	{ MSG_ORIG(MSG_DT_NULL_ALT1),		DT_NULL },

	{ MSG_ORIG(MSG_DT_NEEDED),		DT_NEEDED },
	{ MSG_ORIG(MSG_DT_NEEDED_ALT1),		DT_NEEDED },

	{ MSG_ORIG(MSG_DT_PLTRELSZ),		DT_PLTRELSZ },
	{ MSG_ORIG(MSG_DT_PLTRELSZ_ALT1),	DT_PLTRELSZ },

	{ MSG_ORIG(MSG_DT_PLTGOT),		DT_PLTGOT },
	{ MSG_ORIG(MSG_DT_PLTGOT_ALT1),		DT_PLTGOT },

	{ MSG_ORIG(MSG_DT_HASH),		DT_HASH },
	{ MSG_ORIG(MSG_DT_HASH_ALT1),		DT_HASH },

	{ MSG_ORIG(MSG_DT_STRTAB),		DT_STRTAB },
	{ MSG_ORIG(MSG_DT_STRTAB_ALT1),		DT_STRTAB },

	{ MSG_ORIG(MSG_DT_SYMTAB),		DT_SYMTAB },
	{ MSG_ORIG(MSG_DT_SYMTAB_ALT1),		DT_SYMTAB },

	{ MSG_ORIG(MSG_DT_RELA),		DT_RELA },
	{ MSG_ORIG(MSG_DT_RELA_ALT1),		DT_RELA },

	{ MSG_ORIG(MSG_DT_RELASZ),		DT_RELASZ },
	{ MSG_ORIG(MSG_DT_RELASZ_ALT1),		DT_RELASZ },

	{ MSG_ORIG(MSG_DT_RELAENT),		DT_RELAENT },
	{ MSG_ORIG(MSG_DT_RELAENT_ALT1),	DT_RELAENT },

	{ MSG_ORIG(MSG_DT_STRSZ),		DT_STRSZ },
	{ MSG_ORIG(MSG_DT_STRSZ_ALT1),		DT_STRSZ },

	{ MSG_ORIG(MSG_DT_SYMENT),		DT_SYMENT },
	{ MSG_ORIG(MSG_DT_SYMENT_ALT1),		DT_SYMENT },

	{ MSG_ORIG(MSG_DT_INIT),		DT_INIT },
	{ MSG_ORIG(MSG_DT_INIT_ALT1),		DT_INIT },

	{ MSG_ORIG(MSG_DT_FINI),		DT_FINI },
	{ MSG_ORIG(MSG_DT_FINI_ALT1),		DT_FINI },

	{ MSG_ORIG(MSG_DT_SONAME),		DT_SONAME },
	{ MSG_ORIG(MSG_DT_SONAME_ALT1),		DT_SONAME },

	{ MSG_ORIG(MSG_DT_RPATH),		DT_RPATH },
	{ MSG_ORIG(MSG_DT_RPATH_ALT1),		DT_RPATH },

	{ MSG_ORIG(MSG_DT_SYMBOLIC),		DT_SYMBOLIC },
	{ MSG_ORIG(MSG_DT_SYMBOLIC_ALT1),	DT_SYMBOLIC },

	{ MSG_ORIG(MSG_DT_REL),			DT_REL },
	{ MSG_ORIG(MSG_DT_REL_ALT1),		DT_REL },

	{ MSG_ORIG(MSG_DT_RELSZ),		DT_RELSZ },
	{ MSG_ORIG(MSG_DT_RELSZ_ALT1),		DT_RELSZ },

	{ MSG_ORIG(MSG_DT_RELENT),		DT_RELENT },
	{ MSG_ORIG(MSG_DT_RELENT_ALT1),		DT_RELENT },

	{ MSG_ORIG(MSG_DT_PLTREL),		DT_PLTREL },
	{ MSG_ORIG(MSG_DT_PLTREL_ALT1),		DT_PLTREL },

	{ MSG_ORIG(MSG_DT_DEBUG),		DT_DEBUG },
	{ MSG_ORIG(MSG_DT_DEBUG_ALT1),		DT_DEBUG },

	{ MSG_ORIG(MSG_DT_TEXTREL),		DT_TEXTREL },
	{ MSG_ORIG(MSG_DT_TEXTREL_ALT1),	DT_TEXTREL },

	{ MSG_ORIG(MSG_DT_JMPREL),		DT_JMPREL },
	{ MSG_ORIG(MSG_DT_JMPREL_ALT1),		DT_JMPREL },

	{ MSG_ORIG(MSG_DT_BIND_NOW),		DT_BIND_NOW },
	{ MSG_ORIG(MSG_DT_BIND_NOW_ALT1),	DT_BIND_NOW },

	{ MSG_ORIG(MSG_DT_INIT_ARRAY),		DT_INIT_ARRAY },
	{ MSG_ORIG(MSG_DT_INIT_ARRAY_ALT1),	DT_INIT_ARRAY },

	{ MSG_ORIG(MSG_DT_FINI_ARRAY),		DT_FINI_ARRAY },
	{ MSG_ORIG(MSG_DT_FINI_ARRAY_ALT1),	DT_FINI_ARRAY },

	{ MSG_ORIG(MSG_DT_INIT_ARRAYSZ),	DT_INIT_ARRAYSZ },
	{ MSG_ORIG(MSG_DT_INIT_ARRAYSZ_ALT1),	DT_INIT_ARRAYSZ },

	{ MSG_ORIG(MSG_DT_FINI_ARRAYSZ),	DT_FINI_ARRAYSZ },
	{ MSG_ORIG(MSG_DT_FINI_ARRAYSZ_ALT1),	DT_FINI_ARRAYSZ },

	{ MSG_ORIG(MSG_DT_RUNPATH),		DT_RUNPATH },
	{ MSG_ORIG(MSG_DT_RUNPATH_ALT1),	DT_RUNPATH },

	{ MSG_ORIG(MSG_DT_FLAGS),		DT_FLAGS },
	{ MSG_ORIG(MSG_DT_FLAGS_ALT1),		DT_FLAGS },

	{ MSG_ORIG(MSG_DT_PREINIT_ARRAY),	DT_PREINIT_ARRAY },
	{ MSG_ORIG(MSG_DT_PREINIT_ARRAY_ALT1),	DT_PREINIT_ARRAY },

	{ MSG_ORIG(MSG_DT_PREINIT_ARRAYSZ),	DT_PREINIT_ARRAYSZ },
	{ MSG_ORIG(MSG_DT_PREINIT_ARRAYSZ_ALT1), DT_PREINIT_ARRAYSZ },

	{ MSG_ORIG(MSG_DT_SUNW_AUXILIARY),	DT_SUNW_AUXILIARY },
	{ MSG_ORIG(MSG_DT_SUNW_AUXILIARY_ALT1),	DT_SUNW_AUXILIARY },

	{ MSG_ORIG(MSG_DT_SUNW_RTLDINF),	DT_SUNW_RTLDINF },
	{ MSG_ORIG(MSG_DT_SUNW_RTLDINF_ALT1),	DT_SUNW_RTLDINF },

	{ MSG_ORIG(MSG_DT_SUNW_FILTER),		DT_SUNW_FILTER },
	{ MSG_ORIG(MSG_DT_SUNW_FILTER_ALT1),	DT_SUNW_FILTER },

	{ MSG_ORIG(MSG_DT_SUNW_CAP),		DT_SUNW_CAP },
	{ MSG_ORIG(MSG_DT_SUNW_CAP_ALT1),	DT_SUNW_CAP },

	{ MSG_ORIG(MSG_DT_SUNW_SYMTAB),		DT_SUNW_SYMTAB },
	{ MSG_ORIG(MSG_DT_SUNW_SYMTAB_ALT1),	DT_SUNW_SYMTAB },

	{ MSG_ORIG(MSG_DT_SUNW_SYMSZ),		DT_SUNW_SYMSZ },
	{ MSG_ORIG(MSG_DT_SUNW_SYMSZ_ALT1),	DT_SUNW_SYMSZ },

	{ MSG_ORIG(MSG_DT_SUNW_SORTENT),	DT_SUNW_SORTENT },
	{ MSG_ORIG(MSG_DT_SUNW_SORTENT_ALT1),	DT_SUNW_SORTENT },

	{ MSG_ORIG(MSG_DT_SUNW_SYMSORT),	DT_SUNW_SYMSORT },
	{ MSG_ORIG(MSG_DT_SUNW_SYMSORT_ALT1),	DT_SUNW_SYMSORT },

	{ MSG_ORIG(MSG_DT_SUNW_SYMSORTSZ),	DT_SUNW_SYMSORTSZ },
	{ MSG_ORIG(MSG_DT_SUNW_SYMSORTSZ_ALT1),	DT_SUNW_SYMSORTSZ },

	{ MSG_ORIG(MSG_DT_SUNW_TLSSORT),	DT_SUNW_TLSSORT },
	{ MSG_ORIG(MSG_DT_SUNW_TLSSORT_ALT1),	DT_SUNW_TLSSORT },

	{ MSG_ORIG(MSG_DT_SUNW_TLSSORTSZ),	DT_SUNW_TLSSORTSZ },
	{ MSG_ORIG(MSG_DT_SUNW_TLSSORTSZ_ALT1),	DT_SUNW_TLSSORTSZ },

	{ MSG_ORIG(MSG_DT_SUNW_STRPAD),		DT_SUNW_STRPAD },
	{ MSG_ORIG(MSG_DT_SUNW_STRPAD_ALT1),	DT_SUNW_STRPAD },

	{ MSG_ORIG(MSG_DT_SUNW_LDMACH),		DT_SUNW_LDMACH },
	{ MSG_ORIG(MSG_DT_SUNW_LDMACH_ALT1),	DT_SUNW_LDMACH },

	{ MSG_ORIG(MSG_DT_SPARC_REGISTER),	DT_SPARC_REGISTER },
	{ MSG_ORIG(MSG_DT_SPARC_REGISTER_ALT1),	DT_SPARC_REGISTER },

	{ MSG_ORIG(MSG_DT_DEPRECATED_SPARC_REGISTER),
						DT_DEPRECATED_SPARC_REGISTER },
	{ MSG_ORIG(MSG_DT_DEPRECATED_SPARC_REGISTER_ALT1),
						DT_DEPRECATED_SPARC_REGISTER },

	{ MSG_ORIG(MSG_DT_CHECKSUM),		DT_CHECKSUM },
	{ MSG_ORIG(MSG_DT_CHECKSUM_ALT1),	DT_CHECKSUM },

	{ MSG_ORIG(MSG_DT_PLTPADSZ),		DT_PLTPADSZ },
	{ MSG_ORIG(MSG_DT_PLTPADSZ_ALT1),	DT_PLTPADSZ },

	{ MSG_ORIG(MSG_DT_MOVEENT),		DT_MOVEENT },
	{ MSG_ORIG(MSG_DT_MOVEENT_ALT1),	DT_MOVEENT },

	{ MSG_ORIG(MSG_DT_MOVESZ),		DT_MOVESZ },
	{ MSG_ORIG(MSG_DT_MOVESZ_ALT1),		DT_MOVESZ },

	{ MSG_ORIG(MSG_DT_FEATURE_1),		DT_FEATURE_1 },
	{ MSG_ORIG(MSG_DT_FEATURE_1_ALT1),	DT_FEATURE_1 },

	{ MSG_ORIG(MSG_DT_POSFLAG_1),		DT_POSFLAG_1 },
	{ MSG_ORIG(MSG_DT_POSFLAG_1_ALT1),	DT_POSFLAG_1 },

	{ MSG_ORIG(MSG_DT_SYMINSZ),		DT_SYMINSZ },
	{ MSG_ORIG(MSG_DT_SYMINSZ_ALT1),	DT_SYMINSZ },

	{ MSG_ORIG(MSG_DT_SYMINENT),		DT_SYMINENT },
	{ MSG_ORIG(MSG_DT_SYMINENT_ALT1),	DT_SYMINENT },

	{ MSG_ORIG(MSG_DT_CONFIG),		DT_CONFIG },
	{ MSG_ORIG(MSG_DT_CONFIG_ALT1),		DT_CONFIG },

	{ MSG_ORIG(MSG_DT_DEPAUDIT),		DT_DEPAUDIT },
	{ MSG_ORIG(MSG_DT_DEPAUDIT_ALT1),	DT_DEPAUDIT },

	{ MSG_ORIG(MSG_DT_AUDIT),		DT_AUDIT },
	{ MSG_ORIG(MSG_DT_AUDIT_ALT1),		DT_AUDIT },

	{ MSG_ORIG(MSG_DT_PLTPAD),		DT_PLTPAD },
	{ MSG_ORIG(MSG_DT_PLTPAD_ALT1),		DT_PLTPAD },

	{ MSG_ORIG(MSG_DT_MOVETAB),		DT_MOVETAB },
	{ MSG_ORIG(MSG_DT_MOVETAB_ALT1),	DT_MOVETAB },

	{ MSG_ORIG(MSG_DT_SYMINFO),		DT_SYMINFO },
	{ MSG_ORIG(MSG_DT_SYMINFO_ALT1),	DT_SYMINFO },

	{ MSG_ORIG(MSG_DT_VERSYM),		DT_VERSYM },
	{ MSG_ORIG(MSG_DT_VERSYM_ALT1),		DT_VERSYM },

	{ MSG_ORIG(MSG_DT_RELACOUNT),		DT_RELACOUNT },
	{ MSG_ORIG(MSG_DT_RELACOUNT_ALT1),	DT_RELACOUNT },

	{ MSG_ORIG(MSG_DT_RELCOUNT),		DT_RELCOUNT },
	{ MSG_ORIG(MSG_DT_RELCOUNT_ALT1),	DT_RELCOUNT },

	{ MSG_ORIG(MSG_DT_FLAGS_1),		DT_FLAGS_1 },
	{ MSG_ORIG(MSG_DT_FLAGS_1_ALT1),	DT_FLAGS_1 },

	{ MSG_ORIG(MSG_DT_VERDEF),		DT_VERDEF },
	{ MSG_ORIG(MSG_DT_VERDEF_ALT1),		DT_VERDEF },

	{ MSG_ORIG(MSG_DT_VERDEFNUM),		DT_VERDEFNUM },
	{ MSG_ORIG(MSG_DT_VERDEFNUM_ALT1),	DT_VERDEFNUM },

	{ MSG_ORIG(MSG_DT_VERNEED),		DT_VERNEED },
	{ MSG_ORIG(MSG_DT_VERNEED_ALT1),	DT_VERNEED },

	{ MSG_ORIG(MSG_DT_VERNEEDNUM),		DT_VERNEEDNUM },
	{ MSG_ORIG(MSG_DT_VERNEEDNUM_ALT1),	DT_VERNEEDNUM },

	{ MSG_ORIG(MSG_DT_AUXILIARY),		DT_AUXILIARY },
	{ MSG_ORIG(MSG_DT_AUXILIARY_ALT1),	DT_AUXILIARY },

	{ MSG_ORIG(MSG_DT_USED),		DT_USED },
	{ MSG_ORIG(MSG_DT_USED_ALT1),		DT_USED },

	{ MSG_ORIG(MSG_DT_FILTER),		DT_FILTER },
	{ MSG_ORIG(MSG_DT_FILTER_ALT1),		DT_FILTER },

	{ NULL }
};


/*
 * ELF DT_FLAGS DF_* values
 */
static elfedit_atoui_sym_t sym_df[] = {
	{ MSG_ORIG(MSG_DF_ORIGIN),		DF_ORIGIN },
	{ MSG_ORIG(MSG_DF_ORIGIN_ALT1),		DF_ORIGIN },

	{ MSG_ORIG(MSG_DF_SYMBOLIC),		DF_SYMBOLIC },
	{ MSG_ORIG(MSG_DF_SYMBOLIC_ALT1),	DF_SYMBOLIC },

	{ MSG_ORIG(MSG_DF_TEXTREL),		DF_TEXTREL },
	{ MSG_ORIG(MSG_DF_TEXTREL_ALT1),	DF_TEXTREL },

	{ MSG_ORIG(MSG_DF_BIND_NOW),		DF_BIND_NOW },
	{ MSG_ORIG(MSG_DF_BIND_NOW_ALT1),	DF_BIND_NOW },

	{ MSG_ORIG(MSG_DF_STATIC_TLS),		DF_STATIC_TLS },
	{ MSG_ORIG(MSG_DF_STATIC_TLS_ALT1),	DF_STATIC_TLS },

	{ NULL }
};


/*
 * ELF DT_POSFLAG_1 DF_P1_* values
 */
static elfedit_atoui_sym_t sym_df_p1[] = {
	{ MSG_ORIG(MSG_DF_P1_LAZYLOAD),		DF_P1_LAZYLOAD },
	{ MSG_ORIG(MSG_DF_P1_LAZYLOAD_ALT1),	DF_P1_LAZYLOAD },

	{ MSG_ORIG(MSG_DF_P1_GROUPPERM),	DF_P1_GROUPPERM },
	{ MSG_ORIG(MSG_DF_P1_GROUPPERM_ALT1),	DF_P1_GROUPPERM },

	{ NULL }
};


/*
 * ELF DT_FLAGS_1 DF_1_* values
 */
static elfedit_atoui_sym_t sym_df_1[] = {
	{ MSG_ORIG(MSG_DF_1_NOW),		DF_1_NOW },
	{ MSG_ORIG(MSG_DF_1_NOW_ALT1),		DF_1_NOW },

	{ MSG_ORIG(MSG_DF_1_GLOBAL),		DF_1_GLOBAL },
	{ MSG_ORIG(MSG_DF_1_GLOBAL_ALT1),	DF_1_GLOBAL },

	{ MSG_ORIG(MSG_DF_1_GROUP),		DF_1_GROUP },
	{ MSG_ORIG(MSG_DF_1_GROUP_ALT1),	DF_1_GROUP },

	{ MSG_ORIG(MSG_DF_1_NODELETE),		DF_1_NODELETE },
	{ MSG_ORIG(MSG_DF_1_NODELETE_ALT1),	DF_1_NODELETE },

	{ MSG_ORIG(MSG_DF_1_LOADFLTR),		DF_1_LOADFLTR },
	{ MSG_ORIG(MSG_DF_1_LOADFLTR_ALT1),	DF_1_LOADFLTR },

	{ MSG_ORIG(MSG_DF_1_INITFIRST),		DF_1_INITFIRST },
	{ MSG_ORIG(MSG_DF_1_INITFIRST_ALT1),	DF_1_INITFIRST },

	{ MSG_ORIG(MSG_DF_1_NOOPEN),		DF_1_NOOPEN },
	{ MSG_ORIG(MSG_DF_1_NOOPEN_ALT1),	DF_1_NOOPEN },

	{ MSG_ORIG(MSG_DF_1_ORIGIN),		DF_1_ORIGIN },
	{ MSG_ORIG(MSG_DF_1_ORIGIN_ALT1),	DF_1_ORIGIN },

	{ MSG_ORIG(MSG_DF_1_DIRECT),		DF_1_DIRECT },
	{ MSG_ORIG(MSG_DF_1_DIRECT_ALT1),	DF_1_DIRECT },

	{ MSG_ORIG(MSG_DF_1_TRANS),		DF_1_TRANS },
	{ MSG_ORIG(MSG_DF_1_TRANS_ALT1),	DF_1_TRANS },

	{ MSG_ORIG(MSG_DF_1_INTERPOSE),		DF_1_INTERPOSE },
	{ MSG_ORIG(MSG_DF_1_INTERPOSE_ALT1),	DF_1_INTERPOSE },

	{ MSG_ORIG(MSG_DF_1_NODEFLIB),		DF_1_NODEFLIB },
	{ MSG_ORIG(MSG_DF_1_NODEFLIB_ALT1),	DF_1_NODEFLIB },

	{ MSG_ORIG(MSG_DF_1_NODUMP),		DF_1_NODUMP },
	{ MSG_ORIG(MSG_DF_1_NODUMP_ALT1),	DF_1_NODUMP },

	{ MSG_ORIG(MSG_DF_1_CONFALT),		DF_1_CONFALT },
	{ MSG_ORIG(MSG_DF_1_CONFALT_ALT1),	DF_1_CONFALT },

	{ MSG_ORIG(MSG_DF_1_ENDFILTEE),		DF_1_ENDFILTEE },
	{ MSG_ORIG(MSG_DF_1_ENDFILTEE_ALT1),	DF_1_ENDFILTEE },

	{ MSG_ORIG(MSG_DF_1_DISPRELDNE),	DF_1_DISPRELDNE },
	{ MSG_ORIG(MSG_DF_1_DISPRELDNE_ALT1),	DF_1_DISPRELDNE },

	{ MSG_ORIG(MSG_DF_1_DISPRELPND),	DF_1_DISPRELPND },
	{ MSG_ORIG(MSG_DF_1_DISPRELPND_ALT1),	DF_1_DISPRELPND },

	{ MSG_ORIG(MSG_DF_1_NODIRECT),		DF_1_NODIRECT },
	{ MSG_ORIG(MSG_DF_1_NODIRECT_ALT1),	DF_1_NODIRECT },

	{ MSG_ORIG(MSG_DF_1_IGNMULDEF),		DF_1_IGNMULDEF },
	{ MSG_ORIG(MSG_DF_1_IGNMULDEF_ALT1),	DF_1_IGNMULDEF },

	{ MSG_ORIG(MSG_DF_1_NOKSYMS),		DF_1_NOKSYMS },
	{ MSG_ORIG(MSG_DF_1_NOKSYMS_ALT1),	DF_1_NOKSYMS },

	{ MSG_ORIG(MSG_DF_1_NOHDR),		DF_1_NOHDR },
	{ MSG_ORIG(MSG_DF_1_NOHDR_ALT1),	DF_1_NOHDR },

	{ MSG_ORIG(MSG_DF_1_EDITED),		DF_1_EDITED },
	{ MSG_ORIG(MSG_DF_1_EDITED_ALT1),	DF_1_EDITED },

	{ MSG_ORIG(MSG_DF_1_NORELOC),		DF_1_NORELOC },
	{ MSG_ORIG(MSG_DF_1_NORELOC_ALT1),	DF_1_NORELOC },

	{ MSG_ORIG(MSG_DF_1_SYMINTPOSE),	DF_1_SYMINTPOSE },
	{ MSG_ORIG(MSG_DF_1_SYMINTPOSE_ALT1),	DF_1_SYMINTPOSE },

	{ MSG_ORIG(MSG_DF_1_GLOBAUDIT),		DF_1_GLOBAUDIT },
	{ MSG_ORIG(MSG_DF_1_GLOBAUDIT_ALT1),	DF_1_GLOBAUDIT },

	{ NULL }
};


/*
 * ELF DT_FEATURE_1 DTF_1_* values
 */
static elfedit_atoui_sym_t sym_dtf_1[] = {
	{ MSG_ORIG(MSG_DTF_1_PARINIT),		DTF_1_PARINIT },
	{ MSG_ORIG(MSG_DTF_1_PARINIT_ALT1),	DTF_1_PARINIT },

	{ MSG_ORIG(MSG_DTF_1_CONFEXP),		DTF_1_CONFEXP },
	{ MSG_ORIG(MSG_DTF_1_CONFEXP_ALT1),	DTF_1_CONFEXP },

	{ NULL }
};

/*
 * ELF header EI_* indexes
 */
static elfedit_atoui_sym_t sym_ei[] = {
	{ MSG_ORIG(MSG_EI_MAG0),		EI_MAG0 },
	{ MSG_ORIG(MSG_EI_MAG0_ALT1),		EI_MAG0 },

	{ MSG_ORIG(MSG_EI_MAG1),		EI_MAG1 },
	{ MSG_ORIG(MSG_EI_MAG1_ALT1),		EI_MAG1 },

	{ MSG_ORIG(MSG_EI_MAG2),		EI_MAG2 },
	{ MSG_ORIG(MSG_EI_MAG2_ALT1),		EI_MAG2 },

	{ MSG_ORIG(MSG_EI_MAG3),		EI_MAG3 },
	{ MSG_ORIG(MSG_EI_MAG3_ALT1),		EI_MAG3 },

	{ MSG_ORIG(MSG_EI_CLASS),		EI_CLASS },
	{ MSG_ORIG(MSG_EI_CLASS_ALT1),		EI_CLASS },

	{ MSG_ORIG(MSG_EI_DATA),		EI_DATA },
	{ MSG_ORIG(MSG_EI_DATA_ALT1),		EI_DATA },

	{ MSG_ORIG(MSG_EI_VERSION),		EI_VERSION },
	{ MSG_ORIG(MSG_EI_VERSION_ALT1),	EI_VERSION },

	{ MSG_ORIG(MSG_EI_OSABI),		EI_OSABI },
	{ MSG_ORIG(MSG_EI_OSABI_ALT1),		EI_OSABI },

	{ MSG_ORIG(MSG_EI_ABIVERSION),		EI_ABIVERSION },
	{ MSG_ORIG(MSG_EI_ABIVERSION_ALT1),	EI_ABIVERSION },

	{ NULL }
};

/*
 * ELF header ET_* file type values
 */
static elfedit_atoui_sym_t sym_et[] = {
	{ MSG_ORIG(MSG_ET_NONE),		ET_NONE },
	{ MSG_ORIG(MSG_ET_NONE_ALT1),		ET_NONE },

	{ MSG_ORIG(MSG_ET_REL),			ET_REL },
	{ MSG_ORIG(MSG_ET_REL_ALT1),		ET_REL },

	{ MSG_ORIG(MSG_ET_EXEC),		ET_EXEC },
	{ MSG_ORIG(MSG_ET_EXEC_ALT1),		ET_EXEC },

	{ MSG_ORIG(MSG_ET_DYN),			ET_DYN },
	{ MSG_ORIG(MSG_ET_DYN_ALT1),		ET_DYN },

	{ MSG_ORIG(MSG_ET_CORE),		ET_CORE },
	{ MSG_ORIG(MSG_ET_CORE_ALT1),		ET_CORE },

	{ NULL }
};

/*
 * ELFCLASS
 */
static elfedit_atoui_sym_t sym_elfclass[] = {
	{ MSG_ORIG(MSG_ELFCLASSNONE),		ELFCLASSNONE },
	{ MSG_ORIG(MSG_ELFCLASSNONE_ALT1),	ELFCLASSNONE },

	{ MSG_ORIG(MSG_ELFCLASS32),		ELFCLASS32 },
	{ MSG_ORIG(MSG_ELFCLASS32_ALT1),	ELFCLASS32 },

	{ MSG_ORIG(MSG_ELFCLASS64),		ELFCLASS64 },
	{ MSG_ORIG(MSG_ELFCLASS64_ALT1),	ELFCLASS64 },

	{ NULL }
};

/*
 * ELFDATA
 */
static elfedit_atoui_sym_t sym_elfdata[] = {
	{ MSG_ORIG(MSG_ELFDATANONE),		ELFDATANONE },
	{ MSG_ORIG(MSG_ELFDATANONE_ALT1),	ELFDATANONE },

	{ MSG_ORIG(MSG_ELFDATA2LSB),		ELFDATA2LSB },
	{ MSG_ORIG(MSG_ELFDATA2LSB_ALT1),	ELFDATA2LSB },

	{ MSG_ORIG(MSG_ELFDATA2MSB),		ELFDATA2MSB },
	{ MSG_ORIG(MSG_ELFDATA2MSB_ALT1),	ELFDATA2MSB },

	{ NULL }
};

/*
 * ELF header EF_* flags
 */
static elfedit_atoui_sym_t sym_ef[] = {
	{ MSG_ORIG(MSG_EF_SPARC_32PLUS),	EF_SPARC_32PLUS },
	{ MSG_ORIG(MSG_EF_SPARC_32PLUS_ALT1),	EF_SPARC_32PLUS },

	{ MSG_ORIG(MSG_EF_SPARC_SUN_US1),	EF_SPARC_SUN_US1 },
	{ MSG_ORIG(MSG_EF_SPARC_SUN_US1_ALT1),	EF_SPARC_SUN_US1 },

	{ MSG_ORIG(MSG_EF_SPARC_HAL_R1),	EF_SPARC_HAL_R1 },
	{ MSG_ORIG(MSG_EF_SPARC_HAL_R1_ALT1),	EF_SPARC_HAL_R1 },

	{ MSG_ORIG(MSG_EF_SPARC_SUN_US3),	EF_SPARC_SUN_US3 },
	{ MSG_ORIG(MSG_EF_SPARC_SUN_US3_ALT1),	EF_SPARC_SUN_US3 },

	{ MSG_ORIG(MSG_EF_SPARCV9_MM),		EF_SPARCV9_MM },
	{ MSG_ORIG(MSG_EF_SPARCV9_MM_ALT1),	EF_SPARCV9_MM },

	{ MSG_ORIG(MSG_EF_SPARCV9_TSO),		EF_SPARCV9_TSO },
	{ MSG_ORIG(MSG_EF_SPARCV9_TSO_ALT1),	EF_SPARCV9_TSO },

	{ MSG_ORIG(MSG_EF_SPARCV9_PSO),		EF_SPARCV9_PSO },
	{ MSG_ORIG(MSG_EF_SPARCV9_PSO_ALT1),	EF_SPARCV9_PSO },

	{ MSG_ORIG(MSG_EF_SPARCV9_RMO),		EF_SPARCV9_RMO },
	{ MSG_ORIG(MSG_EF_SPARCV9_RMO_ALT1),	EF_SPARCV9_RMO },

	{ NULL }
};

/*
 * ELF header EV_* versions
 */
static elfedit_atoui_sym_t sym_ev[] = {
	{ MSG_ORIG(MSG_EV_NONE),		EV_NONE },
	{ MSG_ORIG(MSG_EV_NONE_ALT1),		EV_NONE },

	{ MSG_ORIG(MSG_EV_CURRENT),		EV_CURRENT },
	{ MSG_ORIG(MSG_EV_CURRENT_ALT1),	EV_CURRENT },

	{ NULL }
};

/*
 * ELF EM_* machine types
 */
static elfedit_atoui_sym_t sym_em[] = {
	{ MSG_ORIG(MSG_EM_NONE),		EM_NONE },
	{ MSG_ORIG(MSG_EM_NONE_ALT1),		EM_NONE },

	{ MSG_ORIG(MSG_EM_M32),			EM_M32 },
	{ MSG_ORIG(MSG_EM_M32_ALT1),		EM_M32 },
	{ MSG_ORIG(MSG_EM_M32_ALT2),		EM_M32 },

	{ MSG_ORIG(MSG_EM_SPARC),		EM_SPARC },
	{ MSG_ORIG(MSG_EM_SPARC_ALT1),		EM_SPARC },

	{ MSG_ORIG(MSG_EM_386),			EM_386 },
	{ MSG_ORIG(MSG_EM_386_ALT1),		EM_386 },
	{ MSG_ORIG(MSG_EM_386_ALT2),		EM_386 },

	{ MSG_ORIG(MSG_EM_68K),			EM_68K },
	{ MSG_ORIG(MSG_EM_68K_ALT1),		EM_68K },
	{ MSG_ORIG(MSG_EM_68K_ALT2),		EM_68K },

	{ MSG_ORIG(MSG_EM_88K),			EM_88K },
	{ MSG_ORIG(MSG_EM_88K_ALT1),		EM_88K },
	{ MSG_ORIG(MSG_EM_88K_ALT2),		EM_88K },

	{ MSG_ORIG(MSG_EM_486),			EM_486 },
	{ MSG_ORIG(MSG_EM_486_ALT1),		EM_486 },
	{ MSG_ORIG(MSG_EM_486_ALT2),		EM_486 },

	{ MSG_ORIG(MSG_EM_860),			EM_860 },
	{ MSG_ORIG(MSG_EM_860_ALT1),		EM_860 },
	{ MSG_ORIG(MSG_EM_860_ALT2),		EM_860 },

	{ MSG_ORIG(MSG_EM_MIPS),		EM_MIPS },
	{ MSG_ORIG(MSG_EM_MIPS_ALT1),		EM_MIPS },
	{ MSG_ORIG(MSG_EM_MIPS_ALT2),		EM_MIPS },

	{ MSG_ORIG(MSG_EM_S370),		EM_S370 },
	{ MSG_ORIG(MSG_EM_S370_ALT1),		EM_S370 },

	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE),		EM_MIPS_RS3_LE },
	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE_ALT1),	EM_MIPS_RS3_LE },
	{ MSG_ORIG(MSG_EM_MIPS_RS3_LE_ALT2),	EM_MIPS_RS3_LE },

	{ MSG_ORIG(MSG_EM_RS6000),		EM_RS6000 },
	{ MSG_ORIG(MSG_EM_RS6000_ALT1),		EM_RS6000 },

	{ MSG_ORIG(MSG_EM_PA_RISC),		EM_PA_RISC },
	{ MSG_ORIG(MSG_EM_PA_RISC_ALT1),	EM_PA_RISC },

	{ MSG_ORIG(MSG_EM_NCUBE),		EM_nCUBE },
	{ MSG_ORIG(MSG_EM_NCUBE_ALT1),		EM_nCUBE },

	{ MSG_ORIG(MSG_EM_VPP500),		EM_VPP500 },
	{ MSG_ORIG(MSG_EM_VPP500_ALT1),		EM_VPP500 },

	{ MSG_ORIG(MSG_EM_SPARC32PLUS),		EM_SPARC32PLUS },
	{ MSG_ORIG(MSG_EM_SPARC32PLUS_ALT1),	EM_SPARC32PLUS },

	{ MSG_ORIG(MSG_EM_960),			EM_960 },
	{ MSG_ORIG(MSG_EM_960_ALT1),		EM_960 },

	{ MSG_ORIG(MSG_EM_PPC),			EM_PPC },
	{ MSG_ORIG(MSG_EM_PPC_ALT1),		EM_PPC },
	{ MSG_ORIG(MSG_EM_PPC_ALT2),		EM_PPC },

	{ MSG_ORIG(MSG_EM_PPC64),		EM_PPC64 },
	{ MSG_ORIG(MSG_EM_PPC64_ALT1),		EM_PPC64 },
	{ MSG_ORIG(MSG_EM_PPC64_ALT2),		EM_PPC64 },

	{ MSG_ORIG(MSG_EM_S390),		EM_S390 },
	{ MSG_ORIG(MSG_EM_S390_ALT1),		EM_S390 },

	{ MSG_ORIG(MSG_EM_V800),		EM_V800 },
	{ MSG_ORIG(MSG_EM_V800_ALT1),		EM_V800 },

	{ MSG_ORIG(MSG_EM_FR20),		EM_FR20 },
	{ MSG_ORIG(MSG_EM_FR20_ALT1),		EM_FR20 },

	{ MSG_ORIG(MSG_EM_RH32),		EM_RH32 },
	{ MSG_ORIG(MSG_EM_RH32_ALT1),		EM_RH32 },

	{ MSG_ORIG(MSG_EM_RCE),			EM_RCE },
	{ MSG_ORIG(MSG_EM_RCE_ALT1),		EM_RCE },

	{ MSG_ORIG(MSG_EM_ARM),			EM_ARM },
	{ MSG_ORIG(MSG_EM_ARM_ALT1),		EM_ARM },

	{ MSG_ORIG(MSG_EM_ALPHA),		EM_ALPHA },
	{ MSG_ORIG(MSG_EM_ALPHA_ALT1),		EM_ALPHA },

	{ MSG_ORIG(MSG_EM_SH),			EM_SH },
	{ MSG_ORIG(MSG_EM_SH_ALT1),		EM_SH },

	{ MSG_ORIG(MSG_EM_SPARCV9),		EM_SPARCV9 },
	{ MSG_ORIG(MSG_EM_SPARCV9_ALT1),	EM_SPARCV9 },

	{ MSG_ORIG(MSG_EM_TRICORE),		EM_TRICORE },
	{ MSG_ORIG(MSG_EM_TRICORE_ALT1),	EM_TRICORE },

	{ MSG_ORIG(MSG_EM_ARC),			EM_ARC },
	{ MSG_ORIG(MSG_EM_ARC_ALT1),		EM_ARC },

	{ MSG_ORIG(MSG_EM_H8_300),		EM_H8_300 },
	{ MSG_ORIG(MSG_EM_H8_300_ALT1),		EM_H8_300 },

	{ MSG_ORIG(MSG_EM_H8_300H),		EM_H8_300H },
	{ MSG_ORIG(MSG_EM_H8_300H_ALT1),	EM_H8_300H },

	{ MSG_ORIG(MSG_EM_H8S),			EM_H8S },
	{ MSG_ORIG(MSG_EM_H8S_ALT1),		EM_H8S },

	{ MSG_ORIG(MSG_EM_H8_500),		EM_H8_500 },
	{ MSG_ORIG(MSG_EM_H8_500_ALT1),		EM_H8_500 },

	{ MSG_ORIG(MSG_EM_IA_64),		EM_IA_64 },
	{ MSG_ORIG(MSG_EM_IA_64_ALT1),		EM_IA_64 },

	{ MSG_ORIG(MSG_EM_MIPS_X),		EM_MIPS_X },
	{ MSG_ORIG(MSG_EM_MIPS_X_ALT1),		EM_MIPS_X },

	{ MSG_ORIG(MSG_EM_COLDFIRE),		EM_COLDFIRE },
	{ MSG_ORIG(MSG_EM_COLDFIRE_ALT1),	EM_COLDFIRE },

	{ MSG_ORIG(MSG_EM_68HC12),		EM_68HC12 },
	{ MSG_ORIG(MSG_EM_68HC12_ALT1),		EM_68HC12 },

	{ MSG_ORIG(MSG_EM_MMA),			EM_MMA },
	{ MSG_ORIG(MSG_EM_MMA_ALT1),		EM_MMA },

	{ MSG_ORIG(MSG_EM_PCP),			EM_PCP },
	{ MSG_ORIG(MSG_EM_PCP_ALT1),		EM_PCP },

	{ MSG_ORIG(MSG_EM_NCPU),		EM_NCPU },
	{ MSG_ORIG(MSG_EM_NCPU_ALT1),		EM_NCPU },

	{ MSG_ORIG(MSG_EM_NDR1),		EM_NDR1 },
	{ MSG_ORIG(MSG_EM_NDR1_ALT1),		EM_NDR1 },

	{ MSG_ORIG(MSG_EM_STARCORE),		EM_STARCORE },
	{ MSG_ORIG(MSG_EM_STARCORE_ALT1),	EM_STARCORE },

	{ MSG_ORIG(MSG_EM_ME16),		EM_ME16 },
	{ MSG_ORIG(MSG_EM_ME16_ALT1),		EM_ME16 },

	{ MSG_ORIG(MSG_EM_ST100),		EM_ST100 },
	{ MSG_ORIG(MSG_EM_ST100_ALT1),		EM_ST100 },

	{ MSG_ORIG(MSG_EM_TINYJ),		EM_TINYJ },
	{ MSG_ORIG(MSG_EM_TINYJ_ALT1),		EM_TINYJ },

	{ MSG_ORIG(MSG_EM_AMD64),		EM_AMD64 },
	{ MSG_ORIG(MSG_EM_AMD64_ALT1),		EM_AMD64 },

	{ MSG_ORIG(MSG_EM_PDSP),		EM_PDSP },
	{ MSG_ORIG(MSG_EM_PDSP_ALT1),		EM_PDSP },

	{ MSG_ORIG(MSG_EM_FX66),		EM_FX66 },
	{ MSG_ORIG(MSG_EM_FX66_ALT1),		EM_FX66 },

	{ MSG_ORIG(MSG_EM_ST9PLUS),		EM_ST9PLUS },
	{ MSG_ORIG(MSG_EM_ST9PLUS_ALT1),	EM_ST9PLUS },

	{ MSG_ORIG(MSG_EM_ST7),			EM_ST7 },
	{ MSG_ORIG(MSG_EM_ST7_ALT1),		EM_ST7 },

	{ MSG_ORIG(MSG_EM_68HC16),		EM_68HC16 },
	{ MSG_ORIG(MSG_EM_68HC16_ALT1),		EM_68HC16 },

	{ MSG_ORIG(MSG_EM_68HC11),		EM_68HC11 },
	{ MSG_ORIG(MSG_EM_68HC11_ALT1),		EM_68HC11 },

	{ MSG_ORIG(MSG_EM_68HC08),		EM_68HC08 },
	{ MSG_ORIG(MSG_EM_68HC08_ALT1),		EM_68HC08 },

	{ MSG_ORIG(MSG_EM_68HC05),		EM_68HC05 },
	{ MSG_ORIG(MSG_EM_68HC05_ALT1),		EM_68HC05 },

	{ MSG_ORIG(MSG_EM_SVX),			EM_SVX },
	{ MSG_ORIG(MSG_EM_SVX_ALT1),		EM_SVX },

	{ MSG_ORIG(MSG_EM_ST19),		EM_ST19 },
	{ MSG_ORIG(MSG_EM_ST19_ALT1),		EM_ST19 },

	{ MSG_ORIG(MSG_EM_VAX),			EM_VAX },
	{ MSG_ORIG(MSG_EM_VAX_ALT1),		EM_VAX },

	{ MSG_ORIG(MSG_EM_CRIS),		EM_CRIS },
	{ MSG_ORIG(MSG_EM_CRIS_ALT1),		EM_CRIS },

	{ MSG_ORIG(MSG_EM_JAVELIN),		EM_JAVELIN },
	{ MSG_ORIG(MSG_EM_JAVELIN_ALT1),	EM_JAVELIN },

	{ MSG_ORIG(MSG_EM_FIREPATH),		EM_FIREPATH },
	{ MSG_ORIG(MSG_EM_FIREPATH_ALT1),	EM_FIREPATH },

	{ MSG_ORIG(MSG_EM_ZSP),			EM_ZSP },
	{ MSG_ORIG(MSG_EM_ZSP_ALT1),		EM_ZSP },

	{ MSG_ORIG(MSG_EM_MMIX),		EM_MMIX },
	{ MSG_ORIG(MSG_EM_MMIX_ALT1),		EM_MMIX },

	{ MSG_ORIG(MSG_EM_HUANY),		EM_HUANY },
	{ MSG_ORIG(MSG_EM_HUANY_ALT1),		EM_HUANY },

	{ MSG_ORIG(MSG_EM_PRISM),		EM_PRISM },
	{ MSG_ORIG(MSG_EM_PRISM_ALT1),		EM_PRISM },

	{ MSG_ORIG(MSG_EM_AVR),			EM_AVR },
	{ MSG_ORIG(MSG_EM_AVR_ALT1),		EM_AVR },

	{ MSG_ORIG(MSG_EM_FR30),		EM_FR30 },
	{ MSG_ORIG(MSG_EM_FR30_ALT1),		EM_FR30 },

	{ MSG_ORIG(MSG_EM_D10V),		EM_D10V },
	{ MSG_ORIG(MSG_EM_D10V_ALT1),		EM_D10V },

	{ MSG_ORIG(MSG_EM_D30V),		EM_D30V },
	{ MSG_ORIG(MSG_EM_D30V_ALT1),		EM_D30V },

	{ MSG_ORIG(MSG_EM_V850),		EM_V850 },
	{ MSG_ORIG(MSG_EM_V850_ALT1),		EM_V850 },

	{ MSG_ORIG(MSG_EM_M32R),		EM_M32R },
	{ MSG_ORIG(MSG_EM_M32R_ALT1),		EM_M32R },

	{ MSG_ORIG(MSG_EM_MN10300),		EM_MN10300 },
	{ MSG_ORIG(MSG_EM_MN10300_ALT1),	EM_MN10300 },

	{ MSG_ORIG(MSG_EM_MN10200),		EM_MN10200 },
	{ MSG_ORIG(MSG_EM_MN10200_ALT1),	EM_MN10200 },

	{ MSG_ORIG(MSG_EM_PJ),			EM_PJ },
	{ MSG_ORIG(MSG_EM_PJ_ALT1),		EM_PJ },

	{ MSG_ORIG(MSG_EM_OPENRISC),		EM_OPENRISC },
	{ MSG_ORIG(MSG_EM_OPENRISC_ALT1),	EM_OPENRISC },

	{ MSG_ORIG(MSG_EM_ARC_A5),		EM_ARC_A5 },
	{ MSG_ORIG(MSG_EM_ARC_A5_ALT1),		EM_ARC_A5 },

	{ MSG_ORIG(MSG_EM_XTENSA),		EM_XTENSA },
	{ MSG_ORIG(MSG_EM_XTENSA_ALT1),		EM_XTENSA },

	{ NULL }
};
#if	(EM_NUM != (EM_XTENSA + 1))
#error	"EM_NUM has grown"
#endif


/*
 * ELF header ELFOSABI_* values (and common aliases)
 */
static elfedit_atoui_sym_t sym_elfosabi[] = {
	{ MSG_ORIG(MSG_ELFOSABI_NONE),		ELFOSABI_NONE },
	{ MSG_ORIG(MSG_ELFOSABI_NONE_ALT1),	ELFOSABI_NONE },

	{ MSG_ORIG(MSG_ELFOSABI_SYSV),		ELFOSABI_SYSV },
	{ MSG_ORIG(MSG_ELFOSABI_SYSV_ALT1),	ELFOSABI_SYSV },

	{ MSG_ORIG(MSG_ELFOSABI_HPUX),		ELFOSABI_HPUX },
	{ MSG_ORIG(MSG_ELFOSABI_HPUX_ALT1),	ELFOSABI_HPUX },

	{ MSG_ORIG(MSG_ELFOSABI_NETBSD),	ELFOSABI_NETBSD },
	{ MSG_ORIG(MSG_ELFOSABI_NETBSD_ALT1),	ELFOSABI_NETBSD },

	{ MSG_ORIG(MSG_ELFOSABI_LINUX),		ELFOSABI_LINUX },
	{ MSG_ORIG(MSG_ELFOSABI_LINUX_ALT1),	ELFOSABI_LINUX },

	{ MSG_ORIG(MSG_ELFOSABI_SOLARIS),	ELFOSABI_SOLARIS },
	{ MSG_ORIG(MSG_ELFOSABI_SOLARIS_ALT1),	ELFOSABI_SOLARIS },

	{ MSG_ORIG(MSG_ELFOSABI_AIX),		ELFOSABI_AIX },
	{ MSG_ORIG(MSG_ELFOSABI_AIX_ALT1),	ELFOSABI_AIX },

	{ MSG_ORIG(MSG_ELFOSABI_IRIX),		ELFOSABI_IRIX },
	{ MSG_ORIG(MSG_ELFOSABI_IRIX_ALT1),	ELFOSABI_IRIX },

	{ MSG_ORIG(MSG_ELFOSABI_FREEBSD),	ELFOSABI_FREEBSD },
	{ MSG_ORIG(MSG_ELFOSABI_FREEBSD_ALT1),	ELFOSABI_FREEBSD },

	{ MSG_ORIG(MSG_ELFOSABI_TRU64),		ELFOSABI_TRU64 },
	{ MSG_ORIG(MSG_ELFOSABI_TRU64_ALT1),	ELFOSABI_TRU64 },

	{ MSG_ORIG(MSG_ELFOSABI_MODESTO),	ELFOSABI_MODESTO },
	{ MSG_ORIG(MSG_ELFOSABI_MODESTO_ALT1),	ELFOSABI_MODESTO },

	{ MSG_ORIG(MSG_ELFOSABI_OPENBSD),	ELFOSABI_OPENBSD },
	{ MSG_ORIG(MSG_ELFOSABI_OPENBSD_ALT1),	ELFOSABI_OPENBSD },

	{ MSG_ORIG(MSG_ELFOSABI_OPENVMS),	ELFOSABI_OPENVMS },
	{ MSG_ORIG(MSG_ELFOSABI_OPENVMS_ALT1),	ELFOSABI_OPENVMS },

	{ MSG_ORIG(MSG_ELFOSABI_NSK),		ELFOSABI_NSK },
	{ MSG_ORIG(MSG_ELFOSABI_NSK_ALT1),	ELFOSABI_NSK },

	{ MSG_ORIG(MSG_ELFOSABI_AROS),		ELFOSABI_AROS },
	{ MSG_ORIG(MSG_ELFOSABI_AROS_ALT1),	ELFOSABI_AROS },

	{ MSG_ORIG(MSG_ELFOSABI_ARM),		ELFOSABI_ARM },
	{ MSG_ORIG(MSG_ELFOSABI_ARM_ALT1),	ELFOSABI_ARM },

	{ MSG_ORIG(MSG_ELFOSABI_STANDALONE),	ELFOSABI_STANDALONE },
	{ MSG_ORIG(MSG_ELFOSABI_STANDALONE_ALT1), ELFOSABI_STANDALONE },

	{ NULL }
};


/*
 * Program header PT_* type values
 */
static elfedit_atoui_sym_t sym_pt[] = {
	{ MSG_ORIG(MSG_PT_NULL),		PT_NULL },
	{ MSG_ORIG(MSG_PT_NULL_ALT1),		PT_NULL },

	{ MSG_ORIG(MSG_PT_LOAD),		PT_LOAD },
	{ MSG_ORIG(MSG_PT_LOAD_ALT1),		PT_LOAD },

	{ MSG_ORIG(MSG_PT_DYNAMIC),		PT_DYNAMIC },
	{ MSG_ORIG(MSG_PT_DYNAMIC_ALT1),	PT_DYNAMIC },

	{ MSG_ORIG(MSG_PT_INTERP),		PT_INTERP },
	{ MSG_ORIG(MSG_PT_INTERP_ALT1),		PT_INTERP },

	{ MSG_ORIG(MSG_PT_NOTE),		PT_NOTE },
	{ MSG_ORIG(MSG_PT_NOTE_ALT1),		PT_NOTE },

	{ MSG_ORIG(MSG_PT_SHLIB),		PT_SHLIB },
	{ MSG_ORIG(MSG_PT_SHLIB_ALT1),		PT_SHLIB },

	{ MSG_ORIG(MSG_PT_PHDR),		PT_PHDR },
	{ MSG_ORIG(MSG_PT_PHDR_ALT1),		PT_PHDR },

	{ MSG_ORIG(MSG_PT_TLS),			PT_TLS },
	{ MSG_ORIG(MSG_PT_TLS_ALT1),		PT_TLS },

	{ MSG_ORIG(MSG_PT_SUNW_UNWIND),		PT_SUNW_UNWIND },
	{ MSG_ORIG(MSG_PT_SUNW_UNWIND_ALT1),	PT_SUNW_UNWIND },

	{ MSG_ORIG(MSG_PT_SUNWBSS),		PT_SUNWBSS },
	{ MSG_ORIG(MSG_PT_SUNWBSS_ALT1),	PT_SUNWBSS },

	{ MSG_ORIG(MSG_PT_SUNWSTACK),		PT_SUNWSTACK },
	{ MSG_ORIG(MSG_PT_SUNWSTACK_ALT1),	PT_SUNWSTACK },

	{ MSG_ORIG(MSG_PT_SUNWDTRACE),		PT_SUNWDTRACE },
	{ MSG_ORIG(MSG_PT_SUNWDTRACE_ALT1),	PT_SUNWDTRACE },

	{ MSG_ORIG(MSG_PT_SUNWCAP),		PT_SUNWCAP },
	{ MSG_ORIG(MSG_PT_SUNWCAP_ALT1),	PT_SUNWCAP },

	{ NULL }
};


/*
 * Program header PF_* flag values
 */
static elfedit_atoui_sym_t sym_pf[] = {
	{ MSG_ORIG(MSG_PF_X),			PF_X },
	{ MSG_ORIG(MSG_PF_X_ALT1),		PF_X },

	{ MSG_ORIG(MSG_PF_W),			PF_W },
	{ MSG_ORIG(MSG_PF_W_ALT1),		PF_W },

	{ MSG_ORIG(MSG_PF_R),			PF_R },
	{ MSG_ORIG(MSG_PF_R_ALT1),		PF_R },

	{ NULL }
};


/*
 * Section header SHF_* flag values
 */
static elfedit_atoui_sym_t sym_shf[] = {
	{ MSG_ORIG(MSG_SHF_WRITE),		SHF_WRITE },
	{ MSG_ORIG(MSG_SHF_WRITE_ALT1),		SHF_WRITE },

	{ MSG_ORIG(MSG_SHF_ALLOC),		SHF_ALLOC },
	{ MSG_ORIG(MSG_SHF_ALLOC_ALT1),		SHF_ALLOC },

	{ MSG_ORIG(MSG_SHF_EXECINSTR),		SHF_EXECINSTR },
	{ MSG_ORIG(MSG_SHF_EXECINSTR_ALT1),	SHF_EXECINSTR },

	{ MSG_ORIG(MSG_SHF_MERGE),		SHF_MERGE },
	{ MSG_ORIG(MSG_SHF_MERGE_ALT1),		SHF_MERGE },

	{ MSG_ORIG(MSG_SHF_STRINGS),		SHF_STRINGS },
	{ MSG_ORIG(MSG_SHF_STRINGS_ALT1),	SHF_STRINGS },

	{ MSG_ORIG(MSG_SHF_INFO_LINK),		SHF_INFO_LINK },
	{ MSG_ORIG(MSG_SHF_INFO_LINK_ALT1),	SHF_INFO_LINK },

	{ MSG_ORIG(MSG_SHF_LINK_ORDER),		SHF_LINK_ORDER },
	{ MSG_ORIG(MSG_SHF_LINK_ORDER_ALT1),	SHF_LINK_ORDER },

	{ MSG_ORIG(MSG_SHF_OS_NONCONFORMING),	SHF_OS_NONCONFORMING },
	{ MSG_ORIG(MSG_SHF_OS_NONCONFORMING_ALT1), SHF_OS_NONCONFORMING },

	{ MSG_ORIG(MSG_SHF_GROUP),		SHF_GROUP },
	{ MSG_ORIG(MSG_SHF_GROUP_ALT1),		SHF_GROUP },

	{ MSG_ORIG(MSG_SHF_TLS),		SHF_TLS },
	{ MSG_ORIG(MSG_SHF_TLS_ALT1),		SHF_TLS },

	{ MSG_ORIG(MSG_SHF_AMD64_LARGE),	SHF_AMD64_LARGE },
	{ MSG_ORIG(MSG_SHF_AMD64_LARGE_ALT1),	SHF_AMD64_LARGE },

	{ MSG_ORIG(MSG_SHF_ORDERED),		SHF_ORDERED },
	{ MSG_ORIG(MSG_SHF_ORDERED_ALT1),	SHF_ORDERED },

	{ MSG_ORIG(MSG_SHF_EXCLUDE),		SHF_EXCLUDE },
	{ MSG_ORIG(MSG_SHF_EXCLUDE_ALT1),	SHF_EXCLUDE },

	{ NULL }
};

/*
 * ELF symbol bindings (st_info ELF_ST_BIND)
 */
static elfedit_atoui_sym_t sym_stb[] = {
	{ MSG_ORIG(MSG_STB_LOCAL),		STB_LOCAL },
	{ MSG_ORIG(MSG_STB_LOCAL_ALT1),		STB_LOCAL },

	{ MSG_ORIG(MSG_STB_GLOBAL),		STB_GLOBAL },
	{ MSG_ORIG(MSG_STB_GLOBAL_ALT1),	STB_GLOBAL },

	{ MSG_ORIG(MSG_STB_WEAK),		STB_WEAK },
	{ MSG_ORIG(MSG_STB_WEAK_ALT1),		STB_WEAK },

	{ NULL }
};

/*
 * ELF symbol types (st_info ELF_ST_TYPE)
 */
static elfedit_atoui_sym_t sym_stt[] = {
	{ MSG_ORIG(MSG_STT_NOTYPE),		STT_NOTYPE },
	{ MSG_ORIG(MSG_STT_NOTYPE_ALT1),	STT_NOTYPE },

	{ MSG_ORIG(MSG_STT_OBJECT),		STT_OBJECT },
	{ MSG_ORIG(MSG_STT_OBJECT_ALT1),	STT_OBJECT },

	{ MSG_ORIG(MSG_STT_FUNC),		STT_FUNC },
	{ MSG_ORIG(MSG_STT_FUNC_ALT1),		STT_FUNC },

	{ MSG_ORIG(MSG_STT_SECTION),		STT_SECTION },
	{ MSG_ORIG(MSG_STT_SECTION_ALT1),	STT_SECTION },

	{ MSG_ORIG(MSG_STT_FILE),		STT_FILE },
	{ MSG_ORIG(MSG_STT_FILE_ALT1),		STT_FILE },

	{ MSG_ORIG(MSG_STT_COMMON),		STT_COMMON },
	{ MSG_ORIG(MSG_STT_COMMON_ALT1),	STT_COMMON },

	{ MSG_ORIG(MSG_STT_TLS),		STT_TLS },
	{ MSG_ORIG(MSG_STT_TLS_ALT1),		STT_TLS },

	{ NULL }
};

/*
 * ELF symbol visibility (st_other ELF_ST_VISIBILITY)
 */
static elfedit_atoui_sym_t sym_stv[] = {
	{ MSG_ORIG(MSG_STV_DEFAULT),		STV_DEFAULT },
	{ MSG_ORIG(MSG_STV_DEFAULT_ALT1),	STV_DEFAULT },

	{ MSG_ORIG(MSG_STV_INTERNAL),		STV_INTERNAL },
	{ MSG_ORIG(MSG_STV_INTERNAL_ALT1),	STV_INTERNAL },

	{ MSG_ORIG(MSG_STV_HIDDEN),		STV_HIDDEN },
	{ MSG_ORIG(MSG_STV_HIDDEN_ALT1),	STV_HIDDEN },

	{ MSG_ORIG(MSG_STV_PROTECTED),		STV_PROTECTED },
	{ MSG_ORIG(MSG_STV_PROTECTED_ALT1),	STV_PROTECTED },

	{ MSG_ORIG(MSG_STV_EXPORTED),		STV_EXPORTED },
	{ MSG_ORIG(MSG_STV_EXPORTED_ALT1),	STV_EXPORTED },

	{ MSG_ORIG(MSG_STV_SINGLETON),		STV_SINGLETON },
	{ MSG_ORIG(MSG_STV_SINGLETON_ALT1),	STV_SINGLETON },

	{ MSG_ORIG(MSG_STV_ELIMINATE),		STV_ELIMINATE },
	{ MSG_ORIG(MSG_STV_ELIMINATE_ALT1),	STV_ELIMINATE },

	{ NULL }
};

/*
 * ELF syminfo SYMINFO_BT_ special boundto values
 */
static elfedit_atoui_sym_t sym_syminfo_bt[] = {
	{ MSG_ORIG(MSG_SYMINFO_BT_SELF),	SYMINFO_BT_SELF },
	{ MSG_ORIG(MSG_SYMINFO_BT_SELF_ALT1),	SYMINFO_BT_SELF },

	{ MSG_ORIG(MSG_SYMINFO_BT_PARENT),	SYMINFO_BT_PARENT },
	{ MSG_ORIG(MSG_SYMINFO_BT_PARENT_ALT1),	SYMINFO_BT_PARENT },

	{ MSG_ORIG(MSG_SYMINFO_BT_NONE),	SYMINFO_BT_NONE },
	{ MSG_ORIG(MSG_SYMINFO_BT_NONE_ALT1),	SYMINFO_BT_NONE },

	{ NULL }
};


/*
 * ELF syminfo SYMINFO_FLG_ flags
 */
static elfedit_atoui_sym_t sym_syminfo_flg[] = {
	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECT),	SYMINFO_FLG_DIRECT },
	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECT_ALT1), SYMINFO_FLG_DIRECT },

	{ MSG_ORIG(MSG_SYMINFO_FLG_COPY),	SYMINFO_FLG_COPY },
	{ MSG_ORIG(MSG_SYMINFO_FLG_COPY_ALT1),	SYMINFO_FLG_COPY },

	{ MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD),	SYMINFO_FLG_LAZYLOAD },
	{ MSG_ORIG(MSG_SYMINFO_FLG_LAZYLOAD_ALT1), SYMINFO_FLG_LAZYLOAD },

	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND),	SYMINFO_FLG_DIRECTBIND },
	{ MSG_ORIG(MSG_SYMINFO_FLG_DIRECTBIND_ALT1), SYMINFO_FLG_DIRECTBIND },

	{ MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT), SYMINFO_FLG_NOEXTDIRECT },
	{ MSG_ORIG(MSG_SYMINFO_FLG_NOEXTDIRECT_ALT1), SYMINFO_FLG_NOEXTDIRECT },

	{ NULL }
};


/*
 * ELF capabilities tag CA_ values
 */
static elfedit_atoui_sym_t sym_ca[] = {
	{ MSG_ORIG(MSG_CA_SUNW_NULL),		CA_SUNW_NULL },
	{ MSG_ORIG(MSG_CA_SUNW_NULL_ALT1),	CA_SUNW_NULL },

	{ MSG_ORIG(MSG_CA_SUNW_HW_1),		CA_SUNW_HW_1 },
	{ MSG_ORIG(MSG_CA_SUNW_HW_1_ALT1),	CA_SUNW_HW_1 },

	{ MSG_ORIG(MSG_CA_SUNW_SF_1),		CA_SUNW_SF_1 },
	{ MSG_ORIG(MSG_CA_SUNW_SF_1_ALT1),	CA_SUNW_SF_1 },

	{ NULL }
};


/*
 * AV_386 flags used for CA_SUNW_HW_1 capabilities
 *
 * The space for this is reserved at compile time, but the values are
 * filled in at runtime on demand from the usr/src/common/elfcap code.
 * Note that we need two slots for every capability, one for the full
 * string, and another for the informal lowercase version.
 */
static elfedit_atoui_sym_t sym_av_386[(2 * ELFCAP_NUM_HW1_386) + 1];

/*
 * AV_SPARC flags used for CA_SUNW_HW_1 capabilities
 *
 * The space for this is reserved at compile time, but the values are
 * filled in at runtime on demand from the usr/src/common/elfcap code.
 * Note that we need two slots for every capability, one for the full
 * string, and another for the informal lowercase version.
 */
static elfedit_atoui_sym_t sym_av_sparc[(2 * ELFCAP_NUM_HW1_SPARC) + 1];

/*
 * SF1_SUNW flags used for CA_SUNW_SF_1 capabilities
 *
 * The space for this is reserved at compile time, but the values are
 * filled in at runtime on demand from the usr/src/common/elfcap code.
 * Note that we need two slots for every capability, one for the full
 * string, and another for the informal lowercase version.
 */
static elfedit_atoui_sym_t sym_sf1_sunw[(2 * ELFCAP_NUM_SF1) + 1];








/*
 * Array of pointers to atoui arrays for each constant type, indexed
 * by elfedit_const_t value. The number and order of entries in this
 * table must agree with the definition of elfedit_const_t in elfedit.h.
 */
static elfedit_atoui_sym_t *sym_table[] = {
	sym_outstyle,		/* 0: ELFEDIT_CONST_OUTSTYLE */
	sym_minus_o_outstyle,	/* 1: ELFEDIT_CONST_OUTSTYLE_MO */
	sym_bool,		/* 2: ELFEDIT_CONST_BOOL */
	sym_shn,		/* 3: ELFEDIT_CONST_SHN */
	sym_sht,		/* 4: ELFEDIT_CONST_SHT */
	sym_sht_strtab,		/* 5: ELFEDIT_CONST_SHT_STRTAB */
	sym_sht_allsymtab,	/* 6: ELFEDIT_CONST_SHT_ALLSYMTAB */
	sym_sht_symtab,		/* 7: ELFEDIT_CONST_SHT_SYMTAB */
	sym_sht_dynsym,		/* 8: ELFEDIT_CONST_SHT_DYNSYM */
	sym_sht_ldynsym,	/* 9: ELFEDIT_CONST_SHT_LDYNSYM */
	sym_dt,			/* 10: ELFEDIT_CONST_DT: Dynamic tags */
	sym_df,			/* 11: ELFEDIT_CONST_DF: DT_FLAGS */
	sym_df_p1,		/* 12: ELFEDIT_CONST_DF_P1: DF_POSFLAG_1 */
	sym_df_1,		/* 13: ELFEDIT_CONST_DF_1: DT_FLAGS_1 */
	sym_dtf_1,		/* 14: ELFEDIT_CONST_DTF_1: DT_FEATURE_1 */
	sym_ei,			/* 15: ELFEDIT_CONST_EI: Ehdr e_ident indexes */
	sym_et,			/* 16: ELFEDIT_CONST_ET: Ehdr obj type */
	sym_elfclass,		/* 17: ELFEDIT_CONST_ELFCLASS: Ehdr class */
	sym_elfdata,		/* 18: ELFEDIT_CONST_ELFDATA: Ehdr endian */
	sym_ef,			/* 19: ELFEDIT_CONST_EF: Ehdr flags */
	sym_ev,			/* 20: ELFEDIT_CONST_EV: Ehdr version */
	sym_em,			/* 21: ELFEDIT_CONST_EM: Ehdr machine */
	sym_elfosabi,		/* 22: ELFEDIT_CONST_ELFOSABI: Ehdr ABI */
	sym_pt,			/* 23: ELFEDIT_CONST_PT: Phdr type */
	sym_pf,			/* 24: ELFEDIT_CONST_PF: Phdr flags */
	sym_shf,		/* 25: ELFEDIT_CONST_SHF: Shdr flags */
	sym_stb,		/* 26: ELFEDIT_CONST_STB: Sym binding */
	sym_stt,		/* 27: ELFEDIT_CONST_STT: Sym type */
	sym_stv,		/* 28: ELFEDIT_CONST_STV: Sym visibility */
	sym_syminfo_bt,		/* 29: ELFEDIT_CONST_SYMINFO_BT:Syminfo bndto */
	sym_syminfo_flg,	/* 30: ELFEDIT_CONST_SYMINFO_FLG:Syminfo flag */
	sym_ca,			/* 31: ELFEDIT_CONST_CA: Capabilities tags */
	NULL,			/* 32: ELFEDIT_CONST_AV_386: X86 HW caps */
	NULL,			/* 33: ELFEDIT_CONST_AV_SPARC: sparc HW caps */
	NULL,			/* 34: ELFEDIT_CONST_SF1_SUNW: software caps */
};







/*
 * Fill in the specified hardware/software capability array
 * with data from usr/src/common/elfcap.
 *
 * entry:
 *	const_type - Index of constant item being filled
 *	arr - elfedit_atoui_sym_t array to be filled
 *	desc - Array of capability descriptors from elfcap
 *	cnt - # of capability descriptors.
 *
 * exit:
 *	arr is expected to have [(2 * cnt) + 1] elements, all zero filled.
 *	For each descriptor, 2 array elements are filled in. The first one
 *	has the full name, and the second has the lowecase informal version.
 *	The final element of arr is left as NULL, to serve as termination.
 */
static void
fill_capability_array(elfedit_const_t const_type,
    elfedit_atoui_sym_t *arr, const elfcap_desc_t *desc, size_t cnt)
{
	sym_table[const_type] = arr;

	for (; cnt-- > 0; desc++) {
		/*
		 * Ignore "placeholder" items. These represent
		 * unallocated holes in the capability bits.
		 */
		if (desc->c_val == 0)
			continue;

		arr->sym_name = desc->c_full.s_str;
		arr->sym_value = desc->c_val;
		arr++;

		arr->sym_name = desc->c_lc.s_str;
		arr->sym_value = desc->c_val;
		arr++;
	}

}



/*
 * Given an elfedit_const_t value, return the array of elfedit_atoui_sym_t
 * entries that it represents.
 */
elfedit_atoui_sym_t *
elfedit_const_to_atoui(elfedit_const_t const_type)
{
	if ((const_type < 0) ||
	    (const_type >= (sizeof (sym_table) / sizeof (sym_table[0]))))
		elfedit_msg(ELFEDIT_MSG_ERR, MSG_INTL(MSG_ERR_BADCONST));

	/* Fill capability constant array on demand? */
	switch (const_type) {
	case ELFEDIT_CONST_AV_386:
		if (sym_table[ELFEDIT_CONST_AV_386] == NULL)
			fill_capability_array(ELFEDIT_CONST_AV_386,
			    sym_av_386, elfcap_getdesc_hw1_386(),
			    ELFCAP_NUM_HW1_386);
		break;
	case ELFEDIT_CONST_AV_SPARC:
		if (sym_table[ELFEDIT_CONST_AV_SPARC] == NULL)
			fill_capability_array(ELFEDIT_CONST_AV_SPARC,
			    sym_av_sparc, elfcap_getdesc_hw1_sparc(),
			    ELFCAP_NUM_HW1_SPARC);
		break;
	case ELFEDIT_CONST_SF1_SUNW:
		if (sym_table[ELFEDIT_CONST_SF1_SUNW] == NULL)
			fill_capability_array(ELFEDIT_CONST_SF1_SUNW,
			    sym_sf1_sunw, elfcap_getdesc_sf1(), ELFCAP_NUM_SF1);
		break;
	}

	return (sym_table[const_type]);
}



/*
 * Return the elfedit_atoui_t array that corresponds to the
 * CA_SUNW_HW_1 hardware capabiliies field for a given
 * machine type.
 *
 * This routine will return NULL if there is no definition for the
 * machine specified.
 */
elfedit_atoui_sym_t *
elfedit_mach_sunw_hw1_to_atoui(int mach)
{
	switch (mach) {
	case EM_386:
	case EM_486:
	case EM_AMD64:
		return (elfedit_const_to_atoui(ELFEDIT_CONST_AV_386));

	case EM_SPARC:
	case EM_SPARC32PLUS:
	case EM_SPARCV9:
		return (elfedit_const_to_atoui(ELFEDIT_CONST_AV_SPARC));
	}

	/* A machine we don't know about */
	return (NULL);
}