/* Data structure for communication from the run-time dynamic linker for
loaded ELF shared objects.
- Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1995-2014 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _LINK_H
#define _LINK_H 1
#define _ElfW_1(e,w,t) e##w##t
#include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */
+#include <bits/link.h>
/* Rendezvous structure used by the run-time dynamic linker to communicate
details of shared object loading to the debugger. If the executable's
*/
extern ElfW(Dyn) _DYNAMIC[];
-
-/* Some internal data structures of the dynamic linker used in the
- linker map. We only provide forward declarations. */
-struct libname_list;
-struct r_found_version;
-struct r_search_path_elem;
-
-/* Forward declaration. */
-struct link_map;
-
-/* Structure to describe a single list of scope elements. The lookup
- functions get passed an array of pointers to such structures. */
-struct r_scope_elem
-{
- /* Array of maps for the scope. */
- struct link_map **r_list;
- /* Number of entries in the scope. */
- unsigned int r_nlist;
-
- /* Array of maps which also includes duplicates. */
- struct link_map **r_duplist;
- /* Number of elements in this list. */
- unsigned int r_nduplist;
-};
-
-
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
members form a chain of all the shared objects loaded at startup.
These data structures exist in space used by the run-time dynamic linker;
- modifying them may have disastrous results.
-
- This data structure might change in future, if necessary. User-level
- programs must avoid defining objects of this type. */
+ modifying them may have disastrous results. */
struct link_map
{
/* These first few members are part of the protocol with the debugger.
This is the same format used in SVR4. */
- ElfW(Addr) l_addr; /* Base address shared object is loaded at. */
+ ElfW(Addr) l_addr; /* Difference between the address in the ELF
+ file and the addresses in memory. */
char *l_name; /* Absolute file name object was found in. */
ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
+ };
- /* All following members are internal to the dynamic linker.
- They may change without notice. */
-
- struct libname_list *l_libname;
- /* Indexed pointers to dynamic section.
- [0,DT_NUM) are indexed by the processor-independent tags.
- [DT_NUM,DT_NUM+DT_THISPROCNUM) are indexed by the tag minus DT_LOPROC.
- [DT_NUM+DT_THISPROCNUM,DT_NUM+DT_THISPROCNUM+DT_EXTRANUM) are indexed
- by DT_EXTRATAGIDX(tagvalue) and
- [DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM,
- DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM)
- are indexed by DT_EXTRATAGIDX(tagvalue) (see <elf.h>). */
-
- ElfW(Dyn) *l_info[DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM
- + DT_EXTRANUM];
- const ElfW(Phdr) *l_phdr; /* Pointer to program header table in core. */
- ElfW(Addr) l_entry; /* Entry point location. */
- ElfW(Half) l_phnum; /* Number of program header entries. */
- ElfW(Half) l_ldnum; /* Number of dynamic segment entries. */
-
- /* Array of DT_NEEDED dependencies and their dependencies, in
- dependency order for symbol lookup (with and without
- duplicates). There is no entry before the dependencies have
- been loaded. */
- struct r_scope_elem l_searchlist;
-
- /* We need a special searchlist to process objects marked with
- DT_SYMBOLIC. */
- struct r_scope_elem l_symbolic_searchlist;
-
- /* Dependent object that first caused this object to be loaded. */
- struct link_map *l_loader;
-
- /* Symbol hash table. */
- Elf_Symndx l_nbuckets;
- const Elf_Symndx *l_buckets, *l_chain;
-
- unsigned int l_opencount; /* Reference count for dlopen/dlclose. */
- enum /* Where this object came from. */
- {
- lt_executable, /* The main executable program. */
- lt_library, /* Library needed by main executable. */
- lt_loaded /* Extra run-time loaded shared object. */
- } l_type:2;
- unsigned int l_relocated:1; /* Nonzero if object's relocations done. */
- unsigned int l_init_called:1; /* Nonzero if DT_INIT function called. */
- unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */
- unsigned int l_reserved:2; /* Reserved for internal use. */
- unsigned int l_phdr_allocated:1; /* Nonzero if the data structure pointed
- to by `l_phdr' is allocated. */
-
- /* Array with version names. */
- unsigned int l_nversions;
- struct r_found_version *l_versions;
-
- /* Collected information about own RPATH directories. */
- struct r_search_path_elem **l_rpath_dirs;
-
- /* Collected results of relocation while profiling. */
- ElfW(Addr) *l_reloc_result;
-
- /* Pointer to the version information if available. */
- ElfW(Versym) *l_versyms;
-
- /* String specifying the path where this object was found. */
- const char *l_origin;
-
- /* Start and finish of memory map for this object. l_map_start
- need not be the same as l_addr. */
- ElfW(Addr) l_map_start, l_map_end;
-
- /* This is an array defining the lookup scope for this link map.
- There are at most three different scope lists. */
- struct r_scope_elem *l_scope[4];
-
- /* A similar array, this time only with the local scope. This is
- used occasionally. */
- struct r_scope_elem *l_local_scope[2];
-
- /* This information is kept to check for sure whether a shared
- object is the same as one already loaded. */
- dev_t l_dev;
- ino_t l_ino;
-
- /* Collected information about own RUNPATH directories. */
- struct r_search_path_elem **l_runpath_dirs;
-
- /* List of object in order of the init and fini calls. */
- struct link_map **l_initfini;
-
- /* List of the dependencies introduced through symbol binding. */
- unsigned int l_reldepsmax;
- unsigned int l_reldepsact;
- struct link_map **l_reldeps;
+#ifdef __USE_GNU
+
+/* Version numbers for la_version handshake interface. */
+#define LAV_CURRENT 1
+
+/* Activity types signaled through la_activity. */
+enum
+ {
+ LA_ACT_CONSISTENT, /* Link map consistent again. */
+ LA_ACT_ADD, /* New object will be added. */
+ LA_ACT_DELETE /* Objects will be removed. */
};
+/* Values representing origin of name for dynamic loading. */
+enum
+ {
+ LA_SER_ORIG = 0x01, /* Original name. */
+ LA_SER_LIBPATH = 0x02, /* Directory from LD_LIBRARY_PATH. */
+ LA_SER_RUNPATH = 0x04, /* Directory from RPATH/RUNPATH. */
+ LA_SER_CONFIG = 0x08, /* Found through ldconfig. */
+ LA_SER_DEFAULT = 0x40, /* Default directory. */
+ LA_SER_SECURE = 0x80 /* Unused. */
+ };
+
+/* Values for la_objopen return value. */
+enum
+ {
+ LA_FLG_BINDTO = 0x01, /* Audit symbols bound to this object. */
+ LA_FLG_BINDFROM = 0x02 /* Audit symbols bound from this object. */
+ };
+
+/* Values for la_symbind flags parameter. */
+enum
+ {
+ LA_SYMB_NOPLTENTER = 0x01, /* la_pltenter will not be called. */
+ LA_SYMB_NOPLTEXIT = 0x02, /* la_pltexit will not be called. */
+ LA_SYMB_STRUCTCALL = 0x04, /* Return value is a structure. */
+ LA_SYMB_DLSYM = 0x08, /* Binding due to dlsym call. */
+ LA_SYMB_ALTVALUE = 0x10 /* Value has been changed by a previous
+ la_symbind call. */
+ };
+
+struct dl_phdr_info
+ {
+ ElfW(Addr) dlpi_addr;
+ const char *dlpi_name;
+ const ElfW(Phdr) *dlpi_phdr;
+ ElfW(Half) dlpi_phnum;
+
+ /* Note: Following members were introduced after the first
+ version of this structure was available. Check the SIZE
+ argument passed to the dl_iterate_phdr callback to determine
+ whether or not each later member is available. */
+
+ /* Incremented when a new object may have been added. */
+ __extension__ unsigned long long int dlpi_adds;
+ /* Incremented when an object may have been removed. */
+ __extension__ unsigned long long int dlpi_subs;
+
+ /* If there is a PT_TLS segment, its module ID as used in
+ TLS relocations, else zero. */
+ size_t dlpi_tls_modid;
+
+ /* The address of the calling thread's instance of this module's
+ PT_TLS segment, if it has one and it has been allocated
+ in the calling thread, otherwise a null pointer. */
+ void *dlpi_tls_data;
+ };
+
+__BEGIN_DECLS
+
+extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *,
+ size_t, void *),
+ void *__data);
+
+
+/* Prototypes for the ld.so auditing interfaces. These are not
+ defined anywhere in ld.so but instead have to be provided by the
+ auditing DSO. */
+extern unsigned int la_version (unsigned int __version);
+extern void la_activity (uintptr_t *__cookie, unsigned int __flag);
+extern char *la_objsearch (const char *__name, uintptr_t *__cookie,
+ unsigned int __flag);
+extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid,
+ uintptr_t *__cookie);
+extern void la_preinit (uintptr_t *__cookie);
+extern uintptr_t la_symbind32 (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook, uintptr_t *__defcook,
+ unsigned int *__flags, const char *__symname);
+extern uintptr_t la_symbind64 (Elf64_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook, uintptr_t *__defcook,
+ unsigned int *__flags, const char *__symname);
+extern unsigned int la_objclose (uintptr_t *__cookie);
+
+__END_DECLS
+
+#endif
+
#endif /* link.h */