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*2020b2b6SRod Evans * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #include <dlfcn.h> 277c478bd9Sstevel@tonic-gate #include <stdio.h> 287c478bd9Sstevel@tonic-gate #include "_debug.h" 297c478bd9Sstevel@tonic-gate #include "msg.h" 307c478bd9Sstevel@tonic-gate #include "libld.h" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate void 33*2020b2b6SRod Evans Dbg_audit_lib(Rt_map *clmp, const char *lib, int type) 347c478bd9Sstevel@tonic-gate { 35*2020b2b6SRod Evans Lm_list *clml = LIST(clmp); 36*2020b2b6SRod Evans const char *str; 37*2020b2b6SRod Evans 385aefb655Srie if (DBG_NOTCLASS(DBG_C_AUDITING)) 397c478bd9Sstevel@tonic-gate return; 407c478bd9Sstevel@tonic-gate 41*2020b2b6SRod Evans Dbg_util_nl(clml, DBG_NL_STD); 42*2020b2b6SRod Evans switch (type) { 43*2020b2b6SRod Evans case DBG_AUD_PRELOAD: 44*2020b2b6SRod Evans str = MSG_ORIG(MSG_AUD_PRELOAD); 45*2020b2b6SRod Evans break; 46*2020b2b6SRod Evans case DBG_AUD_GLOBAL: 47*2020b2b6SRod Evans str = MSG_ORIG(MSG_AUD_GLOBAL); 48*2020b2b6SRod Evans break; 49*2020b2b6SRod Evans case DBG_AUD_LOCAL: 50*2020b2b6SRod Evans /* FALLTHROUGH */ 51*2020b2b6SRod Evans default: 52*2020b2b6SRod Evans str = MSG_ORIG(MSG_STR_EMPTY); 537c478bd9Sstevel@tonic-gate } 547c478bd9Sstevel@tonic-gate 55*2020b2b6SRod Evans dbg_print(clml, MSG_INTL(MSG_AUD_LIB), lib, NAME(clmp), str); 567c478bd9Sstevel@tonic-gate } 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate void 595aefb655Srie Dbg_audit_interface(Lm_list *lml, const char *lib, const char *interface) 607c478bd9Sstevel@tonic-gate { 615aefb655Srie if (DBG_NOTCLASS(DBG_C_AUDITING)) 627c478bd9Sstevel@tonic-gate return; 637c478bd9Sstevel@tonic-gate 645aefb655Srie dbg_print(lml, MSG_INTL(MSG_AUD_INTERFACE), lib, interface); 657c478bd9Sstevel@tonic-gate } 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate void 68*2020b2b6SRod Evans Dbg_audit_version(Lm_list *lml, const char *lib, uint_t overs, uint_t nvers) 69*2020b2b6SRod Evans { 70*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 71*2020b2b6SRod Evans return; 72*2020b2b6SRod Evans 73*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_VERSION), lib, overs, nvers); 74*2020b2b6SRod Evans } 75*2020b2b6SRod Evans 76*2020b2b6SRod Evans void 77*2020b2b6SRod Evans Dbg_audit_activity(Lm_list *lml, const char *lib, const char *obj, uint_t flags) 78*2020b2b6SRod Evans { 79*2020b2b6SRod Evans Conv_inv_buf_t inv_buf; 80*2020b2b6SRod Evans 81*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 82*2020b2b6SRod Evans return; 83*2020b2b6SRod Evans 84*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 85*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_ACTIVITY), lib, obj, 86*2020b2b6SRod Evans conv_la_activity(flags, CONV_FMT_ALT_DEFAULT, &inv_buf)); 87*2020b2b6SRod Evans } 88*2020b2b6SRod Evans 89*2020b2b6SRod Evans void 90*2020b2b6SRod Evans Dbg_audit_preinit(Lm_list *lml, const char *lib, const char *obj) 917c478bd9Sstevel@tonic-gate { 925aefb655Srie if (DBG_NOTCLASS(DBG_C_AUDITING)) 937c478bd9Sstevel@tonic-gate return; 947c478bd9Sstevel@tonic-gate 955aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 96*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_PREINIT), lib, obj); 977c478bd9Sstevel@tonic-gate } 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate void 100*2020b2b6SRod Evans Dbg_audit_objsearch(Lm_list *lml, int call, const char *lib, 101*2020b2b6SRod Evans const char *oobj, uint_t flags, const char *nobj) 1027c478bd9Sstevel@tonic-gate { 103*2020b2b6SRod Evans Conv_la_search_buf_t la_search_buf; 1047c478bd9Sstevel@tonic-gate 1055aefb655Srie if (DBG_NOTCLASS(DBG_C_AUDITING)) 1067c478bd9Sstevel@tonic-gate return; 107*2020b2b6SRod Evans 108*2020b2b6SRod Evans if (call == DBG_AUD_CALL) { 109*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 110*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJSEARCH), lib, oobj, 111*2020b2b6SRod Evans conv_la_search(flags, &la_search_buf)); 112*2020b2b6SRod Evans } else { 113*2020b2b6SRod Evans if (nobj) 114*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJSEARCH_R), lib, 115*2020b2b6SRod Evans oobj, nobj); 116*2020b2b6SRod Evans else 117*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJSEARCH_S), lib, 118*2020b2b6SRod Evans oobj); 119*2020b2b6SRod Evans } 120*2020b2b6SRod Evans } 121*2020b2b6SRod Evans 122*2020b2b6SRod Evans void 123*2020b2b6SRod Evans Dbg_audit_objfilter(Lm_list *lml, int call, const char *lib, 124*2020b2b6SRod Evans const char *filter, const char *filtee, const char *ref) 125*2020b2b6SRod Evans { 126*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 1277c478bd9Sstevel@tonic-gate return; 1287c478bd9Sstevel@tonic-gate 129*2020b2b6SRod Evans if (call == DBG_AUD_CALL) { 130*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 131*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJFILTER), lib, filter, 132*2020b2b6SRod Evans filtee, ref); 133*2020b2b6SRod Evans } else 134*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJFILTER_R), lib, filter); 135*2020b2b6SRod Evans } 1367c478bd9Sstevel@tonic-gate 137*2020b2b6SRod Evans void 138*2020b2b6SRod Evans Dbg_audit_objopen(Lm_list *lml, int call, const char *lib, const char *obj, 139*2020b2b6SRod Evans uint_t flags, Boolean ignore) 140*2020b2b6SRod Evans { 141*2020b2b6SRod Evans Conv_la_bind_buf_t la_bind_buf; 142*2020b2b6SRod Evans 143*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 144*2020b2b6SRod Evans return; 145*2020b2b6SRod Evans 146*2020b2b6SRod Evans if (call == DBG_AUD_CALL) { 147*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 148*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJOPEN), lib, obj); 149*2020b2b6SRod Evans } else { 150*2020b2b6SRod Evans if (ignore) 151*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJOPEN_RI), lib, obj, 152*2020b2b6SRod Evans conv_la_bind(flags, &la_bind_buf)); 153*2020b2b6SRod Evans else 154*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJOPEN_R), lib, obj, 155*2020b2b6SRod Evans conv_la_bind(flags, &la_bind_buf)); 156*2020b2b6SRod Evans } 157*2020b2b6SRod Evans } 158*2020b2b6SRod Evans 159*2020b2b6SRod Evans void 160*2020b2b6SRod Evans Dbg_audit_objclose(Lm_list *lml, const char *lib, const char *obj) 161*2020b2b6SRod Evans { 162*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 163*2020b2b6SRod Evans return; 164*2020b2b6SRod Evans 165*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 166*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_OBJCLOSE), lib, obj); 167*2020b2b6SRod Evans } 168*2020b2b6SRod Evans 169*2020b2b6SRod Evans void 170*2020b2b6SRod Evans Dbg_audit_symbind(Lm_list *lml, int call, const char *lib, const char *name, 171*2020b2b6SRod Evans Addr value, uint_t flags) 172*2020b2b6SRod Evans { 173*2020b2b6SRod Evans Conv_la_symbind_buf_t la_symbind_buf; 174*2020b2b6SRod Evans 175*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 176*2020b2b6SRod Evans return; 177*2020b2b6SRod Evans 178*2020b2b6SRod Evans if (call == DBG_AUD_CALL) { 179*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 180*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_SYMBIND), lib, name, 181*2020b2b6SRod Evans EC_XWORD(value), conv_la_symbind(flags, &la_symbind_buf)); 182*2020b2b6SRod Evans } else { 183*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_SYMBIND_R), lib, name, 184*2020b2b6SRod Evans EC_XWORD(value), conv_la_symbind(flags, &la_symbind_buf)); 185*2020b2b6SRod Evans } 186*2020b2b6SRod Evans } 187*2020b2b6SRod Evans 188*2020b2b6SRod Evans void 189*2020b2b6SRod Evans Dbg_audit_pltenter(Lm_list *lml, int call, const char *lib, const char *name, 190*2020b2b6SRod Evans Addr value) 191*2020b2b6SRod Evans { 192*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 193*2020b2b6SRod Evans return; 194*2020b2b6SRod Evans 195*2020b2b6SRod Evans if (call == DBG_AUD_CALL) { 196*2020b2b6SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 197*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_PLTENTER), lib, name, 198*2020b2b6SRod Evans EC_XWORD(value)); 199*2020b2b6SRod Evans } else { 200*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_PLTENTER_R), lib, name, 201*2020b2b6SRod Evans EC_XWORD(value)); 202*2020b2b6SRod Evans } 203*2020b2b6SRod Evans } 204*2020b2b6SRod Evans 205*2020b2b6SRod Evans void 206*2020b2b6SRod Evans Dbg_audit_pltexit(Lm_list *lml, const char *lib, const char *name) 207*2020b2b6SRod Evans { 208*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_AUDITING)) 209*2020b2b6SRod Evans return; 210*2020b2b6SRod Evans 211*2020b2b6SRod Evans dbg_print(lml, MSG_INTL(MSG_AUD_PLTEXIT), lib, name); 2127c478bd9Sstevel@tonic-gate } 213c75e1b9dSrie 214c75e1b9dSrie void 215c75e1b9dSrie Dbg_audit_skip(Lm_list *lml, const char *name, const char *lmid) 216c75e1b9dSrie { 217c75e1b9dSrie if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES)) 218c75e1b9dSrie return; 219c75e1b9dSrie 220c75e1b9dSrie dbg_print(lml, MSG_INTL(MSG_AUD_SKIP), name, lmid); 221c75e1b9dSrie } 2227247f888Srie 2237247f888Srie void 2247247f888Srie Dbg_audit_terminate(Lm_list *lml, const char *name) 2257247f888Srie { 226*2020b2b6SRod Evans if (DBG_NOTCLASS(DBG_C_FILES)) 2277247f888Srie return; 2287247f888Srie 2297247f888Srie dbg_print(lml, MSG_INTL(MSG_AUD_TERM), name); 2307247f888Srie } 2317247f888Srie 2327247f888Srie void 2337247f888Srie Dbg_audit_ignore(Rt_map *lmp) 2347247f888Srie { 2357247f888Srie if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES)) 2367247f888Srie return; 2377247f888Srie 2387247f888Srie dbg_print(LIST(lmp), MSG_INTL(MSG_AUD_IGNORE), NAME(lmp)); 2397247f888Srie } 240