1*c54927cbSderaadt /* $OpenBSD: link.h,v 1.15 2013/10/19 09:00:18 deraadt Exp $ */ 28c432240Sderaadt /* $NetBSD: link.h,v 1.10 1996/01/09 00:00:11 pk Exp $ */ 3df930be7Sderaadt 4df930be7Sderaadt /* 5df930be7Sderaadt * Copyright (c) 1993 Paul Kranenburg 6df930be7Sderaadt * All rights reserved. 7df930be7Sderaadt * 8df930be7Sderaadt * Redistribution and use in source and binary forms, with or without 9df930be7Sderaadt * modification, are permitted provided that the following conditions 10df930be7Sderaadt * are met: 11df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright 12df930be7Sderaadt * notice, this list of conditions and the following disclaimer. 13df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 14df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the 15df930be7Sderaadt * documentation and/or other materials provided with the distribution. 16df930be7Sderaadt * 3. All advertising materials mentioning features or use of this software 17df930be7Sderaadt * must display the following acknowledgement: 18df930be7Sderaadt * This product includes software developed by Paul Kranenburg. 19df930be7Sderaadt * 4. The name of the author may not be used to endorse or promote products 2047369814Sderaadt * derived from this software without specific prior written permission 21df930be7Sderaadt * 22df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23df930be7Sderaadt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24df930be7Sderaadt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25df930be7Sderaadt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26df930be7Sderaadt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27df930be7Sderaadt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28df930be7Sderaadt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29df930be7Sderaadt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30df930be7Sderaadt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31df930be7Sderaadt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32df930be7Sderaadt */ 33df930be7Sderaadt 34df930be7Sderaadt 35df930be7Sderaadt #ifndef _LINK_H_ 36df930be7Sderaadt #define _LINK_H_ 37df930be7Sderaadt 3872bfe451Sart #ifdef __ELF__ 3972bfe451Sart #include <link_elf.h> 4037722117Sart #endif 4137722117Sart 42df930be7Sderaadt /* 4303aafb83Sespie * A `Shared Object Descriptor' describes a shared object that is needed 44df930be7Sderaadt * to complete the link edit process of the object containing it. 45df930be7Sderaadt * A list of such objects (chained through `sod_next') is pointed at 46df930be7Sderaadt * by `sdt_sods' in the section_dispatch_table structure. 47df930be7Sderaadt */ 48df930be7Sderaadt 49df930be7Sderaadt struct sod { /* Shared Object Descriptor */ 50df930be7Sderaadt long sod_name; /* name (relative to load address) */ 51d1f942abSespie unsigned int sod_library : 1,/* Searched for by library rules */ 52df930be7Sderaadt sod_reserved : 31; 53df930be7Sderaadt short sod_major; /* major version number */ 54df930be7Sderaadt short sod_minor; /* minor version number */ 55df930be7Sderaadt long sod_next; /* next sod */ 56df930be7Sderaadt }; 57df930be7Sderaadt 58df930be7Sderaadt /* 59df930be7Sderaadt * `Shared Object Map's are used by the run-time link editor (ld.so) to 60df930be7Sderaadt * keep track of all shared objects loaded into a process' address space. 61df930be7Sderaadt * These structures are only used at run-time and do not occur within 62df930be7Sderaadt * the text or data segment of an executable or shared library. 63df930be7Sderaadt */ 64df930be7Sderaadt struct so_map { /* Shared Object Map */ 65df930be7Sderaadt caddr_t som_addr; /* Address at which object mapped */ 66df930be7Sderaadt char *som_path; /* Path to mmap'ed file */ 67df930be7Sderaadt struct so_map *som_next; /* Next map in chain */ 68df930be7Sderaadt struct sod *som_sod; /* Sod responsible for this map */ 69df930be7Sderaadt caddr_t som_sodbase; /* Base address of this sod */ 70d1f942abSespie unsigned int som_write : 1; /* Text is currently writable */ 71df930be7Sderaadt struct _dynamic *som_dynamic; /* _dynamic structure */ 72df930be7Sderaadt caddr_t som_spd; /* Private data */ 73df930be7Sderaadt }; 74df930be7Sderaadt 75df930be7Sderaadt 76df930be7Sderaadt /* 772e9485faSart * Debug rendezvous struct. Pointer to this is set up in the 788d496b79Sart * target code pointed by the DT_DEBUG tag. If it is 792e9485faSart * defined. 802e9485faSart */ 812e9485faSart struct r_debug { 822e9485faSart int r_version; /* Protocol version. */ 832e9485faSart struct link_map *r_map; /* Head of list of loaded objects. */ 842e9485faSart 852e9485faSart /* 862e9485faSart * This is the address of a function internal to the run-time linker, 872e9485faSart * that will always be called when the linker begins to map in a 882e9485faSart * library or unmap it, and again when the mapping change is complete. 892e9485faSart * The debugger can set a breakpoint at this address if it wants to 902e9485faSart * notice shared object mapping changes. 912e9485faSart */ 928d496b79Sart unsigned long r_brk; 932e9485faSart enum { 942e9485faSart /* 952e9485faSart * This state value describes the mapping change taking place 962e9485faSart * when the `r_brk' address is called. 972e9485faSart */ 982e9485faSart RT_CONSISTENT, /* Mapping change is complete. */ 992e9485faSart RT_ADD, /* Adding a new object. */ 100b8f07609Sderaadt RT_DELETE /* Removing an object mapping. */ 1012e9485faSart } r_state; 1022e9485faSart 1038d496b79Sart unsigned long r_ldbase; /* Base address the linker is loaded at. */ 1042e9485faSart }; 1052e9485faSart 106df930be7Sderaadt 107df930be7Sderaadt 108df930be7Sderaadt /* 109df930be7Sderaadt * Maximum number of recognized shared object version numbers. 110df930be7Sderaadt */ 111df930be7Sderaadt #define MAXDEWEY 8 112df930be7Sderaadt 113df930be7Sderaadt /* 114df930be7Sderaadt * Header of the hints file. 115df930be7Sderaadt */ 116df930be7Sderaadt struct hints_header { 117df930be7Sderaadt long hh_magic; 118df930be7Sderaadt #define HH_MAGIC 011421044151 119df930be7Sderaadt long hh_version; /* Interface version number */ 120df930be7Sderaadt #define LD_HINTS_VERSION_1 1 1218c432240Sderaadt #define LD_HINTS_VERSION_2 2 122df930be7Sderaadt long hh_hashtab; /* Location of hash table */ 123df930be7Sderaadt long hh_nbucket; /* Number of buckets in hashtab */ 124df930be7Sderaadt long hh_strtab; /* Location of strings */ 125df930be7Sderaadt long hh_strtab_sz; /* Size of strings */ 126df930be7Sderaadt long hh_ehints; /* End of hints (max offset in file) */ 1278c432240Sderaadt long hh_dirlist; /* Colon-separated list of srch dirs */ 128df930be7Sderaadt }; 129df930be7Sderaadt 130df930be7Sderaadt #define HH_BADMAG(hdr) ((hdr).hh_magic != HH_MAGIC) 131df930be7Sderaadt 132df930be7Sderaadt /* 133df930be7Sderaadt * Hash table element in hints file. 134df930be7Sderaadt */ 135df930be7Sderaadt struct hints_bucket { 136df930be7Sderaadt /* namex and pathx are indices into the string table */ 137df930be7Sderaadt int hi_namex; /* Library name */ 138df930be7Sderaadt int hi_pathx; /* Full path */ 139df930be7Sderaadt int hi_dewey[MAXDEWEY]; /* The versions */ 140df930be7Sderaadt int hi_ndewey; /* Number of version numbers */ 141df930be7Sderaadt #define hi_major hi_dewey[0] 142df930be7Sderaadt #define hi_minor hi_dewey[1] 143df930be7Sderaadt int hi_next; /* Next in this bucket */ 144df930be7Sderaadt }; 145df930be7Sderaadt 146df930be7Sderaadt #define _PATH_LD_HINTS "/var/run/ld.so.hints" 147df930be7Sderaadt 148df930be7Sderaadt #endif /* _LINK_H_ */ 149df930be7Sderaadt 150