1 1.1 christos /* 2 1.1 christos * Copyright (c) 2010 The FreeBSD Foundation 3 1.1 christos * All rights reserved. 4 1.1 christos * 5 1.1 christos * This software was developed by Rui Paulo under sponsorship from the 6 1.1 christos * FreeBSD Foundation. 7 1.1 christos * 8 1.1 christos * Redistribution and use in source and binary forms, with or without 9 1.1 christos * modification, are permitted provided that the following conditions 10 1.1 christos * are met: 11 1.1 christos * 1. Redistributions of source code must retain the above copyright 12 1.1 christos * notice, this list of conditions and the following disclaimer. 13 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 christos * notice, this list of conditions and the following disclaimer in the 15 1.1 christos * documentation and/or other materials provided with the distribution. 16 1.1 christos * 17 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 1.1 christos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 1.1 christos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 1.1 christos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 1.1 christos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 1.1 christos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 1.1 christos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 1.1 christos * SUCH DAMAGE. 28 1.1 christos * 29 1.1 christos * $FreeBSD: head/lib/librtld_db/rtld_db.h 265629 2014-05-08 03:26:25Z markj $ 30 1.1 christos */ 31 1.1 christos 32 1.1 christos #ifndef _RTLD_DB_H_ 33 1.1 christos #define _RTLD_DB_H_ 34 1.1 christos 35 1.1 christos #include <sys/param.h> 36 1.1 christos #include <sys/cdefs.h> 37 1.1 christos #include <sys/types.h> 38 1.1 christos 39 1.1 christos 40 1.1 christos #define RD_VERSION 1 41 1.1 christos 42 1.1 christos typedef enum { 43 1.1 christos RD_OK, 44 1.1 christos RD_ERR, 45 1.1 christos RD_DBERR, 46 1.1 christos RD_NOCAPAB, 47 1.1 christos RD_NODYNAM, 48 1.1 christos RD_NOBASE, 49 1.1 christos RD_NOMAPS 50 1.1 christos } rd_err_e; 51 1.1 christos 52 1.1 christos typedef struct rd_agent { 53 1.1 christos struct proc_handle *rda_php; 54 1.1 christos uintptr_t rda_dlactivity_addr; 55 1.1 christos uintptr_t rda_preinit_addr; 56 1.1 christos uintptr_t rda_postinit_addr; 57 1.1 christos } rd_agent_t; 58 1.1 christos 59 1.1 christos typedef struct rd_loadobj { 60 1.1 christos uintptr_t rdl_saddr; /* start address */ 61 1.1 christos uintptr_t rdl_eaddr; /* end address */ 62 1.1 christos uint32_t rdl_offset; 63 1.1 christos uint8_t rdl_prot; 64 1.1 christos #define RD_RDL_R 0x01 65 1.1 christos #define RD_RDL_W 0x02 66 1.1 christos #define RD_RDL_X 0x04 67 1.1 christos enum { 68 1.1 christos RDL_TYPE_NONE = 0, 69 1.1 christos RDL_TYPE_DEF, 70 1.1 christos RDL_TYPE_VNODE, 71 1.1 christos RDL_TYPE_SWAP, 72 1.1 christos RDL_TYPE_DEV, 73 1.1 christos /* XXX some types missing */ 74 1.1 christos RDL_TYPE_UNKNOWN = 255 75 1.1 christos } rdl_type; 76 1.2 roy char rdl_path[PATH_MAX]; 77 1.1 christos } rd_loadobj_t; 78 1.1 christos 79 1.1 christos typedef enum { 80 1.1 christos RD_NONE = 0, 81 1.1 christos RD_PREINIT, 82 1.1 christos RD_POSTINIT, 83 1.1 christos RD_DLACTIVITY 84 1.1 christos } rd_event_e; 85 1.1 christos 86 1.1 christos typedef enum { 87 1.1 christos RD_NOTIFY_BPT, 88 1.1 christos RD_NOTIFY_AUTOBPT, 89 1.1 christos RD_NOTIFY_SYSCALL 90 1.1 christos } rd_notify_e; 91 1.1 christos 92 1.1 christos typedef struct rd_notify { 93 1.1 christos rd_notify_e type; 94 1.1 christos union { 95 1.1 christos uintptr_t bptaddr; 96 1.1 christos long syscallno; 97 1.1 christos } u; 98 1.1 christos } rd_notify_t; 99 1.1 christos 100 1.1 christos typedef enum { 101 1.1 christos RD_NOSTATE = 0, 102 1.1 christos RD_CONSISTENT, 103 1.1 christos RD_ADD, 104 1.1 christos RD_DELETE 105 1.1 christos } rd_state_e; 106 1.1 christos 107 1.1 christos typedef struct rd_event_msg { 108 1.1 christos rd_event_e type; 109 1.1 christos union { 110 1.1 christos rd_state_e state; 111 1.1 christos } u; 112 1.1 christos } rd_event_msg_t; 113 1.1 christos 114 1.1 christos typedef enum { 115 1.1 christos RD_RESOLVE_NONE, 116 1.1 christos RD_RESOLVE_STEP, 117 1.1 christos RD_RESOLVE_TARGET, 118 1.1 christos RD_RESOLVE_TARGET_STEP 119 1.1 christos } rd_skip_e; 120 1.1 christos 121 1.1 christos typedef struct rd_plt_info { 122 1.1 christos rd_skip_e pi_skip_method; 123 1.1 christos long pi_nstep; 124 1.1 christos uintptr_t pi_target; 125 1.1 christos uintptr_t pi_baddr; 126 1.1 christos unsigned int pi_flags; 127 1.1 christos } rd_plt_info_t; 128 1.1 christos 129 1.1 christos #define RD_FLG_PI_PLTBOUND 0x0001 130 1.1 christos 131 1.1 christos __BEGIN_DECLS 132 1.1 christos 133 1.1 christos struct proc_handle; 134 1.1 christos void rd_delete(rd_agent_t *); 135 1.1 christos const char *rd_errstr(rd_err_e); 136 1.1 christos rd_err_e rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *); 137 1.1 christos rd_err_e rd_event_enable(rd_agent_t *, int); 138 1.1 christos rd_err_e rd_event_getmsg(rd_agent_t *, rd_event_msg_t *); 139 1.1 christos rd_err_e rd_init(int); 140 1.1 christos typedef int rl_iter_f(const rd_loadobj_t *, void *); 141 1.1 christos rd_err_e rd_loadobj_iter(rd_agent_t *, rl_iter_f *, void *); 142 1.1 christos void rd_log(const int); 143 1.1 christos rd_agent_t *rd_new(struct proc_handle *); 144 1.1 christos rd_err_e rd_objpad_enable(rd_agent_t *, size_t); 145 1.1 christos struct proc; 146 1.1 christos rd_err_e rd_plt_resolution(rd_agent_t *, uintptr_t, struct proc *, 147 1.1 christos uintptr_t, rd_plt_info_t *); 148 1.1 christos rd_err_e rd_reset(rd_agent_t *); 149 1.1 christos 150 1.1 christos __END_DECLS 151 1.1 christos 152 1.1 christos #endif /* _RTLD_DB_H_ */ 153