xref: /titanic_44/usr/src/cmd/sgs/liblddbg/common/syminfo.c (revision f441771b0ce9f9d6122d318ff8290cb1a2848f9d)
15aefb655Srie /*
25aefb655Srie  * CDDL HEADER START
35aefb655Srie  *
45aefb655Srie  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
75aefb655Srie  *
85aefb655Srie  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95aefb655Srie  * or http://www.opensolaris.org/os/licensing.
105aefb655Srie  * See the License for the specific language governing permissions
115aefb655Srie  * and limitations under the License.
125aefb655Srie  *
135aefb655Srie  * When distributing Covered Code, include this CDDL HEADER in each
145aefb655Srie  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155aefb655Srie  * If applicable, add the following below this CDDL HEADER, with the
165aefb655Srie  * fields enclosed by brackets "[]" replaced with your own identifying
175aefb655Srie  * information: Portions Copyright [yyyy] [name of copyright owner]
185aefb655Srie  *
195aefb655Srie  * CDDL HEADER END
205aefb655Srie  */
215aefb655Srie 
225aefb655Srie /*
23*f441771bSRod Evans  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
245aefb655Srie  */
255aefb655Srie #include	<sgs.h>
26a194faf8Srie #include	<stdio.h>
275aefb655Srie #include	<debug.h>
285aefb655Srie #include	<msg.h>
295aefb655Srie 
305aefb655Srie void
Elf_syminfo_title(Lm_list * lml)315aefb655Srie Elf_syminfo_title(Lm_list *lml)
325aefb655Srie {
335aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_SYMINFO_TITLE));
345aefb655Srie }
355aefb655Srie 
365aefb655Srie #define	FLAGSZ	16
375aefb655Srie #define	NDXSZ	10
385aefb655Srie 
395aefb655Srie void
Elf_syminfo_entry(Lm_list * lml,Word ndx,Syminfo * sip,const char * name,const char * needed)405aefb655Srie Elf_syminfo_entry(Lm_list *lml, Word ndx, Syminfo *sip, const char *name,
415aefb655Srie     const char *needed)
425aefb655Srie {
4308278a5eSRod Evans 	const char	*bndstr = NULL, *str;
445aefb655Srie 	char		flagstr[FLAGSZ], sndxstr[NDXSZ], dndxstr[NDXSZ];
455aefb655Srie 	int		flgndx = 0;
465aefb655Srie 	Half		flags = sip->si_flags;
475aefb655Srie 
4808278a5eSRod Evans 	if (flags & SYMINFO_FLG_CAP) {
4908278a5eSRod Evans 		bndstr = MSG_INTL(MSG_SYMINFO_CAP);
5008278a5eSRod Evans 		flagstr[flgndx++] = 'S';
5108278a5eSRod Evans 		flags &= ~SYMINFO_FLG_CAP;
5208278a5eSRod Evans 	}
5308278a5eSRod Evans 
545aefb655Srie 	if (flags & SYMINFO_FLG_DIRECT) {
5508278a5eSRod Evans 		if (bndstr == NULL) {
565aefb655Srie 			if (sip->si_boundto == SYMINFO_BT_SELF)
575aefb655Srie 				bndstr = MSG_INTL(MSG_SYMINFO_SELF);
585aefb655Srie 			else if (sip->si_boundto == SYMINFO_BT_PARENT)
595aefb655Srie 				bndstr = MSG_INTL(MSG_SYMINFO_PARENT);
605aefb655Srie 			else
615aefb655Srie 				bndstr = needed;
6208278a5eSRod Evans 		}
635aefb655Srie 		flagstr[flgndx++] = 'D';
645aefb655Srie 		flags &= ~SYMINFO_FLG_DIRECT;
655aefb655Srie 
665aefb655Srie 	} else if (flags & SYMINFO_FLG_FILTER) {
675aefb655Srie 		bndstr = needed;
685aefb655Srie 		flagstr[flgndx++] = 'F';
695aefb655Srie 		flags &= ~SYMINFO_FLG_FILTER;
705aefb655Srie 
715aefb655Srie 	} else if (flags & SYMINFO_FLG_AUXILIARY) {
725aefb655Srie 		bndstr = needed;
735aefb655Srie 		flagstr[flgndx++] = 'A';
745aefb655Srie 		flags &= ~SYMINFO_FLG_AUXILIARY;
755aefb655Srie 
765aefb655Srie 	} else if (sip->si_boundto == SYMINFO_BT_EXTERN)
775aefb655Srie 		bndstr = MSG_INTL(MSG_SYMINFO_EXTERN);
7808278a5eSRod Evans 	else if (bndstr == NULL)
795aefb655Srie 		bndstr = MSG_ORIG(MSG_STR_EMPTY);
805aefb655Srie 
815aefb655Srie 	if (flags & SYMINFO_FLG_DIRECTBIND) {
825aefb655Srie 		flagstr[flgndx++] = 'B';
835aefb655Srie 		flags &= ~SYMINFO_FLG_DIRECTBIND;
845aefb655Srie 	}
855aefb655Srie 	if (flags & SYMINFO_FLG_COPY) {
865aefb655Srie 		flagstr[flgndx++] = 'C';
875aefb655Srie 		flags &= ~SYMINFO_FLG_COPY;
885aefb655Srie 	}
895aefb655Srie 	if (flags & SYMINFO_FLG_LAZYLOAD) {
905aefb655Srie 		flagstr[flgndx++] = 'L';
915aefb655Srie 		flags &= ~SYMINFO_FLG_LAZYLOAD;
925aefb655Srie 	}
935aefb655Srie 	if (flags & SYMINFO_FLG_NOEXTDIRECT) {
945aefb655Srie 		flagstr[flgndx++] = 'N';
955aefb655Srie 		flags &= ~SYMINFO_FLG_NOEXTDIRECT;
965aefb655Srie 	}
979a411307Srie 	if (flags & SYMINFO_FLG_INTERPOSE) {
989a411307Srie 		flagstr[flgndx++] = 'I';
999a411307Srie 		flags &= ~SYMINFO_FLG_INTERPOSE;
1009a411307Srie 	}
101*f441771bSRod Evans 	if (flags & SYMINFO_FLG_DEFERRED) {
102*f441771bSRod Evans 		flagstr[flgndx++] = 'P';
103*f441771bSRod Evans 		flags &= ~SYMINFO_FLG_DEFERRED;
104*f441771bSRod Evans 	}
1055aefb655Srie 
1065aefb655Srie 	/*
1075aefb655Srie 	 * Did we account for all of the flags?
1085aefb655Srie 	 */
1095aefb655Srie 	if (flags)
1109a411307Srie 		(void) snprintf(&flagstr[flgndx], FLAGSZ - flgndx,
1115aefb655Srie 		    MSG_ORIG(MSG_SYMINFO_UNKFLAG), flags);
1125aefb655Srie 	else
1135aefb655Srie 		flagstr[flgndx] = '\0';
1145aefb655Srie 
1155aefb655Srie 	/*
1165aefb655Srie 	 * If we've bound to a dependency, determine the dynamic entry index.
1175aefb655Srie 	 */
1185aefb655Srie 	if (bndstr == needed) {
1195aefb655Srie 		(void) snprintf(dndxstr, NDXSZ, MSG_ORIG(MSG_FMT_INDEX),
1205aefb655Srie 		    sip->si_boundto);
1215aefb655Srie 		str = dndxstr;
1225aefb655Srie 	} else
1235aefb655Srie 		str = MSG_ORIG(MSG_STR_EMPTY);
1245aefb655Srie 
1255aefb655Srie 	(void) snprintf(sndxstr, NDXSZ, MSG_ORIG(MSG_FMT_INDEX), ndx);
1265aefb655Srie 
1275aefb655Srie 	dbg_print(lml, MSG_INTL(MSG_SYMINFO_ENTRY), sndxstr, flagstr, str,
1285aefb655Srie 	    bndstr, Elf_demangle_name(name));
1295aefb655Srie }
130