The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/link_aout.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * SPDX-License-Identifier: BSD-4-Clause
    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  * $FreeBSD: stable/12/sys/sys/link_aout.h 326256 2017-11-27 15:01:59Z pfg $
   33  */
   34 
   35 /*
   36  * RRS section definitions.
   37  *
   38  * The layout of some data structures defined in this header file is
   39  * such that we can provide compatibility with the SunOS 4.x shared
   40  * library scheme.
   41  */
   42 
   43 #ifndef _SYS_LINK_AOUT_H_
   44 #define _SYS_LINK_AOUT_H_
   45 
   46 struct dl_info;
   47 
   48 /*
   49  * A `Shared Object Descriptor' describes a shared object that is needed
   50  * to complete the link edit process of the object containing it.
   51  * A list of such objects (chained through `sod_next') is pointed at
   52  * by `sdt_sods' in the section_dispatch_table structure.
   53  */
   54 
   55 struct sod {    /* Shared Object Descriptor */
   56         long    sod_name;               /* name (relative to load address) */
   57         u_int   sod_library  : 1,       /* Searched for by library rules */
   58                 sod_reserved : 31;
   59         short   sod_major;              /* major version number */
   60         short   sod_minor;              /* minor version number */
   61         long    sod_next;               /* next sod */
   62 };
   63 
   64 /*
   65  * `Shared Object Map's are used by the run-time link editor (ld.so) to
   66  * keep track of all shared objects loaded into a process' address space.
   67  * These structures are only used at run-time and do not occur within
   68  * the text or data segment of an executable or shared library.
   69  */
   70 struct so_map {         /* Shared Object Map */
   71         caddr_t         som_addr;       /* Address at which object mapped */
   72         char            *som_path;      /* Path to mmap'ed file */
   73         struct so_map   *som_next;      /* Next map in chain */
   74         struct sod      *som_sod;       /* Sod responsible for this map */
   75         caddr_t         som_sodbase;    /* Base address of this sod */
   76         u_int           som_write : 1;  /* Text is currently writable */
   77         struct _dynamic *som_dynamic;   /* _dynamic structure */
   78         caddr_t         som_spd;        /* Private data */
   79 };
   80 
   81 /*
   82  * Symbol description with size. This is simply an `nlist' with
   83  * one field (nz_size) added.
   84  * Used to convey size information on items in the data segment
   85  * of shared objects. An array of these live in the shared object's
   86  * text segment and is addressed by the `sdt_nzlist' field.
   87  */
   88 struct nzlist {
   89         struct nlist    nlist;
   90         u_long          nz_size;
   91 };
   92 
   93 #define nz_un           nlist.n_un
   94 #define nz_strx         nlist.n_un.n_strx
   95 #define nz_name         nlist.n_un.n_name
   96 #define nz_type         nlist.n_type
   97 #define nz_value        nlist.n_value
   98 #define nz_desc         nlist.n_desc
   99 #define nz_other        nlist.n_other
  100 
  101 /*
  102  * The `section_dispatch_table' structure contains offsets to various data
  103  * structures needed to do run-time relocation.
  104  */
  105 struct section_dispatch_table {
  106         struct so_map *sdt_loaded;      /* List of loaded objects */
  107         long    sdt_sods;               /* List of shared objects descriptors */
  108         long    sdt_paths;              /* Library search paths */
  109         long    sdt_got;                /* Global offset table */
  110         long    sdt_plt;                /* Procedure linkage table */
  111         long    sdt_rel;                /* Relocation table */
  112         long    sdt_hash;               /* Symbol hash table */
  113         long    sdt_nzlist;             /* Symbol table itself */
  114         long    sdt_filler2;            /* Unused (was: stab_hash) */
  115         long    sdt_buckets;            /* Number of hash buckets */
  116         long    sdt_strings;            /* Symbol strings */
  117         long    sdt_str_sz;             /* Size of symbol strings */
  118         long    sdt_text_sz;            /* Size of text area */
  119         long    sdt_plt_sz;             /* Size of procedure linkage table */
  120 };
  121 
  122 /*
  123  * RRS symbol hash table, addressed by `sdt_hash' in section_dispatch_table.
  124  * Used to quickly lookup symbols of the shared object by hashing
  125  * on the symbol's name. `rh_symbolnum' is the index of the symbol
  126  * in the shared object's symbol list (`sdt_nzlist'), `rh_next' is
  127  * the next symbol in the hash bucket (in case of collisions).
  128  */
  129 struct rrs_hash {
  130         int     rh_symbolnum;           /* Symbol number */
  131         int     rh_next;                /* Next hash entry */
  132 };
  133 
  134 /*
  135  * `rt_symbols' is used to keep track of run-time allocated commons
  136  * and data items copied from shared objects.
  137  */
  138 struct rt_symbol {
  139         struct nzlist           *rt_sp;         /* The symbol */
  140         struct rt_symbol        *rt_next;       /* Next in linear list */
  141         struct rt_symbol        *rt_link;       /* Next in bucket */
  142         caddr_t                 rt_srcaddr;     /* Address of "master" copy */
  143         struct so_map           *rt_smp;        /* Originating map */
  144 };
  145 
  146 /*
  147  * Debugger interface structure.
  148  */
  149 struct so_debug {
  150         int     dd_version;             /* Version # of interface */
  151         int     dd_in_debugger;         /* Set when run by debugger */
  152         int     dd_sym_loaded;          /* Run-time linking brought more
  153                                            symbols into scope */
  154         char     *dd_bpt_addr;          /* Address of rtld-generated bpt */
  155         int     dd_bpt_shadow;          /* Original contents of bpt */
  156         struct rt_symbol *dd_cc;        /* Allocated commons/copied data */
  157 };
  158 
  159 /*
  160  * Version returned to crt0 from ld.so
  161  */
  162 #define LDSO_VERSION_NONE       0       /* FreeBSD2.0, 2.0.5 */
  163 #define LDSO_VERSION_HAS_DLEXIT 1       /* includes dlexit in ld_entry */
  164 #define LDSO_VERSION_HAS_DLSYM3 2       /* includes 3-argument dlsym */
  165 #define LDSO_VERSION_HAS_DLADDR 3       /* includes dladdr in ld_entry */
  166 
  167 /*
  168  * Entry points into ld.so - user interface to the run-time linker.
  169  * Entries are valid for the given version numbers returned by ld.so
  170  * to crt0.
  171  */
  172 struct ld_entry {
  173         void    *(*dlopen)(const char *, int);  /* NONE */
  174         int     (*dlclose)(void *);             /* NONE */
  175         void    *(*dlsym)(void *, const char *);        /* NONE */
  176         const char *(*dlerror)(void);           /* NONE */
  177         void    (*dlexit)(void);                        /* HAS_DLEXIT */
  178         void    *(*dlsym3)(void *, const char *, void *); /* HAS_DLSYM3 */
  179         int      (*dladdr)(const void *, struct dl_info *); /* HAS_DLADDR */
  180 };
  181 
  182 /*
  183  * This is the structure pointed at by the __DYNAMIC symbol if an
  184  * executable requires the attention of the run-time link editor.
  185  * __DYNAMIC is given the value zero if no run-time linking needs to
  186  * be done (it is always present in shared objects).
  187  * The union `d_un' provides for different versions of the dynamic
  188  * linking mechanism (switched on by `d_version'). The last version
  189  * used by Sun is 3. We leave some room here and go to version number
  190  * 8 for NetBSD, the main difference lying in the support for the
  191  * `nz_list' type of symbols.
  192  */
  193 
  194 struct _dynamic {
  195         int             d_version;      /* version # of this interface */
  196         struct so_debug *d_debug;
  197         union {
  198                 struct section_dispatch_table *d_sdt;
  199         } d_un;
  200         struct ld_entry *d_entry;       /* XXX */
  201 };
  202 
  203 #define LD_VERSION_SUN          (3)
  204 #define LD_VERSION_BSD          (8)
  205 #define LD_VERSION_NZLIST_P(v)  ((v) >= 8)
  206 
  207 #define LD_GOT(x)       ((x)->d_un.d_sdt->sdt_got)
  208 #define LD_PLT(x)       ((x)->d_un.d_sdt->sdt_plt)
  209 #define LD_REL(x)       ((x)->d_un.d_sdt->sdt_rel)
  210 #define LD_SYMBOL(x)    ((x)->d_un.d_sdt->sdt_nzlist)
  211 #define LD_HASH(x)      ((x)->d_un.d_sdt->sdt_hash)
  212 #define LD_STRINGS(x)   ((x)->d_un.d_sdt->sdt_strings)
  213 #define LD_NEED(x)      ((x)->d_un.d_sdt->sdt_sods)
  214 #define LD_BUCKETS(x)   ((x)->d_un.d_sdt->sdt_buckets)
  215 #define LD_PATHS(x)     ((x)->d_un.d_sdt->sdt_paths)
  216 
  217 #define LD_GOTSZ(x)     ((x)->d_un.d_sdt->sdt_plt - (x)->d_un.d_sdt->sdt_got)
  218 #define LD_RELSZ(x)     ((x)->d_un.d_sdt->sdt_hash - (x)->d_un.d_sdt->sdt_rel)
  219 #define LD_HASHSZ(x)    ((x)->d_un.d_sdt->sdt_nzlist - (x)->d_un.d_sdt->sdt_hash)
  220 #define LD_STABSZ(x)    ((x)->d_un.d_sdt->sdt_strings - (x)->d_un.d_sdt->sdt_nzlist)
  221 #define LD_PLTSZ(x)     ((x)->d_un.d_sdt->sdt_plt_sz)
  222 #define LD_STRSZ(x)     ((x)->d_un.d_sdt->sdt_str_sz)
  223 #define LD_TEXTSZ(x)    ((x)->d_un.d_sdt->sdt_text_sz)
  224 
  225 /*
  226  * Interface to ld.so
  227  */
  228 struct crt_ldso {
  229         int             crt_ba;         /* Base address of ld.so */
  230         int             crt_dzfd;       /* "/dev/zero" file descriptor (SunOS) */
  231         int             crt_ldfd;       /* ld.so file descriptor */
  232         struct _dynamic *crt_dp;        /* Main's __DYNAMIC */
  233         char            **crt_ep;       /* environment strings */
  234         caddr_t         crt_bp;         /* Breakpoint if run from debugger */
  235         char            *crt_prog;      /* Program name (v3) */
  236         char            *crt_ldso;      /* Link editor name (v4) */
  237         struct ld_entry *crt_ldentry;   /* dl*() access (v4) */
  238         char            **crt_argv;     /* argument strings (v5) */
  239 };
  240 
  241 /*
  242  * Version passed from crt0 to ld.so (1st argument to _rtld()).
  243  */
  244 #define CRT_VERSION_SUN         1
  245 #define CRT_VERSION_BSD_2       2
  246 #define CRT_VERSION_BSD_3       3
  247 #define CRT_VERSION_BSD_4       4
  248 #define CRT_VERSION_BSD_5       5
  249 
  250 /*
  251  * Maximum number of recognized shared object version numbers.
  252  */
  253 #define MAXDEWEY        8
  254 
  255 /*
  256  * Header of the hints file.
  257  */
  258 struct hints_header {
  259         long            hh_magic;
  260 #define HH_MAGIC        011421044151
  261         long            hh_version;     /* Interface version number */
  262 #define LD_HINTS_VERSION_1      1
  263 #define LD_HINTS_VERSION_2      2
  264         long            hh_hashtab;     /* Location of hash table */
  265         long            hh_nbucket;     /* Number of buckets in hashtab */
  266         long            hh_strtab;      /* Location of strings */
  267         long            hh_strtab_sz;   /* Size of strings */
  268         long            hh_ehints;      /* End of hints (max offset in file) */
  269         long            hh_dirlist;     /* Colon-separated list of srch dirs */
  270 };
  271 
  272 #define HH_BADMAG(hdr)  ((hdr).hh_magic != HH_MAGIC)
  273 
  274 /*
  275  * Hash table element in hints file.
  276  */
  277 struct hints_bucket {
  278         /* namex and pathx are indices into the string table */
  279         int             hi_namex;               /* Library name */
  280         int             hi_pathx;               /* Full path */
  281         int             hi_dewey[MAXDEWEY];     /* The versions */
  282         int             hi_ndewey;              /* Number of version numbers */
  283 #define hi_major hi_dewey[0]
  284 #define hi_minor hi_dewey[1]
  285         int             hi_next;                /* Next in this bucket */
  286 };
  287 
  288 #define _PATH_LD_HINTS          "/var/run/ld.so.hints"
  289 
  290 #endif /* _SYS_LINK_AOUT_H_ */

Cache object: 82c725940383095582fa4a57c6cce25a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.