_rtld.h revision dde769a2c00c82faaf80563ddd5610de2f4da339
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef __RTLD_H
#define __RTLD_H
/*
* Common header for run-time linker.
*/
#include <stdarg.h>
#include <synch.h>
#include <signal.h>
#include <errno.h>
#include <unistd.h>
#include <link.h>
#include <rtld.h>
#include <sgs.h>
#include <machdep.h>
#include <rtc.h>
#include <debug.h>
#include <msg.h>
#include <libc_int.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Dependency search rule order.
*/
/*
* Data structure for file class specific functions and data.
*/
struct fct {
/* Verify that the object is of this class. */
Rej_desc *);
/* Generate a link-map to describe the loaded object. */
void *, int *);
/* Retrieve the entry point of the object. */
Addr (*fct_entry_pt)(void);
/* Determine the objects dependencies (needed entries). */
/* Look up a symbol for the object. */
/* Relocate the object. */
/* List of default directories to search for dependencies. */
Alist **(*fct_get_def_dirs)(void);
/* List of secure directories to search for dependencies. */
Alist **(*fct_get_sec_dirs)(void);
/* Transpose the name of the object. */
uint_t);
/* Get a shared object name */
/* Retrieve a symbolic address from the object. */
/* Process a dlsym(3c) request within the object. */
int *);
};
/*
* Macros for getting to the file class table.
*/
/*
* Initial memory map allocation. Typical ELF objects contain a text and data
* segment, which can be augmented with a bss mapping. Add a bunch more for
* luck.
*/
#define MMAPFD_NUM 10
/*
* Define Alist initialization counts.
*/
/*
* Size of buffer for building error messages.
*/
/*
* Configuration file information.
*/
typedef struct config {
const char *c_name;
const char *c_strtbl;
} Config;
/*
* Register symbol list.
*/
typedef struct reglist {
} Reglist;
/*
* Data structure to hold interpreter information.
*/
typedef struct interp {
char *i_name; /* interpreter name */
} Interp;
/*
* Data structure used to keep track of copy relocations. These relocations
* are collected during initial relocation processing and maintained on the
* COPY(lmp) list of the defining object. Each copy list is also added to the
* COPY(lmp) of the head object (normally the application dynamic executable)
* from which they will be processed after all relocations are done.
*
* The use of RTLD_GROUP will also reference individual objects COPY(lmp) lists
* in case a bound symbol must be assigned to it actual copy relocation.
*/
typedef struct {
const char *r_name; /* symbol name */
void *r_radd; /* copy to address */
const void *r_dadd; /* copy from address */
} Rel_copy;
/*
* Define a file descriptor, which maintains information regarding a pathname
* that has been opened and minimally inspected.
*/
struct fdesc {
const char *fd_oname; /* original file name */
const char *fd_odir; /* original directory name */
const char *fd_nname; /* new file (expanded) name */
const char *fd_pname; /* new path (resolved) name */
};
/*
* File descriptor availability flag.
*/
#define FD_UNAVAIL -1
/*
* Disabled filter flag. Filter objects are referenced using their .dynamic
* index (DT_FILTER or DT_AUXILIARY). This index is saved and used to lookup
* the required filter. Note that 0 is a valid .dynamic index. The caller's
* OBJFLTRNDX() element is initialized using the following flag, and should
* the filter's initialization fail, is reset to this value to indicate the
* filter is disabled. UINT_MAX provides a convenient invalid .dynamic index.
*/
#define FLTR_DISABLED UINT_MAX
/*
* Status flags for rtld_flags
*/
/* set by crle(1). */
/* cache required */
/*
* Status flags for rtld_flags2
*/
/*
* Information flags for env_info.
*/
/* originates from configuration */
/* file */
/* from configuration file */
/*
* RTLDINFO descriptor.
*/
typedef struct {
} Rti_desc;
/*
* Binding flags for the rt_bind_guard()/rt_bind_clear() routines.
*/
#if !defined(CI_V_FIVE)
#endif
/*
* Print buffer.
*/
typedef struct {
char *pr_buf; /* pointer to beginning of buffer */
char *pr_cur; /* pointer to next free char in buffer */
int pr_fd; /* output fd */
} Prfbuf;
/*
* Path name descriptor. Used to construct various path names such as search
* paths, dependency paths, filter paths etc. The pd_info element can be used
* to hold various pointers, like Grp_hdl, Rtc_obj, etc.
*/
struct pdesc {
const char *pd_pname; /* path name - may be expanded */
const char *pd_oname; /* original name - unexpanded */
void *pd_info; /* possible auxiliary information */
};
/*
* Path name descriptors are passed to expand_path() and expand(). These
* routines break down possible multiple path strings (separated with ":"),
* and perform any reserved token expansion. These routines are passed
* information that indicates the use of the path, for example, search paths,
* i.e., LD_LIBRARY_PATH, RPATHS, etc. are defined using la_objsearch()
* information (see LA_SER flags in link.h). This information is recorded in
* the pd_flags field for later use.
*
* Define expansion path tokens. These are used to prevent various expansions
* from occurring, and record those expansions that do. Any expansion
* information is also recorded in the pd_flags field, and thus is or'd
* together with any LA_SER flags.
*/
/* occurred */
/*
* Define additional path information. These definitions extend the path
* information, and may be passed into expand_path(), or set internally, or
* inherited from expand(). These definitions are or'd together with any
* LA_SER_ flags and PD_TKN_ flags.
*/
/* (preload, audit etc.) */
/*
* Additional token expansion information. Although these flags may be set
* within a token data item return from expand(), they are masked off with
* PD_MSK_INHERIT prior to any expansion information being recorded in a path
* name descriptor for later diagnostics.
*/
/*
* dlopen() handle list size.
*/
/*
* Define a path name search descriptor. This "cookie" maintains state as
* search paths are processed with get_next_dir(). Note, the path list is an
* indirect pointer, as search paths can be reevaluated for secure applications
* to provide better error diagnostics.
*/
typedef struct {
} Spath_desc;
/*
* Define a path name definition descriptor. Used to maintain initial ELF and
* AOUT path name definitions.
*/
typedef struct {
const char *sd_name; /* path name */
} Spath_defn;
/*
* Define _caller flags.
*/
#define CL_NONE 0
/* if the caller can't be determined */
/*
* Binding information flags. These flags are passed up from low level binding
* routines to indicate "additional" information, such as why a binding has been
* rejected. These flags use the same data element as is used to record any
* DBG_BINFO flags. The DBG_BINFO flags are used to define the final bindings
* information and are used to provide better binding diagnostics.
*/
/* should be retried */
/* have been rejected */
/*
* The 32-bit version of rtld uses special stat() wrapper functions
* that preserve the non-largefile semantics of stat()/fstat() while
* allowing for large inode values. The 64-bit rtld uses stat() directly.
*/
#ifdef _LP64
#define rtld_fstat fstat
typedef struct stat rtld_stat_t;
#else
typedef struct {
#ifdef sparc
#endif
} rtld_stat_t;
#endif
/*
* Data declarations.
*/
extern int thr_flg_nolock;
extern int thr_flg_reenter;
extern char **environ; /* environ pointer */
extern int dyn_plt_ent_size; /* Size of dynamic plt's */
extern const char *procname; /* file name of executing process */
extern char *lasterr; /* string describing last error */
extern const char *rtldname; /* name of the dynamic linker */
extern char *platform; /* platform name */
/* data */
#endif
extern const char *locale; /* locale environment setting */
extern const char *locale; /* locale environment setting */
extern const char *rpl_audit; /* replaceable LD_AUDIT string */
extern const char *rpl_debug; /* replaceable LD_DEBUG string */
extern const char *rpl_ldflags; /* replaceable LD_FLAGS string */
extern const char *rpl_libpath; /* replaceable LD_LIBRARY string */
extern const char *rpl_preload; /* replaceable LD_PRELOAD string */
extern const char *prm_audit; /* permanent LD_AUDIT string */
extern const char *prm_debug; /* permanent LD_DEBUG string */
extern const char *prm_ldflags; /* permanent LD_FLAGS string */
extern const char *prm_libpath; /* permanent LD_LIBRARY string */
extern const char *prm_preload; /* permanent LD_PRELOAD string */
/* variables */
extern int killsig; /* signal sent on fatal exit */
extern char **_environ;
extern const char *dbg_file; /* debugging directed to a file */
extern const Msg ldd_reject[];
extern const char *profile_name; /* object being profiled */
extern const char *profile_out; /* profile output file */
extern const char *profile_lib; /* audit library to perform profile */
/* auxv information */
/* diagnostic error string headers */
extern const char *nosym_str; /* MSG_GEN_NOSYM message cache */
/*
* Function declarations.
*/
extern int append_alias(Rt_map *, const char *, int *);
extern void atexit_fini(void);
extern void defrag(void);
extern const char *demangle(const char *);
uint_t *, int *);
extern int enter(int);
Rt_map *);
Rej_desc *, int *);
avl_index_t *);
extern void fpavl_remove(Rt_map *);
extern int is_move_data(caddr_t);
extern int is_rtld_setuid();
extern void ldso_plt_init(Rt_map *);
Lm_cntl *);
extern void load_completion(Rt_map *);
extern void nfavl_insert(const char *, avl_index_t);
Rej_desc *);
int *);
extern void remove_lml(Lm_list *);
extern void remove_plist(Alist **, int);
extern int rt_bind_guard(int);
extern int rt_bind_clear(int);
extern int rt_mutex_lock(Rt_lock *);
extern int rt_mutex_unlock(Rt_lock *);
extern void rt_thr_init(Lm_list *);
extern thread_t rt_thr_self(void);
extern void rtld_db_dlactivity(Lm_list *);
extern void rtld_db_preinit(Lm_list *);
extern void rtld_db_postinit(Lm_list *);
#ifndef _LP64
extern int rtld_fstat(int, rtld_stat_t *restrict);
extern int rtld_stat(const char *restrict, rtld_stat_t *restrict);
#endif
Word *, int);
extern void set_environ(Lm_list *);
extern void spavl_insert(const char *);
extern int spavl_recorded(const char *, avl_index_t *);
extern int update_mode(Rt_map *, int, int);
#if defined(__sparc)
/*
* SPARC Register symbol support.
*/
extern int elf_regsyms(Rt_map *);
extern void set_sparc_g1(ulong_t);
extern void set_sparc_g2(ulong_t);
extern void set_sparc_g3(ulong_t);
extern void set_sparc_g4(ulong_t);
extern void set_sparc_g5(ulong_t);
extern void set_sparc_g6(ulong_t);
extern void set_sparc_g7(ulong_t);
#endif
extern long _sysconfig(int);
#ifdef __cplusplus
}
#endif
#endif /* __RTLD_H */