usr/src/cmd/sgs/liblddbg/common/syminfo.c
author Rod Evans <Rod.Evans@Sun.COM>
Wed, 19 May 2010 22:33:49 -0700
changeset 12449 a87750d92895
parent 11827 d7ef53deac3f
permissions -rw-r--r--
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW PSARC/2010/175 Deferred symbol references 6943432 dlsym(RTLD_PROBE) should only bind to symbol definitions 6668759 an external method for determining whether an ELF dependency is optional
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     1
/*
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     2
 * CDDL HEADER START
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     3
 *
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     7
 *
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    11
 * and limitations under the License.
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    12
 *
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    18
 *
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    19
 * CDDL HEADER END
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    20
 */
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    21
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    22
/*
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
    23
 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    24
 */
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    25
#include	<sgs.h>
5549
beb29939b34a 6629404 ld with -z ignore doesn't scale
rie
parents: 3466
diff changeset
    26
#include	<stdio.h>
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    27
#include	<debug.h>
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    28
#include	<msg.h>
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    29
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    30
void
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    31
Elf_syminfo_title(Lm_list *lml)
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    32
{
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    33
	dbg_print(lml, MSG_INTL(MSG_SYMINFO_TITLE));
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    34
}
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    35
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    36
#define	FLAGSZ	16
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    37
#define	NDXSZ	10
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    38
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    39
void
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    40
Elf_syminfo_entry(Lm_list *lml, Word ndx, Syminfo *sip, const char *name,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    41
    const char *needed)
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    42
{
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    43
	const char	*bndstr = NULL, *str;
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    44
	char		flagstr[FLAGSZ], sndxstr[NDXSZ], dndxstr[NDXSZ];
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    45
	int		flgndx = 0;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    46
	Half		flags = sip->si_flags;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    47
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    48
	if (flags & SYMINFO_FLG_CAP) {
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    49
		bndstr = MSG_INTL(MSG_SYMINFO_CAP);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    50
		flagstr[flgndx++] = 'S';
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    51
		flags &= ~SYMINFO_FLG_CAP;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    52
	}
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    53
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    54
	if (flags & SYMINFO_FLG_DIRECT) {
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    55
		if (bndstr == NULL) {
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    56
			if (sip->si_boundto == SYMINFO_BT_SELF)
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    57
				bndstr = MSG_INTL(MSG_SYMINFO_SELF);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    58
			else if (sip->si_boundto == SYMINFO_BT_PARENT)
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    59
				bndstr = MSG_INTL(MSG_SYMINFO_PARENT);
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    60
			else
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    61
				bndstr = needed;
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    62
		}
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    63
		flagstr[flgndx++] = 'D';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    64
		flags &= ~SYMINFO_FLG_DIRECT;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    65
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    66
	} else if (flags & SYMINFO_FLG_FILTER) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    67
		bndstr = needed;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    68
		flagstr[flgndx++] = 'F';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    69
		flags &= ~SYMINFO_FLG_FILTER;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    70
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    71
	} else if (flags & SYMINFO_FLG_AUXILIARY) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    72
		bndstr = needed;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    73
		flagstr[flgndx++] = 'A';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    74
		flags &= ~SYMINFO_FLG_AUXILIARY;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    75
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    76
	} else if (sip->si_boundto == SYMINFO_BT_EXTERN)
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    77
		bndstr = MSG_INTL(MSG_SYMINFO_EXTERN);
11827
d7ef53deac3f 6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents: 5549
diff changeset
    78
	else if (bndstr == NULL)
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    79
		bndstr = MSG_ORIG(MSG_STR_EMPTY);
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    80
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    81
	if (flags & SYMINFO_FLG_DIRECTBIND) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    82
		flagstr[flgndx++] = 'B';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    83
		flags &= ~SYMINFO_FLG_DIRECTBIND;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    84
	}
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    85
	if (flags & SYMINFO_FLG_COPY) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    86
		flagstr[flgndx++] = 'C';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    87
		flags &= ~SYMINFO_FLG_COPY;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    88
	}
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    89
	if (flags & SYMINFO_FLG_LAZYLOAD) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    90
		flagstr[flgndx++] = 'L';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    91
		flags &= ~SYMINFO_FLG_LAZYLOAD;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    92
	}
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    93
	if (flags & SYMINFO_FLG_NOEXTDIRECT) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    94
		flagstr[flgndx++] = 'N';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    95
		flags &= ~SYMINFO_FLG_NOEXTDIRECT;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
    96
	}
3466
4cc6ca6917b5 PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents: 1618
diff changeset
    97
	if (flags & SYMINFO_FLG_INTERPOSE) {
4cc6ca6917b5 PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents: 1618
diff changeset
    98
		flagstr[flgndx++] = 'I';
4cc6ca6917b5 PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents: 1618
diff changeset
    99
		flags &= ~SYMINFO_FLG_INTERPOSE;
4cc6ca6917b5 PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents: 1618
diff changeset
   100
	}
12449
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   101
	if (flags & SYMINFO_FLG_DEFERRED) {
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   102
		flagstr[flgndx++] = 'P';
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   103
		flags &= ~SYMINFO_FLG_DEFERRED;
a87750d92895 6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents: 11827
diff changeset
   104
	}
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   105
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   106
	/*
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   107
	 * Did we account for all of the flags?
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   108
	 */
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   109
	if (flags)
3466
4cc6ca6917b5 PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents: 1618
diff changeset
   110
		(void) snprintf(&flagstr[flgndx], FLAGSZ - flgndx,
1618
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   111
		    MSG_ORIG(MSG_SYMINFO_UNKFLAG), flags);
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   112
	else
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   113
		flagstr[flgndx] = '\0';
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   114
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   115
	/*
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   116
	 * If we've bound to a dependency, determine the dynamic entry index.
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   117
	 */
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   118
	if (bndstr == needed) {
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   119
		(void) snprintf(dndxstr, NDXSZ, MSG_ORIG(MSG_FMT_INDEX),
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   120
		    sip->si_boundto);
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   121
		str = dndxstr;
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   122
	} else
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   123
		str = MSG_ORIG(MSG_STR_EMPTY);
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   124
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   125
	(void) snprintf(sndxstr, NDXSZ, MSG_ORIG(MSG_FMT_INDEX), ndx);
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   126
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   127
	dbg_print(lml, MSG_INTL(MSG_SYMINFO_ENTRY), sndxstr, flagstr, str,
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   128
	    bndstr, Elf_demangle_name(name));
8c9a4f31d225 6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
diff changeset
   129
}