17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * 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.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
215aefb655Srie
227c478bd9Sstevel@tonic-gate /*
23*4f680cc6SAli Bahrami * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <string.h>
295aefb655Srie #include <debug.h>
305aefb655Srie #include <conv.h>
317c478bd9Sstevel@tonic-gate #include "_debug.h"
325aefb655Srie #include "msg.h"
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate void
Dbg_bind_plt_summary(Lm_list * lml,Half mach,Word pltcnt21d,Word pltcnt24d,Word pltcntu32,Word pltcntu44,Word pltcntfull,Word pltcntfar)355aefb655Srie Dbg_bind_plt_summary(Lm_list *lml, Half mach, Word pltcnt21d, Word pltcnt24d,
365aefb655Srie Word pltcntu32, Word pltcntu44, Word pltcntfull, Word pltcntfar)
377c478bd9Sstevel@tonic-gate {
387c478bd9Sstevel@tonic-gate Word plttotal = pltcnt21d + pltcnt24d + pltcntu32 +
397c478bd9Sstevel@tonic-gate pltcntu44 + pltcntfull + pltcntfar;
407c478bd9Sstevel@tonic-gate
415aefb655Srie if (DBG_NOTCLASS(DBG_C_BINDINGS))
427c478bd9Sstevel@tonic-gate return;
437c478bd9Sstevel@tonic-gate
447c478bd9Sstevel@tonic-gate switch (mach) {
457c478bd9Sstevel@tonic-gate case EM_SPARC:
465aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PSUM_SPARC), EC_WORD(pltcnt21d),
477c478bd9Sstevel@tonic-gate EC_WORD(pltcnt24d), EC_WORD(pltcntfull), EC_WORD(plttotal));
487c478bd9Sstevel@tonic-gate break;
497c478bd9Sstevel@tonic-gate case EM_SPARCV9:
505aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PSUM_SPARCV9),
515aefb655Srie EC_WORD(pltcnt21d), EC_WORD(pltcnt24d), EC_WORD(pltcntu32),
525aefb655Srie EC_WORD(pltcntu44), EC_WORD(pltcntfull), EC_WORD(pltcntfar),
535aefb655Srie EC_WORD(plttotal));
547c478bd9Sstevel@tonic-gate break;
557c478bd9Sstevel@tonic-gate default:
565aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PSUM_DEFAULT),
575aefb655Srie EC_WORD(plttotal));
587c478bd9Sstevel@tonic-gate break;
597c478bd9Sstevel@tonic-gate };
607c478bd9Sstevel@tonic-gate }
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate static const char *pltbindtypes[PLT_T_NUM] = {
637c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_EMPTY), /* PLT_T_NONE */
647c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_21D), /* PLT_T_21D */
657c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_24D), /* PLT_T_24D */
667c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_U32), /* PLT_T_U32 */
677c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_U44), /* PLT_T_U44 */
687c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_FULL), /* PLT_T_FULL */
697c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_FAR) /* PLT_T_FAR */
707c478bd9Sstevel@tonic-gate };
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate #define BINFOSZ MSG_BINFO_START_SIZE + \
735aefb655Srie MSG_BINFO_DIRECT_SIZE + MSG_BINFO_SEP_SIZE + \
745aefb655Srie MSG_BINFO_INTERPOSE_SIZE + MSG_BINFO_SEP_SIZE + \
755aefb655Srie MSG_BINFO_COPYREF_SIZE + MSG_BINFO_SEP_SIZE + \
765aefb655Srie MSG_BINFO_FILTEE_SIZE + MSG_BINFO_SEP_SIZE + \
777c478bd9Sstevel@tonic-gate MSG_BINFO_PLTADDR_SIZE + \
78de777a60Sab196087 CONV_INV_BUFSIZE + MSG_BINFO_END_SIZE
797c478bd9Sstevel@tonic-gate
805aefb655Srie
817c478bd9Sstevel@tonic-gate void
Dbg_bind_global(Rt_map * flmp,Addr fabs,Off foff,Xword pltndx,Pltbindtype pbtype,Rt_map * tlmp,Addr tabs,Off toff,const char * sym,uint_t binfo)825aefb655Srie Dbg_bind_global(Rt_map *flmp, Addr fabs, Off foff, Xword pltndx,
835aefb655Srie Pltbindtype pbtype, Rt_map *tlmp, Addr tabs, Off toff,
847c478bd9Sstevel@tonic-gate const char *sym, uint_t binfo)
857c478bd9Sstevel@tonic-gate {
86*4f680cc6SAli Bahrami /*
87*4f680cc6SAli Bahrami * MSG_ORIG(MSG_BINFO_DIRECT)
88*4f680cc6SAli Bahrami * MSG_ORIG(MSG_BINFO_INTERPOSE)
89*4f680cc6SAli Bahrami * MSG_ORIG(MSG_BINFO_COPYREF)
90*4f680cc6SAli Bahrami * MSG_ORIG(MSG_BINFO_FILTEE)
91*4f680cc6SAli Bahrami * MSG_ORIG(MSG_BINFO_PLTADDR)
92*4f680cc6SAli Bahrami */
93ba4e3c84Sab196087 static char binfostr[BINFOSZ];
945aefb655Srie static Val_desc vda[] = {
95*4f680cc6SAli Bahrami { DBG_BINFO_DIRECT, MSG_BINFO_DIRECT },
96*4f680cc6SAli Bahrami { DBG_BINFO_INTERPOSE, MSG_BINFO_INTERPOSE },
97*4f680cc6SAli Bahrami { DBG_BINFO_COPYREF, MSG_BINFO_COPYREF },
98*4f680cc6SAli Bahrami { DBG_BINFO_FILTEE, MSG_BINFO_FILTEE },
99*4f680cc6SAli Bahrami { DBG_BINFO_PLTADDR, MSG_BINFO_PLTADDR },
1005aefb655Srie { 0, 0 }
1015aefb655Srie };
102ba4e3c84Sab196087 static CONV_EXPN_FIELD_ARG conv_arg = { binfostr, sizeof (binfostr),
103*4f680cc6SAli Bahrami NULL, 0, 0, MSG_ORIG(MSG_BINFO_START),
104ba4e3c84Sab196087 MSG_ORIG(MSG_BINFO_SEP), MSG_ORIG(MSG_BINFO_END) };
105ba4e3c84Sab196087
1065aefb655Srie const char *ffile = NAME(flmp);
1075aefb655Srie const char *tfile = NAME(tlmp);
1085aefb655Srie Lm_list *lml = LIST(flmp);
1097c478bd9Sstevel@tonic-gate
1105aefb655Srie if (DBG_NOTCLASS(DBG_C_BINDINGS))
1117c478bd9Sstevel@tonic-gate return;
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) {
1145aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_BASIC), ffile, tfile,
1155aefb655Srie Dbg_demangle_name(sym));
1167c478bd9Sstevel@tonic-gate return;
1177c478bd9Sstevel@tonic-gate }
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate * Determine if this binding has any associated information, such as
1215aefb655Srie * interposition, direct binding, copy-relocations, etc.
1227c478bd9Sstevel@tonic-gate */
1237c478bd9Sstevel@tonic-gate binfo &= ~DBG_BINFO_FOUND;
1247c478bd9Sstevel@tonic-gate binfo &= DBG_BINFO_MSK;
1257c478bd9Sstevel@tonic-gate if (binfo) {
126ba4e3c84Sab196087 conv_arg.oflags = conv_arg.rflags = binfo;
127*4f680cc6SAli Bahrami (void) conv_expn_field(&conv_arg, vda, 0);
128ba4e3c84Sab196087 } else {
1297c478bd9Sstevel@tonic-gate binfostr[0] = '\0';
130ba4e3c84Sab196087 }
1317c478bd9Sstevel@tonic-gate
1327c478bd9Sstevel@tonic-gate if (pltndx != (Xword)-1) {
1337c478bd9Sstevel@tonic-gate const char *pltstring;
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate if (pbtype < PLT_T_NUM)
1367c478bd9Sstevel@tonic-gate pltstring = pltbindtypes[pbtype];
1377c478bd9Sstevel@tonic-gate else
1387c478bd9Sstevel@tonic-gate pltstring = pltbindtypes[PLT_T_NONE];
1397c478bd9Sstevel@tonic-gate
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate * Called from a plt offset.
1427c478bd9Sstevel@tonic-gate */
1435aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PLT), ffile, EC_ADDR(fabs),
1445aefb655Srie EC_OFF(foff), EC_XWORD(pltndx), pltstring, tfile,
1455aefb655Srie EC_ADDR(tabs), EC_OFF(toff), Dbg_demangle_name(sym),
1465aefb655Srie binfostr);
1477c478bd9Sstevel@tonic-gate
1485aefb655Srie } else if ((fabs == 0) && (foff == 0)) {
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate * Called from a dlsym(). We're not performing a relocation,
1517c478bd9Sstevel@tonic-gate * but are handing the address of the symbol back to the user.
1527c478bd9Sstevel@tonic-gate */
1535aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_DLSYM), ffile, tfile,
1545aefb655Srie EC_ADDR(tabs), EC_OFF(toff), Dbg_demangle_name(sym),
1555aefb655Srie binfostr);
1567c478bd9Sstevel@tonic-gate } else {
1577c478bd9Sstevel@tonic-gate /*
1587c478bd9Sstevel@tonic-gate * Standard relocation.
1597c478bd9Sstevel@tonic-gate */
1605aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_DEFAULT), ffile, EC_ADDR(fabs),
1615aefb655Srie EC_OFF(foff), tfile, EC_ADDR(tabs), EC_OFF(toff),
1625aefb655Srie Dbg_demangle_name(sym), binfostr);
1637c478bd9Sstevel@tonic-gate }
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate
1667c478bd9Sstevel@tonic-gate void
Dbg_bind_reject(Rt_map * flmp,Rt_map * tlmp,const char * sym,int why)16760758829Srie Dbg_bind_reject(Rt_map *flmp, Rt_map *tlmp, const char *sym, int why)
16860758829Srie {
16960758829Srie static Msg reason[DBG_BNDREJ_NUM + 1] = {
17037ffaf83SRod Evans MSG_BNDREJ_DIRECT, /* MSG_INTL(MSG_BNDREJ_DIRECT) */
17137ffaf83SRod Evans MSG_BNDREJ_GROUP, /* MSG_INTL(MSG_BNDREJ_GROUP) */
17260758829Srie MSG_BNDREJ_SINGLE /* MSG_INTL(MSG_BNDREJ_SINGLE) */
17360758829Srie };
17460758829Srie
17560758829Srie if (DBG_NOTCLASS(DBG_C_BINDINGS))
17660758829Srie return;
17760758829Srie
17860758829Srie dbg_print(LIST(flmp), MSG_INTL(MSG_BND_REJECT), NAME(flmp), NAME(tlmp),
17960758829Srie sym, MSG_INTL(reason[why]));
18060758829Srie }
18160758829Srie
18260758829Srie void
Dbg_bind_weak(Rt_map * flmp,Addr fabs,Addr frel,const char * sym)1835aefb655Srie Dbg_bind_weak(Rt_map *flmp, Addr fabs, Addr frel, const char *sym)
1847c478bd9Sstevel@tonic-gate {
1855aefb655Srie Lm_list *lml = LIST(flmp);
1865aefb655Srie const char *ffile = NAME(flmp);
1875aefb655Srie
1885aefb655Srie if (DBG_NOTCLASS(DBG_C_BINDINGS))
1897c478bd9Sstevel@tonic-gate return;
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL())
1925aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_WEAK_1), ffile,
1935aefb655Srie Dbg_demangle_name(sym));
1947c478bd9Sstevel@tonic-gate else
1955aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_WEAK_2), ffile, EC_ADDR(fabs),
1965aefb655Srie EC_ADDR(frel), Dbg_demangle_name(sym));
1977c478bd9Sstevel@tonic-gate }
1987c478bd9Sstevel@tonic-gate
1995aefb655Srie #if defined(_ELF64)
2005aefb655Srie
2017c478bd9Sstevel@tonic-gate void
Dbg_bind_pltpad_to(Rt_map * lmp,Addr pltpad,const char * dfile,const char * sname)2025aefb655Srie Dbg_bind_pltpad_to(Rt_map *lmp, Addr pltpad, const char *dfile,
2035aefb655Srie const char *sname)
2047c478bd9Sstevel@tonic-gate {
2055aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC))
2067c478bd9Sstevel@tonic-gate return;
2077c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL())
2087c478bd9Sstevel@tonic-gate return;
2097c478bd9Sstevel@tonic-gate
2105aefb655Srie dbg_print(LIST(lmp), MSG_INTL(MSG_BND_PLTPAD_TO), EC_ADDR(pltpad),
2115aefb655Srie NAME(lmp), dfile, sname);
2127c478bd9Sstevel@tonic-gate }
2135aefb655Srie
2145aefb655Srie void
Dbg_bind_pltpad_from(Rt_map * lmp,Addr pltpad,const char * sname)2155aefb655Srie Dbg_bind_pltpad_from(Rt_map *lmp, Addr pltpad, const char *sname)
2165aefb655Srie {
2175aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC))
2185aefb655Srie return;
2195aefb655Srie if (DBG_NOTDETAIL())
2205aefb655Srie return;
2215aefb655Srie
2225aefb655Srie dbg_print(LIST(lmp), MSG_INTL(MSG_BND_PLTPAD_FROM), EC_ADDR(pltpad),
2235aefb655Srie NAME(lmp), sname);
2245aefb655Srie }
2255aefb655Srie
2265aefb655Srie #endif
227