2016-01-23 04:26:14 +03:00
|
|
|
/* $NetBSD: link_aout.h,v 1.23 2016/01/23 01:26:14 dholland Exp $ */
|
1994-10-26 03:55:40 +03:00
|
|
|
|
1998-09-05 17:08:38 +04:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
1994-01-28 23:26:52 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-09-05 17:08:38 +04:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Paul Kranenburg.
|
|
|
|
*
|
1994-01-28 23:26:52 +03:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
1998-09-05 17:08:38 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
1994-01-28 23:26:52 +03:00
|
|
|
*/
|
|
|
|
|
1993-10-17 03:51:30 +03:00
|
|
|
/*
|
|
|
|
* RRS section definitions.
|
|
|
|
*
|
1994-01-28 23:26:52 +03:00
|
|
|
* The layout of some data structures defined in this header file is
|
|
|
|
* such that we can provide compatibility with the SunOS 4.x shared
|
|
|
|
* library scheme.
|
1993-10-17 03:51:30 +03:00
|
|
|
*/
|
|
|
|
|
1999-03-20 01:06:36 +03:00
|
|
|
#ifndef _LINK_AOUT_H_
|
|
|
|
#define _LINK_AOUT_H_
|
1993-10-17 03:51:30 +03:00
|
|
|
|
1998-05-14 05:55:28 +04:00
|
|
|
#include <dlfcn.h> /* for Dl_info */
|
1998-12-16 00:28:28 +03:00
|
|
|
#include <a.out.h> /* for struct nlist */
|
1998-05-14 05:55:28 +04:00
|
|
|
|
1993-10-17 03:51:30 +03:00
|
|
|
/*
|
2000-09-15 00:36:39 +04:00
|
|
|
* A `Shared Object Descriptor' describes a shared object that is needed
|
1993-10-17 03:51:30 +03:00
|
|
|
* to complete the link edit process of the object containing it.
|
1994-01-28 23:26:52 +03:00
|
|
|
* A list of such objects (chained through `sod_next') is pointed at
|
|
|
|
* by `sdt_sods' in the section_dispatch_table structure.
|
1993-10-17 03:51:30 +03:00
|
|
|
*/
|
|
|
|
|
1994-01-28 23:26:52 +03:00
|
|
|
struct sod { /* Shared Object Descriptor */
|
|
|
|
long sod_name; /* name (relative to load address) */
|
2016-01-23 04:26:14 +03:00
|
|
|
unsigned int sod_library : 1, /* Searched for by library rules */
|
1994-01-28 23:26:52 +03:00
|
|
|
sod_reserved : 31;
|
|
|
|
short sod_major; /* major version number */
|
|
|
|
short sod_minor; /* minor version number */
|
|
|
|
long sod_next; /* next sod */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
1994-01-28 23:26:52 +03:00
|
|
|
* `Shared Object Map's are used by the run-time link editor (ld.so) to
|
|
|
|
* keep track of all shared objects loaded into a process' address space.
|
1993-10-17 03:51:30 +03:00
|
|
|
* These structures are only used at run-time and do not occur within
|
|
|
|
* the text or data segment of an executable or shared library.
|
|
|
|
*/
|
1994-01-28 23:26:52 +03:00
|
|
|
struct so_map { /* Shared Object Map */
|
|
|
|
caddr_t som_addr; /* Address at which object mapped */
|
|
|
|
char *som_path; /* Path to mmap'ed file */
|
|
|
|
struct so_map *som_next; /* Next map in chain */
|
|
|
|
struct sod *som_sod; /* Sod responsible for this map */
|
|
|
|
caddr_t som_sodbase; /* Base address of this sod */
|
2016-01-23 04:26:14 +03:00
|
|
|
unsigned int som_write : 1; /* Text is currently writable */
|
1994-01-28 23:26:52 +03:00
|
|
|
struct _dynamic *som_dynamic; /* _dynamic structure */
|
|
|
|
caddr_t som_spd; /* Private data */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Symbol description with size. This is simply an `nlist' with
|
|
|
|
* one field (nz_size) added.
|
|
|
|
* Used to convey size information on items in the data segment
|
|
|
|
* of shared objects. An array of these live in the shared object's
|
1994-01-28 23:26:52 +03:00
|
|
|
* text segment and is addressed by the `sdt_nzlist' field.
|
1993-10-17 03:51:30 +03:00
|
|
|
*/
|
|
|
|
struct nzlist {
|
|
|
|
struct nlist nlist;
|
2016-01-23 00:55:57 +03:00
|
|
|
unsigned long nz_size;
|
1993-10-17 03:51:30 +03:00
|
|
|
#define nz_un nlist.n_un
|
|
|
|
#define nz_strx nlist.n_un.n_strx
|
|
|
|
#define nz_name nlist.n_un.n_name
|
|
|
|
#define nz_type nlist.n_type
|
|
|
|
#define nz_value nlist.n_value
|
|
|
|
#define nz_desc nlist.n_desc
|
|
|
|
#define nz_other nlist.n_other
|
|
|
|
};
|
|
|
|
|
1994-01-28 23:26:52 +03:00
|
|
|
#define N_AUX(p) ((p)->n_other & 0xf)
|
1994-12-23 23:16:59 +03:00
|
|
|
#define N_BIND(p) (((unsigned int)(p)->n_other >> 4) & 0xf)
|
1994-01-28 23:26:52 +03:00
|
|
|
#define N_OTHER(r, v) (((unsigned int)(r) << 4) | ((v) & 0xf))
|
|
|
|
|
|
|
|
#define AUX_OBJECT 1
|
|
|
|
#define AUX_FUNC 2
|
1998-10-19 04:30:57 +04:00
|
|
|
#define AUX_LABEL 3
|
1994-12-23 23:16:59 +03:00
|
|
|
/*#define BIND_LOCAL 0 not used */
|
|
|
|
/*#define BIND_GLOBAL 1 not used */
|
|
|
|
#define BIND_WEAK 2
|
1994-01-28 23:26:52 +03:00
|
|
|
|
|
|
|
|
1993-10-17 03:51:30 +03:00
|
|
|
/*
|
1994-01-28 23:26:52 +03:00
|
|
|
* The `section_dispatch_table' structure contains offsets to various data
|
1993-10-17 03:51:30 +03:00
|
|
|
* structures needed to do run-time relocation.
|
|
|
|
*/
|
1994-01-28 23:26:52 +03:00
|
|
|
struct section_dispatch_table {
|
|
|
|
struct so_map *sdt_loaded; /* List of loaded objects */
|
|
|
|
long sdt_sods; /* List of shared objects descriptors */
|
1995-06-05 01:57:18 +04:00
|
|
|
long sdt_paths; /* Library search paths */
|
1994-01-28 23:26:52 +03:00
|
|
|
long sdt_got; /* Global offset table */
|
|
|
|
long sdt_plt; /* Procedure linkage table */
|
|
|
|
long sdt_rel; /* Relocation table */
|
|
|
|
long sdt_hash; /* Symbol hash table */
|
|
|
|
long sdt_nzlist; /* Symbol table itself */
|
|
|
|
long sdt_filler2; /* Unused (was: stab_hash) */
|
|
|
|
long sdt_buckets; /* Number of hash buckets */
|
|
|
|
long sdt_strings; /* Symbol strings */
|
|
|
|
long sdt_str_sz; /* Size of symbol strings */
|
|
|
|
long sdt_text_sz; /* Size of text area */
|
|
|
|
long sdt_plt_sz; /* Size of procedure linkage table */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
1994-01-28 23:26:52 +03:00
|
|
|
* RRS symbol hash table, addressed by `sdt_hash' in section_dispatch_table.
|
1993-10-17 03:51:30 +03:00
|
|
|
* Used to quickly lookup symbols of the shared object by hashing
|
|
|
|
* on the symbol's name. `rh_symbolnum' is the index of the symbol
|
1994-01-28 23:26:52 +03:00
|
|
|
* in the shared object's symbol list (`sdt_nzlist'), `rh_next' is
|
1993-10-17 03:51:30 +03:00
|
|
|
* the next symbol in the hash bucket (in case of collisions).
|
|
|
|
*/
|
|
|
|
struct rrs_hash {
|
1994-01-28 23:26:52 +03:00
|
|
|
int rh_symbolnum; /* Symbol number */
|
|
|
|
int rh_next; /* Next hash entry */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* `rt_symbols' is used to keep track of run-time allocated commons
|
|
|
|
* and data items copied from shared objects.
|
|
|
|
*/
|
|
|
|
struct rt_symbol {
|
1994-01-28 23:26:52 +03:00
|
|
|
struct nzlist *rt_sp; /* The symbol */
|
|
|
|
struct rt_symbol *rt_next; /* Next in linear list */
|
|
|
|
struct rt_symbol *rt_link; /* Next in bucket */
|
|
|
|
caddr_t rt_srcaddr; /* Address of "master" copy */
|
|
|
|
struct so_map *rt_smp; /* Originating map */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Debugger interface structure.
|
|
|
|
*/
|
1994-01-28 23:26:52 +03:00
|
|
|
struct so_debug {
|
|
|
|
int dd_version; /* Version # of interface */
|
|
|
|
int dd_in_debugger; /* Set when run by debugger */
|
|
|
|
int dd_sym_loaded; /* Run-time linking brought more
|
|
|
|
symbols into scope */
|
|
|
|
char *dd_bpt_addr; /* Address of rtld-generated bpt */
|
|
|
|
int dd_bpt_shadow; /* Original contents of bpt */
|
|
|
|
struct rt_symbol *dd_cc; /* Allocated commons/copied data */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entry points into ld.so - user interface to the run-time linker.
|
|
|
|
*/
|
|
|
|
struct ld_entry {
|
2005-02-03 07:39:32 +03:00
|
|
|
void *(*dlopen)(const char *, int);
|
|
|
|
int (*dlclose)(void *);
|
|
|
|
void *(*dlsym)(void *, const char *);
|
|
|
|
int (*dlctl)(void *, int, void *);
|
|
|
|
void (*dlexit)(void);
|
|
|
|
int (*dladdr)(const void *, Dl_info *);
|
|
|
|
void (*dlrsrvd[2])(void);
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the structure pointed at by the __DYNAMIC symbol if an
|
|
|
|
* executable requires the attention of the run-time link editor.
|
|
|
|
* __DYNAMIC is given the value zero if no run-time linking needs to
|
|
|
|
* be done (it is always present in shared objects).
|
1994-01-28 23:26:52 +03:00
|
|
|
* The union `d_un' provides for different versions of the dynamic
|
|
|
|
* linking mechanism (switched on by `d_version'). The last version
|
1993-10-17 03:51:30 +03:00
|
|
|
* used by Sun is 3. We leave some room here and go to version number
|
|
|
|
* 8 for NetBSD, the main difference lying in the support for the
|
|
|
|
* `nz_list' type of symbols.
|
|
|
|
*/
|
|
|
|
|
1994-01-28 23:26:52 +03:00
|
|
|
struct _dynamic {
|
|
|
|
int d_version; /* version # of this interface */
|
|
|
|
struct so_debug *d_debug;
|
1993-10-17 03:51:30 +03:00
|
|
|
union {
|
1994-01-28 23:26:52 +03:00
|
|
|
struct section_dispatch_table *d_sdt;
|
|
|
|
} d_un;
|
1995-09-24 02:26:15 +04:00
|
|
|
struct ld_entry *d_entry; /* compat - now in crt_ldso */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define LD_VERSION_SUN (3)
|
|
|
|
#define LD_VERSION_BSD (8)
|
|
|
|
#define LD_VERSION_NZLIST_P(v) ((v) >= 8)
|
|
|
|
|
1994-01-28 23:26:52 +03:00
|
|
|
#define LD_GOT(x) ((x)->d_un.d_sdt->sdt_got)
|
|
|
|
#define LD_PLT(x) ((x)->d_un.d_sdt->sdt_plt)
|
|
|
|
#define LD_REL(x) ((x)->d_un.d_sdt->sdt_rel)
|
|
|
|
#define LD_SYMBOL(x) ((x)->d_un.d_sdt->sdt_nzlist)
|
|
|
|
#define LD_HASH(x) ((x)->d_un.d_sdt->sdt_hash)
|
|
|
|
#define LD_STRINGS(x) ((x)->d_un.d_sdt->sdt_strings)
|
|
|
|
#define LD_NEED(x) ((x)->d_un.d_sdt->sdt_sods)
|
|
|
|
#define LD_BUCKETS(x) ((x)->d_un.d_sdt->sdt_buckets)
|
1995-06-05 01:57:18 +04:00
|
|
|
#define LD_PATHS(x) ((x)->d_un.d_sdt->sdt_paths)
|
1994-01-28 23:26:52 +03:00
|
|
|
|
|
|
|
#define LD_GOTSZ(x) ((x)->d_un.d_sdt->sdt_plt - (x)->d_un.d_sdt->sdt_got)
|
|
|
|
#define LD_RELSZ(x) ((x)->d_un.d_sdt->sdt_hash - (x)->d_un.d_sdt->sdt_rel)
|
|
|
|
#define LD_HASHSZ(x) ((x)->d_un.d_sdt->sdt_nzlist - (x)->d_un.d_sdt->sdt_hash)
|
|
|
|
#define LD_STABSZ(x) ((x)->d_un.d_sdt->sdt_strings - (x)->d_un.d_sdt->sdt_nzlist)
|
|
|
|
#define LD_PLTSZ(x) ((x)->d_un.d_sdt->sdt_plt_sz)
|
|
|
|
#define LD_STRSZ(x) ((x)->d_un.d_sdt->sdt_str_sz)
|
|
|
|
#define LD_TEXTSZ(x) ((x)->d_un.d_sdt->sdt_text_sz)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface to ld.so
|
1993-10-17 03:51:30 +03:00
|
|
|
*/
|
|
|
|
struct crt_ldso {
|
|
|
|
int crt_ba; /* Base address of ld.so */
|
2000-09-15 00:36:39 +04:00
|
|
|
int crt_dzfd; /* "/dev/zero" file descriptor (SunOS) */
|
1993-10-17 03:51:30 +03:00
|
|
|
int crt_ldfd; /* ld.so file descriptor */
|
1994-01-28 23:26:52 +03:00
|
|
|
struct _dynamic *crt_dp; /* Main's __DYNAMIC */
|
1993-10-17 03:51:30 +03:00
|
|
|
char **crt_ep; /* environment strings */
|
|
|
|
caddr_t crt_bp; /* Breakpoint if run from debugger */
|
1994-12-23 23:16:59 +03:00
|
|
|
char *crt_prog; /* Program name (v3) */
|
|
|
|
char *crt_ldso; /* Link editor name (v4) */
|
|
|
|
struct ld_entry *crt_ldentry; /* dl*() access (v4) */
|
1993-10-17 03:51:30 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Version passed from crt0 to ld.so (1st argument to _rtld()).
|
|
|
|
*/
|
|
|
|
#define CRT_VERSION_SUN 1
|
1994-01-28 23:26:52 +03:00
|
|
|
#define CRT_VERSION_BSD_2 2
|
|
|
|
#define CRT_VERSION_BSD_3 3
|
1994-12-23 23:16:59 +03:00
|
|
|
#define CRT_VERSION_BSD_4 4
|
1993-10-17 03:51:30 +03:00
|
|
|
|
1993-10-23 00:04:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum number of recognized shared object version numbers.
|
|
|
|
*/
|
|
|
|
#define MAXDEWEY 8
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Header of the hints file.
|
|
|
|
*/
|
|
|
|
struct hints_header {
|
|
|
|
long hh_magic;
|
|
|
|
#define HH_MAGIC 011421044151
|
|
|
|
long hh_version; /* Interface version number */
|
|
|
|
#define LD_HINTS_VERSION_1 1
|
1996-01-09 03:00:11 +03:00
|
|
|
#define LD_HINTS_VERSION_2 2
|
1993-10-23 00:04:19 +03:00
|
|
|
long hh_hashtab; /* Location of hash table */
|
|
|
|
long hh_nbucket; /* Number of buckets in hashtab */
|
|
|
|
long hh_strtab; /* Location of strings */
|
|
|
|
long hh_strtab_sz; /* Size of strings */
|
|
|
|
long hh_ehints; /* End of hints (max offset in file) */
|
1996-01-09 03:00:11 +03:00
|
|
|
long hh_dirlist; /* Colon-separated list of srch dirs */
|
1993-10-23 00:04:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define HH_BADMAG(hdr) ((hdr).hh_magic != HH_MAGIC)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Hash table element in hints file.
|
|
|
|
*/
|
|
|
|
struct hints_bucket {
|
|
|
|
/* namex and pathx are indices into the string table */
|
|
|
|
int hi_namex; /* Library name */
|
|
|
|
int hi_pathx; /* Full path */
|
|
|
|
int hi_dewey[MAXDEWEY]; /* The versions */
|
|
|
|
int hi_ndewey; /* Number of version numbers */
|
|
|
|
#define hi_major hi_dewey[0]
|
|
|
|
#define hi_minor hi_dewey[1]
|
|
|
|
int hi_next; /* Next in this bucket */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define _PATH_LD_HINTS "/var/run/ld.so.hints"
|
|
|
|
|
1999-03-20 01:06:36 +03:00
|
|
|
#endif /* _LINK_AOUT_H_ */
|