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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 23*159cf8a6Swesolows * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*159cf8a6Swesolows * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _RTLD_DB_H 287c478bd9Sstevel@tonic-gate #define _RTLD_DB_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 347c478bd9Sstevel@tonic-gate extern "C" { 357c478bd9Sstevel@tonic-gate #endif 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #include <sys/lwp.h> 397c478bd9Sstevel@tonic-gate #include <link.h> 407c478bd9Sstevel@tonic-gate #include <proc_service.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * librtld_db interface versions 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate #define RD_VERSION1 1 477c478bd9Sstevel@tonic-gate #define RD_VERSION2 2 487c478bd9Sstevel@tonic-gate #define RD_VERSION3 3 497c478bd9Sstevel@tonic-gate #define RD_VERSION4 4 507c478bd9Sstevel@tonic-gate #define RD_VERSION RD_VERSION4 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate typedef enum { 537c478bd9Sstevel@tonic-gate RD_ERR, /* generic */ 547c478bd9Sstevel@tonic-gate RD_OK, /* generic "call" succeeded */ 557c478bd9Sstevel@tonic-gate RD_NOCAPAB, /* capability not available */ 567c478bd9Sstevel@tonic-gate RD_DBERR, /* import service failed */ 577c478bd9Sstevel@tonic-gate RD_NOBASE, /* 5.x: aux tag AT_BASE not found */ 587c478bd9Sstevel@tonic-gate RD_NODYNAM, /* symbol 'DYNAMIC' not found */ 597c478bd9Sstevel@tonic-gate RD_NOMAPS /* link-maps are not yet available */ 607c478bd9Sstevel@tonic-gate } rd_err_e; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* 647c478bd9Sstevel@tonic-gate * ways that the event notification can take place: 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate typedef enum { 677c478bd9Sstevel@tonic-gate RD_NOTIFY_BPT, /* set break-point at address */ 687c478bd9Sstevel@tonic-gate RD_NOTIFY_AUTOBPT, /* 4.x compat. not used in 5.x */ 697c478bd9Sstevel@tonic-gate RD_NOTIFY_SYSCALL /* watch for syscall */ 707c478bd9Sstevel@tonic-gate } rd_notify_e; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * information on ways that the event notification can take place: 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate typedef struct rd_notify { 767c478bd9Sstevel@tonic-gate rd_notify_e type; 777c478bd9Sstevel@tonic-gate union { 787c478bd9Sstevel@tonic-gate psaddr_t bptaddr; /* break point address */ 797c478bd9Sstevel@tonic-gate long syscallno; /* system call id */ 807c478bd9Sstevel@tonic-gate } u; 817c478bd9Sstevel@tonic-gate } rd_notify_t; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * information about event instance: 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate typedef enum { 877c478bd9Sstevel@tonic-gate RD_NOSTATE = 0, /* no state information */ 887c478bd9Sstevel@tonic-gate RD_CONSISTENT, /* link-maps are stable */ 897c478bd9Sstevel@tonic-gate RD_ADD, /* currently adding object to link-maps */ 907c478bd9Sstevel@tonic-gate RD_DELETE /* currently deleteing object from link-maps */ 917c478bd9Sstevel@tonic-gate } rd_state_e; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate typedef struct rd_event_msg { 947c478bd9Sstevel@tonic-gate rd_event_e type; 957c478bd9Sstevel@tonic-gate union { 967c478bd9Sstevel@tonic-gate rd_state_e state; /* for DLACTIVITY */ 977c478bd9Sstevel@tonic-gate } u; 987c478bd9Sstevel@tonic-gate } rd_event_msg_t; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * iteration over load objects 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate typedef struct rd_loadobj { 1057c478bd9Sstevel@tonic-gate psaddr_t rl_nameaddr; /* address of the name in user space */ 1067c478bd9Sstevel@tonic-gate unsigned rl_flags; 1077c478bd9Sstevel@tonic-gate psaddr_t rl_base; /* base of address of code */ 1087c478bd9Sstevel@tonic-gate psaddr_t rl_data_base; /* base of address of data */ 1097c478bd9Sstevel@tonic-gate Lmid_t rl_lmident; /* ident of link map */ 1107c478bd9Sstevel@tonic-gate psaddr_t rl_refnameaddr; /* reference name of filter in user */ 1117c478bd9Sstevel@tonic-gate /* space. If non null object is a */ 1127c478bd9Sstevel@tonic-gate /* filter. */ 1137c478bd9Sstevel@tonic-gate psaddr_t rl_plt_base; /* These fields are present for 4.x */ 1147c478bd9Sstevel@tonic-gate unsigned rl_plt_size; /* compatibility and are not */ 1157c478bd9Sstevel@tonic-gate /* currently used in SunOS5.x */ 1167c478bd9Sstevel@tonic-gate psaddr_t rl_bend; /* end of image (text+data+bss) */ 1177c478bd9Sstevel@tonic-gate psaddr_t rl_padstart; /* start of padding */ 1187c478bd9Sstevel@tonic-gate psaddr_t rl_padend; /* end of image after padding */ 1197c478bd9Sstevel@tonic-gate psaddr_t rl_dynamic; /* points to the DYNAMIC section */ 1207c478bd9Sstevel@tonic-gate /* in the target process */ 1217c478bd9Sstevel@tonic-gate unsigned long rl_tlsmodid; /* module ID for TLS references */ 1227c478bd9Sstevel@tonic-gate } rd_loadobj_t; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Values for rl_flags 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate #define RD_FLG_MEM_OBJECT 0x0001 /* Identifies this object as */ 1287c478bd9Sstevel@tonic-gate /* originating from a relocatable */ 1297c478bd9Sstevel@tonic-gate /* module which was dynamically */ 1307c478bd9Sstevel@tonic-gate /* loaded */ 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate typedef struct rd_agent rd_agent_t; 1347c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1357c478bd9Sstevel@tonic-gate typedef int rl_iter_f(const rd_loadobj_t *, void *); 1367c478bd9Sstevel@tonic-gate #else 1377c478bd9Sstevel@tonic-gate typedef int rl_iter_f(); 1387c478bd9Sstevel@tonic-gate #endif 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate /* 1427c478bd9Sstevel@tonic-gate * PLT skipping 1437c478bd9Sstevel@tonic-gate */ 1447c478bd9Sstevel@tonic-gate typedef enum { 1457c478bd9Sstevel@tonic-gate RD_RESOLVE_NONE, /* don't do anything special */ 1467c478bd9Sstevel@tonic-gate RD_RESOLVE_STEP, /* step 'pi_nstep' instructions */ 1477c478bd9Sstevel@tonic-gate RD_RESOLVE_TARGET, /* resolved target is in 'pi_target' */ 1487c478bd9Sstevel@tonic-gate RD_RESOLVE_TARGET_STEP /* put a bpt on target, then step nstep times */ 1497c478bd9Sstevel@tonic-gate } rd_skip_e; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate typedef struct rd_plt_info { 1537c478bd9Sstevel@tonic-gate rd_skip_e pi_skip_method; 1547c478bd9Sstevel@tonic-gate long pi_nstep; 1557c478bd9Sstevel@tonic-gate psaddr_t pi_target; 1567c478bd9Sstevel@tonic-gate psaddr_t pi_baddr; 1577c478bd9Sstevel@tonic-gate unsigned int pi_flags; 1587c478bd9Sstevel@tonic-gate } rd_plt_info_t; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * Values for pi_flags 1627c478bd9Sstevel@tonic-gate */ 1637c478bd9Sstevel@tonic-gate #define RD_FLG_PI_PLTBOUND 0x0001 /* Indicates that the PLT */ 1647c478bd9Sstevel@tonic-gate /* has been bound - and that */ 165*159cf8a6Swesolows /* pi_baddr will contain its */ 1667c478bd9Sstevel@tonic-gate /* destination address */ 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate struct ps_prochandle; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate /* 1717c478bd9Sstevel@tonic-gate * librtld_db.so entry points 1727c478bd9Sstevel@tonic-gate */ 1737c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1747c478bd9Sstevel@tonic-gate extern void rd_delete(rd_agent_t *); 1757c478bd9Sstevel@tonic-gate extern char *rd_errstr(rd_err_e rderr); 1767c478bd9Sstevel@tonic-gate extern rd_err_e rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *); 1777c478bd9Sstevel@tonic-gate extern rd_err_e rd_event_enable(rd_agent_t *, int); 1787c478bd9Sstevel@tonic-gate extern rd_err_e rd_event_getmsg(rd_agent_t *, rd_event_msg_t *); 1797c478bd9Sstevel@tonic-gate extern rd_err_e rd_init(int); 1807c478bd9Sstevel@tonic-gate extern rd_err_e rd_loadobj_iter(rd_agent_t *, rl_iter_f *, 1817c478bd9Sstevel@tonic-gate void *); 1827c478bd9Sstevel@tonic-gate extern void rd_log(const int); 1837c478bd9Sstevel@tonic-gate extern rd_agent_t *rd_new(struct ps_prochandle *); 1847c478bd9Sstevel@tonic-gate extern rd_err_e rd_objpad_enable(struct rd_agent *, size_t); 1857c478bd9Sstevel@tonic-gate extern rd_err_e rd_plt_resolution(rd_agent_t *, psaddr_t, lwpid_t, 1867c478bd9Sstevel@tonic-gate psaddr_t, rd_plt_info_t *); 1877c478bd9Sstevel@tonic-gate extern rd_err_e rd_reset(struct rd_agent *); 1887c478bd9Sstevel@tonic-gate #else 1897c478bd9Sstevel@tonic-gate extern void rd_delete(); 1907c478bd9Sstevel@tonic-gate extern char *rd_errstr(); 1917c478bd9Sstevel@tonic-gate extern rd_err_e rd_event_addr(); 1927c478bd9Sstevel@tonic-gate extern rd_err_e rd_event_enable(); 1937c478bd9Sstevel@tonic-gate extern rd_err_e rd_event_getmsg(); 1947c478bd9Sstevel@tonic-gate extern rd_err_e rd_init(); 1957c478bd9Sstevel@tonic-gate extern rd_err_e rd_loadobj_iter(); 1967c478bd9Sstevel@tonic-gate extern void rd_log(); 1977c478bd9Sstevel@tonic-gate extern rd_agent_t *rd_new(); 1987c478bd9Sstevel@tonic-gate extern rd_err_e rd_objpad_enable(); 1997c478bd9Sstevel@tonic-gate extern rd_err_e rd_plt_resolution(); 2007c478bd9Sstevel@tonic-gate extern rd_err_e rd_reset(); 2017c478bd9Sstevel@tonic-gate #endif 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2047c478bd9Sstevel@tonic-gate } 2057c478bd9Sstevel@tonic-gate #endif 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate #endif /* _RTLD_DB_H */ 208