[BACK]Return to link_aout.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/link_aout.h, Revision 1.2

1.2     ! espie       1: /*     $OpenBSD: link_aout.h,v 1.1 2002/06/07 03:00:01 art Exp $       */
1.1       art         2:
                      3: /*
                      4:  * Copyright (c) 1993 Paul Kranenburg
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  * 3. All advertising materials mentioning features or use of this software
                     16:  *    must display the following acknowledgement:
                     17:  *      This product includes software developed by Paul Kranenburg.
                     18:  * 4. The name of the author may not be used to endorse or promote products
                     19:  *    derived from this software without specific prior written permission
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     22:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     23:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     24:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     25:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     26:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     27:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     28:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     29:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     30:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     31:  */
                     32:
                     33: /*
                     34:  * RRS section definitions.
                     35:  *
                     36:  * The layout of some data structures defined in this header file is
                     37:  * such that we can provide compatibility with the SunOS 4.x shared
                     38:  * library scheme.
                     39:  */
                     40:
                     41: /*
                     42:  * Symbol description with size. This is simply an `nlist' with
                     43:  * one field (nz_size) added.
                     44:  * Used to convey size information on items in the data segment
                     45:  * of shared objects. An array of these live in the shared object's
                     46:  * text segment and is addressed by the `sdt_nzlist' field.
                     47:  */
                     48: struct nzlist {
                     49:        struct nlist    nlist;
1.2     ! espie      50:        unsigned long   nz_size;
1.1       art        51: #define nz_un          nlist.n_un
                     52: #define nz_strx                nlist.n_un.n_strx
                     53: #define nz_name                nlist.n_un.n_name
                     54: #define nz_type                nlist.n_type
                     55: #define nz_value       nlist.n_value
                     56: #define nz_desc                nlist.n_desc
                     57: #define nz_other       nlist.n_other
                     58: };
                     59:
                     60: #define N_AUX(p)       ((p)->n_other & 0xf)
                     61: #define N_BIND(p)      (((unsigned int)(p)->n_other >> 4) & 0xf)
                     62: #define N_OTHER(r, v)  (((unsigned int)(r) << 4) | ((v) & 0xf))
                     63:
                     64: #define AUX_OBJECT     1
                     65: #define AUX_FUNC       2
                     66: /*#define BIND_LOCAL   0       not used */
                     67: /*#define BIND_GLOBAL  1       not used */
                     68: #define BIND_WEAK      2
                     69:
                     70: /*
                     71:  * The `section_dispatch_table' structure contains offsets to various data
                     72:  * structures needed to do run-time relocation.
                     73:  */
                     74: struct section_dispatch_table {
                     75:        struct so_map *sdt_loaded;      /* List of loaded objects */
                     76:        long    sdt_sods;               /* List of shared objects descriptors */
                     77:        long    sdt_paths;              /* Library search paths */
                     78:        long    sdt_got;                /* Global offset table */
                     79:        long    sdt_plt;                /* Procedure linkage table */
                     80:        long    sdt_rel;                /* Relocation table */
                     81:        long    sdt_hash;               /* Symbol hash table */
                     82:        long    sdt_nzlist;             /* Symbol table itself */
                     83:        long    sdt_filler2;            /* Unused (was: stab_hash) */
                     84:        long    sdt_buckets;            /* Number of hash buckets */
                     85:        long    sdt_strings;            /* Symbol strings */
                     86:        long    sdt_str_sz;             /* Size of symbol strings */
                     87:        long    sdt_text_sz;            /* Size of text area */
                     88:        long    sdt_plt_sz;             /* Size of procedure linkage table */
                     89: };
                     90:
                     91: /*
                     92:  * RRS symbol hash table, addressed by `sdt_hash' in section_dispatch_table.
                     93:  * Used to quickly lookup symbols of the shared object by hashing
                     94:  * on the symbol's name. `rh_symbolnum' is the index of the symbol
                     95:  * in the shared object's symbol list (`sdt_nzlist'), `rh_next' is
                     96:  * the next symbol in the hash bucket (in case of collisions).
                     97:  */
                     98: struct rrs_hash {
                     99:        int     rh_symbolnum;           /* Symbol number */
                    100:        int     rh_next;                /* Next hash entry */
                    101: };
                    102:
                    103: /*
                    104:  * `rt_symbols' is used to keep track of run-time allocated commons
                    105:  * and data items copied from shared objects.
                    106:  */
                    107: struct rt_symbol {
                    108:        struct nzlist           *rt_sp;         /* The symbol */
                    109:        struct rt_symbol        *rt_next;       /* Next in linear list */
                    110:        struct rt_symbol        *rt_link;       /* Next in bucket */
                    111:        caddr_t                 rt_srcaddr;     /* Address of "master" copy */
                    112:        struct so_map           *rt_smp;        /* Originating map */
                    113: };
                    114:
                    115: /*
                    116:  * Debugger interface structure.
                    117:  */
                    118: struct so_debug {
                    119:        int     dd_version;             /* Version # of interface */
                    120:        int     dd_in_debugger;         /* Set when run by debugger */
                    121:        int     dd_sym_loaded;          /* Run-time linking brought more
                    122:                                           symbols into scope */
                    123:        char     *dd_bpt_addr;          /* Address of rtld-generated bpt */
                    124:        int     dd_bpt_shadow;          /* Original contents of bpt */
                    125:        struct rt_symbol *dd_cc;        /* Allocated commons/copied data */
                    126: };
                    127:
                    128: /*
                    129:  * Entry points into ld.so - user interface to the run-time linker.
                    130:  */
                    131: struct ld_entry {
                    132:        void    *(*dlopen)(const char *, int);
                    133:        int     (*dlclose)(void *);
                    134:        void    *(*dlsym)(void *, const char *);
                    135:        int     (*dlctl)(void *, int, void *);
                    136:        void    (*dlexit)(void);
                    137:        void    (*dlrsrvd[3])(void);
                    138: };
                    139:
                    140: /*
                    141:  * This is the structure pointed at by the __DYNAMIC symbol if an
                    142:  * executable requires the attention of the run-time link editor.
                    143:  * __DYNAMIC is given the value zero if no run-time linking needs to
                    144:  * be done (it is always present in shared objects).
                    145:  * The union `d_un' provides for different versions of the dynamic
                    146:  * linking mechanism (switched on by `d_version'). The last version
                    147:  * used by Sun is 3. We leave some room here and go to version number
                    148:  * 8 for NetBSD, the main difference lying in the support for the
                    149:  * `nz_list' type of symbols.
                    150:  */
                    151:
                    152: struct _dynamic {
                    153:        int             d_version;      /* version # of this interface */
                    154:        struct so_debug *d_debug;
                    155:        union {
                    156:                struct section_dispatch_table *d_sdt;
                    157:        } d_un;
                    158:        struct ld_entry *d_entry;       /* compat - now in crt_ldso */
                    159: };
                    160:
                    161: #define LD_VERSION_SUN         (3)
                    162: #define LD_VERSION_BSD         (8)
                    163: #define LD_VERSION_NZLIST_P(v) ((v) >= 8)
                    164:
                    165: #define LD_GOT(x)      ((x)->d_un.d_sdt->sdt_got)
                    166: #define LD_PLT(x)      ((x)->d_un.d_sdt->sdt_plt)
                    167: #define LD_REL(x)      ((x)->d_un.d_sdt->sdt_rel)
                    168: #define LD_SYMBOL(x)   ((x)->d_un.d_sdt->sdt_nzlist)
                    169: #define LD_HASH(x)     ((x)->d_un.d_sdt->sdt_hash)
                    170: #define LD_STRINGS(x)  ((x)->d_un.d_sdt->sdt_strings)
                    171: #define LD_NEED(x)     ((x)->d_un.d_sdt->sdt_sods)
                    172: #define LD_BUCKETS(x)  ((x)->d_un.d_sdt->sdt_buckets)
                    173: #define LD_PATHS(x)    ((x)->d_un.d_sdt->sdt_paths)
                    174:
                    175: #define LD_GOTSZ(x)    ((x)->d_un.d_sdt->sdt_plt - (x)->d_un.d_sdt->sdt_got)
                    176: #define LD_RELSZ(x)    ((x)->d_un.d_sdt->sdt_hash - (x)->d_un.d_sdt->sdt_rel)
                    177: #define LD_HASHSZ(x)   ((x)->d_un.d_sdt->sdt_nzlist - (x)->d_un.d_sdt->sdt_hash)
                    178: #define LD_STABSZ(x)   ((x)->d_un.d_sdt->sdt_strings - (x)->d_un.d_sdt->sdt_nzlist)
                    179: #define LD_PLTSZ(x)    ((x)->d_un.d_sdt->sdt_plt_sz)
                    180: #define LD_STRSZ(x)    ((x)->d_un.d_sdt->sdt_str_sz)
                    181: #define LD_TEXTSZ(x)   ((x)->d_un.d_sdt->sdt_text_sz)
                    182:
                    183: /*
                    184:  * Interface to ld.so
                    185:  */
                    186: struct crt_ldso {
                    187:        int             crt_ba;         /* Base address of ld.so */
                    188:        int             crt_dzfd;       /* "/dev/zero" file descriptor (SunOS) */
                    189:        int             crt_ldfd;       /* ld.so file descriptor */
                    190:        struct _dynamic *crt_dp;        /* Main's __DYNAMIC */
                    191:        char            **crt_ep;       /* environment strings */
                    192:        caddr_t         crt_bp;         /* Breakpoint if run from debugger */
                    193:        char            *crt_prog;      /* Program name (v3) */
                    194:        char            *crt_ldso;      /* Link editor name (v4) */
                    195:        struct ld_entry *crt_ldentry;   /* dl*() access (v4) */
                    196: };
                    197:
                    198: /*
                    199:  * Version passed from crt0 to ld.so (1st argument to _rtld()).
                    200:  */
                    201: #define CRT_VERSION_SUN                1
                    202: #define CRT_VERSION_BSD_2      2
                    203: #define CRT_VERSION_BSD_3      3
                    204: #define CRT_VERSION_BSD_4      4