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 5*5aefb655Srie * Common Development and Distribution License (the "License"). 6*5aefb655Srie * 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 */ 21*5aefb655Srie 227c478bd9Sstevel@tonic-gate /* 23*5aefb655Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <string.h> 31*5aefb655Srie #include <debug.h> 32*5aefb655Srie #include <conv.h> 337c478bd9Sstevel@tonic-gate #include "_debug.h" 34*5aefb655Srie #include "msg.h" 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate void 37*5aefb655Srie Dbg_bind_plt_summary(Lm_list *lml, Half mach, Word pltcnt21d, Word pltcnt24d, 38*5aefb655Srie Word pltcntu32, Word pltcntu44, Word pltcntfull, Word pltcntfar) 397c478bd9Sstevel@tonic-gate { 407c478bd9Sstevel@tonic-gate Word plttotal = pltcnt21d + pltcnt24d + pltcntu32 + 417c478bd9Sstevel@tonic-gate pltcntu44 + pltcntfull + pltcntfar; 427c478bd9Sstevel@tonic-gate 43*5aefb655Srie if (DBG_NOTCLASS(DBG_C_BINDINGS)) 447c478bd9Sstevel@tonic-gate return; 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate switch (mach) { 477c478bd9Sstevel@tonic-gate case EM_SPARC: 48*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PSUM_SPARC), EC_WORD(pltcnt21d), 497c478bd9Sstevel@tonic-gate EC_WORD(pltcnt24d), EC_WORD(pltcntfull), EC_WORD(plttotal)); 507c478bd9Sstevel@tonic-gate break; 517c478bd9Sstevel@tonic-gate case EM_SPARCV9: 52*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PSUM_SPARCV9), 53*5aefb655Srie EC_WORD(pltcnt21d), EC_WORD(pltcnt24d), EC_WORD(pltcntu32), 54*5aefb655Srie EC_WORD(pltcntu44), EC_WORD(pltcntfull), EC_WORD(pltcntfar), 55*5aefb655Srie EC_WORD(plttotal)); 567c478bd9Sstevel@tonic-gate break; 577c478bd9Sstevel@tonic-gate default: 58*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PSUM_DEFAULT), 59*5aefb655Srie EC_WORD(plttotal)); 607c478bd9Sstevel@tonic-gate break; 617c478bd9Sstevel@tonic-gate }; 627c478bd9Sstevel@tonic-gate } 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate static const char *pltbindtypes[PLT_T_NUM] = { 657c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_STR_EMPTY), /* PLT_T_NONE */ 667c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_21D), /* PLT_T_21D */ 677c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_24D), /* PLT_T_24D */ 687c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_U32), /* PLT_T_U32 */ 697c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_U44), /* PLT_T_U44 */ 707c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_FULL), /* PLT_T_FULL */ 717c478bd9Sstevel@tonic-gate MSG_ORIG(MSG_PLT_FAR) /* PLT_T_FAR */ 727c478bd9Sstevel@tonic-gate }; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define BINFOSZ MSG_BINFO_START_SIZE + \ 75*5aefb655Srie MSG_BINFO_DIRECT_SIZE + MSG_BINFO_SEP_SIZE + \ 76*5aefb655Srie MSG_BINFO_INTERPOSE_SIZE + MSG_BINFO_SEP_SIZE + \ 77*5aefb655Srie MSG_BINFO_COPYREF_SIZE + MSG_BINFO_SEP_SIZE + \ 78*5aefb655Srie MSG_BINFO_FILTEE_SIZE + MSG_BINFO_SEP_SIZE + \ 797c478bd9Sstevel@tonic-gate MSG_BINFO_PLTADDR_SIZE + \ 80*5aefb655Srie CONV_INV_STRSIZE + MSG_BINFO_END_SIZE 81*5aefb655Srie 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate void 84*5aefb655Srie Dbg_bind_global(Rt_map *flmp, Addr fabs, Off foff, Xword pltndx, 85*5aefb655Srie Pltbindtype pbtype, Rt_map *tlmp, Addr tabs, Off toff, 867c478bd9Sstevel@tonic-gate const char *sym, uint_t binfo) 877c478bd9Sstevel@tonic-gate { 88*5aefb655Srie static Val_desc vda[] = { 89*5aefb655Srie { DBG_BINFO_DIRECT, MSG_ORIG(MSG_BINFO_DIRECT) }, 90*5aefb655Srie { DBG_BINFO_INTERPOSE, MSG_ORIG(MSG_BINFO_INTERPOSE) }, 91*5aefb655Srie { DBG_BINFO_COPYREF, MSG_ORIG(MSG_BINFO_COPYREF) }, 92*5aefb655Srie { DBG_BINFO_FILTEE, MSG_ORIG(MSG_BINFO_FILTEE) }, 93*5aefb655Srie { DBG_BINFO_PLTADDR, MSG_ORIG(MSG_BINFO_PLTADDR) }, 94*5aefb655Srie { 0, 0 } 95*5aefb655Srie }; 967c478bd9Sstevel@tonic-gate char binfostr[BINFOSZ]; 97*5aefb655Srie const char *ffile = NAME(flmp); 98*5aefb655Srie const char *tfile = NAME(tlmp); 99*5aefb655Srie Lm_list *lml = LIST(flmp); 1007c478bd9Sstevel@tonic-gate 101*5aefb655Srie if (DBG_NOTCLASS(DBG_C_BINDINGS)) 1027c478bd9Sstevel@tonic-gate return; 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) { 105*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_BASIC), ffile, tfile, 106*5aefb655Srie Dbg_demangle_name(sym)); 1077c478bd9Sstevel@tonic-gate return; 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* 1117c478bd9Sstevel@tonic-gate * Determine if this binding has any associated information, such as 112*5aefb655Srie * interposition, direct binding, copy-relocations, etc. 1137c478bd9Sstevel@tonic-gate */ 1147c478bd9Sstevel@tonic-gate binfo &= ~DBG_BINFO_FOUND; 1157c478bd9Sstevel@tonic-gate binfo &= DBG_BINFO_MSK; 1167c478bd9Sstevel@tonic-gate if (binfo) { 117*5aefb655Srie (void) strlcpy(binfostr, MSG_ORIG(MSG_BINFO_START), BINFOSZ); 118*5aefb655Srie 119*5aefb655Srie if (conv_expn_field(binfostr, BINFOSZ, vda, binfo, binfo, 120*5aefb655Srie MSG_ORIG(MSG_BINFO_SEP), 0)) 121*5aefb655Srie (void) strcat(binfostr, MSG_ORIG(MSG_BINFO_END)); 1227c478bd9Sstevel@tonic-gate } else 1237c478bd9Sstevel@tonic-gate binfostr[0] = '\0'; 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate if (pltndx != (Xword)-1) { 1267c478bd9Sstevel@tonic-gate const char *pltstring; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate if (pbtype < PLT_T_NUM) 1297c478bd9Sstevel@tonic-gate pltstring = pltbindtypes[pbtype]; 1307c478bd9Sstevel@tonic-gate else 1317c478bd9Sstevel@tonic-gate pltstring = pltbindtypes[PLT_T_NONE]; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate /* 1347c478bd9Sstevel@tonic-gate * Called from a plt offset. 1357c478bd9Sstevel@tonic-gate */ 136*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_PLT), ffile, EC_ADDR(fabs), 137*5aefb655Srie EC_OFF(foff), EC_XWORD(pltndx), pltstring, tfile, 138*5aefb655Srie EC_ADDR(tabs), EC_OFF(toff), Dbg_demangle_name(sym), 139*5aefb655Srie binfostr); 1407c478bd9Sstevel@tonic-gate 141*5aefb655Srie } else if ((fabs == 0) && (foff == 0)) { 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * Called from a dlsym(). We're not performing a relocation, 1447c478bd9Sstevel@tonic-gate * but are handing the address of the symbol back to the user. 1457c478bd9Sstevel@tonic-gate */ 146*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_DLSYM), ffile, tfile, 147*5aefb655Srie EC_ADDR(tabs), EC_OFF(toff), Dbg_demangle_name(sym), 148*5aefb655Srie binfostr); 1497c478bd9Sstevel@tonic-gate } else { 1507c478bd9Sstevel@tonic-gate /* 1517c478bd9Sstevel@tonic-gate * Standard relocation. 1527c478bd9Sstevel@tonic-gate */ 153*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_DEFAULT), ffile, EC_ADDR(fabs), 154*5aefb655Srie EC_OFF(foff), tfile, EC_ADDR(tabs), EC_OFF(toff), 155*5aefb655Srie Dbg_demangle_name(sym), binfostr); 1567c478bd9Sstevel@tonic-gate } 1577c478bd9Sstevel@tonic-gate } 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate void 160*5aefb655Srie Dbg_bind_weak(Rt_map *flmp, Addr fabs, Addr frel, const char *sym) 1617c478bd9Sstevel@tonic-gate { 162*5aefb655Srie Lm_list *lml = LIST(flmp); 163*5aefb655Srie const char *ffile = NAME(flmp); 164*5aefb655Srie 165*5aefb655Srie if (DBG_NOTCLASS(DBG_C_BINDINGS)) 1667c478bd9Sstevel@tonic-gate return; 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 169*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_WEAK_1), ffile, 170*5aefb655Srie Dbg_demangle_name(sym)); 1717c478bd9Sstevel@tonic-gate else 172*5aefb655Srie dbg_print(lml, MSG_INTL(MSG_BND_WEAK_2), ffile, EC_ADDR(fabs), 173*5aefb655Srie EC_ADDR(frel), Dbg_demangle_name(sym)); 174*5aefb655Srie } 175*5aefb655Srie 176*5aefb655Srie #if defined(_ELF64) 177*5aefb655Srie 178*5aefb655Srie void 179*5aefb655Srie Dbg_bind_pltpad_to(Rt_map *lmp, Addr pltpad, const char *dfile, 180*5aefb655Srie const char *sname) 181*5aefb655Srie { 182*5aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 183*5aefb655Srie return; 184*5aefb655Srie if (DBG_NOTDETAIL()) 185*5aefb655Srie return; 186*5aefb655Srie 187*5aefb655Srie dbg_print(LIST(lmp), MSG_INTL(MSG_BND_PLTPAD_TO), EC_ADDR(pltpad), 188*5aefb655Srie NAME(lmp), dfile, sname); 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate void 192*5aefb655Srie Dbg_bind_pltpad_from(Rt_map *lmp, Addr pltpad, const char *sname) 1937c478bd9Sstevel@tonic-gate { 194*5aefb655Srie if (DBG_NOTCLASS(DBG_C_RELOC)) 1957c478bd9Sstevel@tonic-gate return; 1967c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1977c478bd9Sstevel@tonic-gate return; 1987c478bd9Sstevel@tonic-gate 199*5aefb655Srie dbg_print(LIST(lmp), MSG_INTL(MSG_BND_PLTPAD_FROM), EC_ADDR(pltpad), 200*5aefb655Srie NAME(lmp), sname); 2017c478bd9Sstevel@tonic-gate } 202*5aefb655Srie 203*5aefb655Srie #endif 204