elf.c revision 5aefb6555731130ca4fd295960123d71f2d21fe8
080575042aba2197b425ebfd52061dea061a9aa1xy * CDDL HEADER START
080575042aba2197b425ebfd52061dea061a9aa1xy * The contents of this file are subject to the terms of the
080575042aba2197b425ebfd52061dea061a9aa1xy * Common Development and Distribution License (the "License").
080575042aba2197b425ebfd52061dea061a9aa1xy * You may not use this file except in compliance with the License.
080575042aba2197b425ebfd52061dea061a9aa1xy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d5c3073dbbd835e1e9b7dca0c6c770cf3cc20afachenlu chen - Sun Microsystems - Beijing China * or http://www.opensolaris.org/os/licensing.
080575042aba2197b425ebfd52061dea061a9aa1xy * See the License for the specific language governing permissions
080575042aba2197b425ebfd52061dea061a9aa1xy * and limitations under the License.
080575042aba2197b425ebfd52061dea061a9aa1xy * When distributing Covered Code, include this CDDL HEADER in each
080575042aba2197b425ebfd52061dea061a9aa1xy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
080575042aba2197b425ebfd52061dea061a9aa1xy * If applicable, add the following below this CDDL HEADER, with the
080575042aba2197b425ebfd52061dea061a9aa1xy * fields enclosed by brackets "[]" replaced with your own identifying
080575042aba2197b425ebfd52061dea061a9aa1xy * information: Portions Copyright [yyyy] [name of copyright owner]
080575042aba2197b425ebfd52061dea061a9aa1xy * CDDL HEADER END
080575042aba2197b425ebfd52061dea061a9aa1xy * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi * Use is subject to license terms.
080575042aba2197b425ebfd52061dea061a9aa1xy#pragma ident "%Z%%M% %I% %E% SMI"
080575042aba2197b425ebfd52061dea061a9aa1xy * String conversion routines for ELF header attributes.
080575042aba2197b425ebfd52061dea061a9aa1xy#include "_conv.h"
080575042aba2197b425ebfd52061dea061a9aa1xyconst char *
080575042aba2197b425ebfd52061dea061a9aa1xy return (conv_invalid_val(string, CONV_INV_STRSIZE, class, 0));
c124a83e09115de88ecccd4f689983f42a1d53bdRobert Mustacchi MSG_ELFDATANONE, MSG_ELFDATA2LSB, MSG_ELFDATA2MSB
25f2d433de915875c8393f0b0dc14aa155997ad0xy return (conv_invalid_val(string, CONV_INV_STRSIZE, data, 0));
4d7379630d53d9992780329b674af8c85935e858xiangtao you - Sun Microsystems - Beijing China MSG_EM_ARC, MSG_EM_H8_300, MSG_EM_H8_300H,
4d7379630d53d9992780329b674af8c85935e858xiangtao you - Sun Microsystems - Beijing China MSG_EM_H8S, MSG_EM_H8_500, MSG_EM_IA_64,
75eba5b6d79ed4d2ce3daf7b2806306b6b69a938Robert Mustacchi MSG_EM_MIPS_X, MSG_EM_COLDFIRE, MSG_EM_68HC12,
caf05df5c10c960028f122b1b02a3f7d8f892c31Miles Xu, Sun Microsystems MSG_EM_NDR1, MSG_EM_STARCORE, MSG_EM_ME16,
4d7379630d53d9992780329b674af8c85935e858xiangtao you - Sun Microsystems - Beijing China MSG_EM_68HC16, MSG_EM_68HC11, MSG_EM_68HC08,
ede5269ebe7fa3787cc9b58c3781b639c578f93dchenlu chen - Sun Microsystems - Beijing China MSG_EM_FR30, MSG_EM_D10V, MSG_EM_D30V,
592a4d85662412bade15f3d9e9e0cbcf8514348cccconst char *
49b7860084dbba18bc00b29413d6182197f9fe93Robert Mustacchi return (conv_invalid_val(string, CONV_INV_STRSIZE, machine, 0));
25f2d433de915875c8393f0b0dc14aa155997ad0xy return (conv_invalid_val(string, CONV_INV_STRSIZE, etype, 0));
25f2d433de915875c8393f0b0dc14aa155997ad0xy return (conv_invalid_val(string, CONV_INV_STRSIZE, version, 0));
fe62dec3a38f1f79ffe68417df75dbbb58135bb7Chen-Liang Xu * Make a string representation of the e_flags field.
080575042aba2197b425ebfd52061dea061a9aa1xyconst char *
fe62dec3a38f1f79ffe68417df75dbbb58135bb7Chen-Liang Xu { EF_SPARC_SUN_US1, MSG_ORIG(MSG_EF_SPARC_SUN_US1) },
fe62dec3a38f1f79ffe68417df75dbbb58135bb7Chen-Liang Xu { EF_SPARC_HAL_R1, MSG_ORIG(MSG_EF_SPARC_HAL_R1) },
080575042aba2197b425ebfd52061dea061a9aa1xy * Non-SPARC architectures presently provide no known flags.
080575042aba2197b425ebfd52061dea061a9aa1xy * Valid vendor extension bits for SPARCV9. These must be
25f2d433de915875c8393f0b0dc14aa155997ad0xy * updated along with elf_SPARC.h.
fe62dec3a38f1f79ffe68417df75dbbb58135bb7Chen-Liang Xu (void) strcpy(string, MSG_ORIG(MSG_GBL_OSQBRKT));
fe62dec3a38f1f79ffe68417df75dbbb58135bb7Chen-Liang Xu if (conv_expn_field(string, EFLAGSZ, vda, flags, _flags, 0, 0))
fe62dec3a38f1f79ffe68417df75dbbb58135bb7Chen-Liang Xu (void) strlcat(string, MSG_ORIG(MSG_GBL_CSQBRKT),
25f2d433de915875c8393f0b0dc14aa155997ad0xy return (conv_invalid_val(string, EFLAGSZ, flags, CONV_INV_DECIMAL));
25f2d433de915875c8393f0b0dc14aa155997ad0xy * A generic means of returning additional information for a rejected file in
25f2d433de915875c8393f0b0dc14aa155997ad0xy * terms of a string.
25f2d433de915875c8393f0b0dc14aa155997ad0xyconst char *
4d7379630d53d9992780329b674af8c85935e858xiangtao you - Sun Microsystems - Beijing Chinaconv_reject_desc(Rej_desc * rej)
d5c3073dbbd835e1e9b7dca0c6c770cf3cc20afachenlu chen - Sun Microsystems - Beijing China static char string[CONV_INV_STRSIZE];
d5c3073dbbd835e1e9b7dca0c6c770cf3cc20afachenlu chen - Sun Microsystems - Beijing China ushort_t type = rej->rej_type;
d5c3073dbbd835e1e9b7dca0c6c770cf3cc20afachenlu chen - Sun Microsystems - Beijing China uint_t info = rej->rej_info;
25f2d433de915875c8393f0b0dc14aa155997ad0xy /* LINTED */
3f64cd552fee350c8075ec62765e9a6f9caef1a8guoqing zhu - Sun Microsystems - Beijing China else if (type == SGS_REJ_CLASS)
25f2d433de915875c8393f0b0dc14aa155997ad0xy /* LINTED */
caf05df5c10c960028f122b1b02a3f7d8f892c31Miles Xu, Sun Microsystems return (conv_ehdr_data((uchar_t)info));
caf05df5c10c960028f122b1b02a3f7d8f892c31Miles Xu, Sun Microsystems return (conv_ehdr_type((Half)info));
caf05df5c10c960028f122b1b02a3f7d8f892c31Miles Xu, Sun Microsystems else if ((type == SGS_REJ_BADFLAG) || (type == SGS_REJ_MISFLAG) ||
caf05df5c10c960028f122b1b02a3f7d8f892c31Miles Xu, Sun Microsystems (type == SGS_REJ_HAL) || (type == SGS_REJ_US3))
caf05df5c10c960028f122b1b02a3f7d8f892c31Miles Xu, Sun Microsystems * Only called from ld.so.1, thus M_MACH is hardcoded.
080575042aba2197b425ebfd52061dea061a9aa1xy return ((const char *)0);
25f2d433de915875c8393f0b0dc14aa155997ad0xy else if ((type == SGS_REJ_STR) || (type == SGS_REJ_HWCAP_1)) {
3f64cd552fee350c8075ec62765e9a6f9caef1a8guoqing zhu - Sun Microsystems - Beijing China if (rej->rej_str)
3f64cd552fee350c8075ec62765e9a6f9caef1a8guoqing zhu - Sun Microsystems - Beijing China return ((const char *)rej->rej_str);
3f64cd552fee350c8075ec62765e9a6f9caef1a8guoqing zhu - Sun Microsystems - Beijing China return (MSG_ORIG(MSG_STR_EMPTY));
3f64cd552fee350c8075ec62765e9a6f9caef1a8guoqing zhu - Sun Microsystems - Beijing China return (conv_invalid_val(string, CONV_INV_STRSIZE, info,