syminfo.c revision 3466:4cc6ca6917b5
189857Sobrien/*
289857Sobrien * CDDL HEADER START
389857Sobrien *
489857Sobrien * The contents of this file are subject to the terms of the
589857Sobrien * Common Development and Distribution License (the "License").
689857Sobrien * You may not use this file except in compliance with the License.
789857Sobrien *
889857Sobrien * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
989857Sobrien * or http://www.opensolaris.org/os/licensing.
1089857Sobrien * See the License for the specific language governing permissions
1189857Sobrien * and limitations under the License.
1289857Sobrien *
1389857Sobrien * When distributing Covered Code, include this CDDL HEADER in each
1489857Sobrien * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1589857Sobrien * If applicable, add the following below this CDDL HEADER, with the
1689857Sobrien * fields enclosed by brackets "[]" replaced with your own identifying
1789857Sobrien * information: Portions Copyright [yyyy] [name of copyright owner]
1889857Sobrien *
1989857Sobrien * CDDL HEADER END
2089857Sobrien */
2189857Sobrien
2289857Sobrien/*
2389857Sobrien * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2489857Sobrien * Use is subject to license terms.
2589857Sobrien */
2689857Sobrien#pragma ident	"%Z%%M%	%I%	%E% SMI"
2789857Sobrien
2889857Sobrien#include	<sgs.h>
2989857Sobrien#include	<debug.h>
3089857Sobrien#include	<msg.h>
3189857Sobrien
3289857Sobrienvoid
3389857SobrienElf_syminfo_title(Lm_list *lml)
3489857Sobrien{
3589857Sobrien	dbg_print(lml, MSG_INTL(MSG_SYMINFO_TITLE));
3689857Sobrien}
3789857Sobrien
3889857Sobrien#define	FLAGSZ	16
3989857Sobrien#define	NDXSZ	10
4089857Sobrien
4189857Sobrienvoid
4289857SobrienElf_syminfo_entry(Lm_list *lml, Word ndx, Syminfo *sip, const char *name,
4389857Sobrien    const char *needed)
4489857Sobrien{
4589857Sobrien	const char	*bndstr, *str;
4689857Sobrien	char		flagstr[FLAGSZ], sndxstr[NDXSZ], dndxstr[NDXSZ];
4789857Sobrien	int		flgndx = 0;
4889857Sobrien	Half		flags = sip->si_flags;
49
50	if (flags & SYMINFO_FLG_DIRECT) {
51		if (sip->si_boundto == SYMINFO_BT_SELF)
52			bndstr = MSG_INTL(MSG_SYMINFO_SELF);
53		else if (sip->si_boundto == SYMINFO_BT_PARENT)
54			bndstr = MSG_INTL(MSG_SYMINFO_PARENT);
55		else
56			bndstr = needed;
57
58		flagstr[flgndx++] = 'D';
59		flags &= ~SYMINFO_FLG_DIRECT;
60
61	} else if (flags & SYMINFO_FLG_FILTER) {
62		bndstr = needed;
63		flagstr[flgndx++] = 'F';
64		flags &= ~SYMINFO_FLG_FILTER;
65
66	} else if (flags & SYMINFO_FLG_AUXILIARY) {
67		bndstr = needed;
68		flagstr[flgndx++] = 'A';
69		flags &= ~SYMINFO_FLG_AUXILIARY;
70
71	} else if (sip->si_boundto == SYMINFO_BT_EXTERN)
72		bndstr = MSG_INTL(MSG_SYMINFO_EXTERN);
73	else
74		bndstr = MSG_ORIG(MSG_STR_EMPTY);
75
76	if (flags & SYMINFO_FLG_DIRECTBIND) {
77		flagstr[flgndx++] = 'B';
78		flags &= ~SYMINFO_FLG_DIRECTBIND;
79	}
80	if (flags & SYMINFO_FLG_COPY) {
81		flagstr[flgndx++] = 'C';
82		flags &= ~SYMINFO_FLG_COPY;
83	}
84	if (flags & SYMINFO_FLG_LAZYLOAD) {
85		flagstr[flgndx++] = 'L';
86		flags &= ~SYMINFO_FLG_LAZYLOAD;
87	}
88	if (flags & SYMINFO_FLG_NOEXTDIRECT) {
89		flagstr[flgndx++] = 'N';
90		flags &= ~SYMINFO_FLG_NOEXTDIRECT;
91	}
92	if (flags & SYMINFO_FLG_INTERPOSE) {
93		flagstr[flgndx++] = 'I';
94		flags &= ~SYMINFO_FLG_INTERPOSE;
95	}
96
97	/*
98	 * Did we account for all of the flags?
99	 */
100	if (flags)
101		(void) snprintf(&flagstr[flgndx], FLAGSZ - flgndx,
102		    MSG_ORIG(MSG_SYMINFO_UNKFLAG), flags);
103	else
104		flagstr[flgndx] = '\0';
105
106	/*
107	 * If we've bound to a dependency, determine the dynamic entry index.
108	 */
109	if (bndstr == needed) {
110		(void) snprintf(dndxstr, NDXSZ, MSG_ORIG(MSG_FMT_INDEX),
111		    sip->si_boundto);
112		str = dndxstr;
113	} else
114		str = MSG_ORIG(MSG_STR_EMPTY);
115
116	(void) snprintf(sndxstr, NDXSZ, MSG_ORIG(MSG_FMT_INDEX), ndx);
117
118	dbg_print(lml, MSG_INTL(MSG_SYMINFO_ENTRY), sndxstr, flagstr, str,
119	    bndstr, Elf_demangle_name(name));
120}
121