|
Packit Service |
82fcde |
/* Data structure for communication from the run-time dynamic linker for
|
|
Packit Service |
82fcde |
loaded ELF shared objects.
|
|
Packit Service |
82fcde |
Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef _LINK_H
|
|
Packit Service |
82fcde |
#define _LINK_H 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <features.h>
|
|
Packit Service |
82fcde |
#include <elf.h>
|
|
Packit Service |
82fcde |
#include <dlfcn.h>
|
|
Packit Service |
82fcde |
#include <sys/types.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* We use this macro to refer to ELF types independent of the native wordsize.
|
|
Packit Service |
82fcde |
`ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
|
|
Packit Service |
82fcde |
#define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
|
|
Packit Service |
82fcde |
#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
|
|
Packit Service |
82fcde |
#define _ElfW_1(e,w,t) e##w##t
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */
|
|
Packit Service |
82fcde |
#include <bits/link.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Rendezvous structure used by the run-time dynamic linker to communicate
|
|
Packit Service |
82fcde |
details of shared object loading to the debugger. If the executable's
|
|
Packit Service |
82fcde |
dynamic section has a DT_DEBUG element, the run-time linker sets that
|
|
Packit Service |
82fcde |
element's value to the address where this structure can be found. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
struct r_debug
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int r_version; /* Version number for this protocol. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
struct link_map *r_map; /* Head of the chain of loaded objects. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* This is the address of a function internal to the run-time linker,
|
|
Packit Service |
82fcde |
that will always be called when the linker begins to map in a
|
|
Packit Service |
82fcde |
library or unmap it, and again when the mapping change is complete.
|
|
Packit Service |
82fcde |
The debugger can set a breakpoint at this address if it wants to
|
|
Packit Service |
82fcde |
notice shared object mapping changes. */
|
|
Packit Service |
82fcde |
ElfW(Addr) r_brk;
|
|
Packit Service |
82fcde |
enum
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* This state value describes the mapping change taking place when
|
|
Packit Service |
82fcde |
the `r_brk' address is called. */
|
|
Packit Service |
82fcde |
RT_CONSISTENT, /* Mapping change is complete. */
|
|
Packit Service |
82fcde |
RT_ADD, /* Beginning to add a new object. */
|
|
Packit Service |
82fcde |
RT_DELETE /* Beginning to remove an object mapping. */
|
|
Packit Service |
82fcde |
} r_state;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* This is the instance of that structure used by the dynamic linker. */
|
|
Packit Service |
82fcde |
extern struct r_debug _r_debug;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* This symbol refers to the "dynamic structure" in the `.dynamic' section
|
|
Packit Service |
82fcde |
of whatever module refers to `_DYNAMIC'. So, to find its own
|
|
Packit Service |
82fcde |
`struct r_debug', a program could do:
|
|
Packit Service |
82fcde |
for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn)
|
|
Packit Service |
82fcde |
if (dyn->d_tag == DT_DEBUG)
|
|
Packit Service |
82fcde |
r_debug = (struct r_debug *) dyn->d_un.d_ptr;
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
extern ElfW(Dyn) _DYNAMIC[];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
|
|
Packit Service |
82fcde |
members form a chain of all the shared objects loaded at startup.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
These data structures exist in space used by the run-time dynamic linker;
|
|
Packit Service |
82fcde |
modifying them may have disastrous results. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
struct link_map
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
/* These first few members are part of the protocol with the debugger.
|
|
Packit Service |
82fcde |
This is the same format used in SVR4. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ElfW(Addr) l_addr; /* Difference between the address in the ELF
|
|
Packit Service |
82fcde |
file and the addresses in memory. */
|
|
Packit Service |
82fcde |
char *l_name; /* Absolute file name object was found in. */
|
|
Packit Service |
82fcde |
ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
|
|
Packit Service |
82fcde |
struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __USE_GNU
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Version numbers for la_version handshake interface. */
|
|
Packit Service |
82fcde |
#define LAV_CURRENT 1
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Activity types signaled through la_activity. */
|
|
Packit Service |
82fcde |
enum
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
LA_ACT_CONSISTENT, /* Link map consistent again. */
|
|
Packit Service |
82fcde |
LA_ACT_ADD, /* New object will be added. */
|
|
Packit Service |
82fcde |
LA_ACT_DELETE /* Objects will be removed. */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Values representing origin of name for dynamic loading. */
|
|
Packit Service |
82fcde |
enum
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
LA_SER_ORIG = 0x01, /* Original name. */
|
|
Packit Service |
82fcde |
LA_SER_LIBPATH = 0x02, /* Directory from LD_LIBRARY_PATH. */
|
|
Packit Service |
82fcde |
LA_SER_RUNPATH = 0x04, /* Directory from RPATH/RUNPATH. */
|
|
Packit Service |
82fcde |
LA_SER_CONFIG = 0x08, /* Found through ldconfig. */
|
|
Packit Service |
82fcde |
LA_SER_DEFAULT = 0x40, /* Default directory. */
|
|
Packit Service |
82fcde |
LA_SER_SECURE = 0x80 /* Unused. */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Values for la_objopen return value. */
|
|
Packit Service |
82fcde |
enum
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
LA_FLG_BINDTO = 0x01, /* Audit symbols bound to this object. */
|
|
Packit Service |
82fcde |
LA_FLG_BINDFROM = 0x02 /* Audit symbols bound from this object. */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Values for la_symbind flags parameter. */
|
|
Packit Service |
82fcde |
enum
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
LA_SYMB_NOPLTENTER = 0x01, /* la_pltenter will not be called. */
|
|
Packit Service |
82fcde |
LA_SYMB_NOPLTEXIT = 0x02, /* la_pltexit will not be called. */
|
|
Packit Service |
82fcde |
LA_SYMB_STRUCTCALL = 0x04, /* Return value is a structure. */
|
|
Packit Service |
82fcde |
LA_SYMB_DLSYM = 0x08, /* Binding due to dlsym call. */
|
|
Packit Service |
82fcde |
LA_SYMB_ALTVALUE = 0x10 /* Value has been changed by a previous
|
|
Packit Service |
82fcde |
la_symbind call. */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
struct dl_phdr_info
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
ElfW(Addr) dlpi_addr;
|
|
Packit Service |
82fcde |
const char *dlpi_name;
|
|
Packit Service |
82fcde |
const ElfW(Phdr) *dlpi_phdr;
|
|
Packit Service |
82fcde |
ElfW(Half) dlpi_phnum;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Note: Following members were introduced after the first
|
|
Packit Service |
82fcde |
version of this structure was available. Check the SIZE
|
|
Packit Service |
82fcde |
argument passed to the dl_iterate_phdr callback to determine
|
|
Packit Service |
82fcde |
whether or not each later member is available. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Incremented when a new object may have been added. */
|
|
Packit Service |
82fcde |
__extension__ unsigned long long int dlpi_adds;
|
|
Packit Service |
82fcde |
/* Incremented when an object may have been removed. */
|
|
Packit Service |
82fcde |
__extension__ unsigned long long int dlpi_subs;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* If there is a PT_TLS segment, its module ID as used in
|
|
Packit Service |
82fcde |
TLS relocations, else zero. */
|
|
Packit Service |
82fcde |
size_t dlpi_tls_modid;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* The address of the calling thread's instance of this module's
|
|
Packit Service |
82fcde |
PT_TLS segment, if it has one and it has been allocated
|
|
Packit Service |
82fcde |
in the calling thread, otherwise a null pointer. */
|
|
Packit Service |
82fcde |
void *dlpi_tls_data;
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
__BEGIN_DECLS
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *,
|
|
Packit Service |
82fcde |
size_t, void *),
|
|
Packit Service |
82fcde |
void *__data);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Prototypes for the ld.so auditing interfaces. These are not
|
|
Packit Service |
82fcde |
defined anywhere in ld.so but instead have to be provided by the
|
|
Packit Service |
82fcde |
auditing DSO. */
|
|
Packit Service |
82fcde |
extern unsigned int la_version (unsigned int __version);
|
|
Packit Service |
82fcde |
extern void la_activity (uintptr_t *__cookie, unsigned int __flag);
|
|
Packit Service |
82fcde |
extern char *la_objsearch (const char *__name, uintptr_t *__cookie,
|
|
Packit Service |
82fcde |
unsigned int __flag);
|
|
Packit Service |
82fcde |
extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid,
|
|
Packit Service |
82fcde |
uintptr_t *__cookie);
|
|
Packit Service |
82fcde |
extern void la_preinit (uintptr_t *__cookie);
|
|
Packit Service |
82fcde |
extern uintptr_t la_symbind32 (Elf32_Sym *__sym, unsigned int __ndx,
|
|
Packit Service |
82fcde |
uintptr_t *__refcook, uintptr_t *__defcook,
|
|
Packit Service |
82fcde |
unsigned int *__flags, const char *__symname);
|
|
Packit Service |
82fcde |
extern uintptr_t la_symbind64 (Elf64_Sym *__sym, unsigned int __ndx,
|
|
Packit Service |
82fcde |
uintptr_t *__refcook, uintptr_t *__defcook,
|
|
Packit Service |
82fcde |
unsigned int *__flags, const char *__symname);
|
|
Packit Service |
82fcde |
extern unsigned int la_objclose (uintptr_t *__cookie);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
__END_DECLS
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#endif /* link.h */
|