mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 13:00:06 +00:00
e8ed861df7
2004-01-26 David Mosberger <davidm@hpl.hp.com> * elf/link.h (struct dl_phdr_info): Fix typo in comment. * elf/rtld.c (dl_main): After incrementing dl_nloaded, also increment dl_load_adds. * elf/dl-iteratephdr.c (__dl_iterate_phdr): Replace GL(dl_load_subs) with equivalent GL(dl_load_adds - GL(dl_nloaded). (dl_iterate_phdr): Likewise. * elf/dl-close.c (_dl_close): Delete increment of GL(dl_load_subs). * elf/dl-support.c: Remove global variable _dl_load_subs. * sysdeps/generic/ldsodefs.h (struct rtld_global): Remove _dl_load_subs member. 2004-01-27 Jakub Jelinek <jakub@redhat.com> * elf/rtld.c (_dl_start_final): Don't set l_relro_* here. (_dl_start): And neither here. (dl_main): Set GL(dl_loaded)->l_relro_* and GL(dl_rtld_map)->l_relro_*.
126 lines
4.5 KiB
C
126 lines
4.5 KiB
C
/* Data structure for communication from the run-time dynamic linker for
|
|
loaded ELF shared objects.
|
|
Copyright (C) 1995-1999, 2000, 2001, 2004 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 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, write to the Free
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307 USA. */
|
|
|
|
#ifndef _LINK_H
|
|
#define _LINK_H 1
|
|
|
|
#include <features.h>
|
|
#include <elf.h>
|
|
#include <dlfcn.h>
|
|
#include <sys/types.h>
|
|
|
|
/* We use this macro to refer to ELF types independent of the native wordsize.
|
|
`ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
|
|
#define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type)
|
|
#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
|
|
#define _ElfW_1(e,w,t) e##w##t
|
|
|
|
#include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */
|
|
|
|
/* Rendezvous structure used by the run-time dynamic linker to communicate
|
|
details of shared object loading to the debugger. If the executable's
|
|
dynamic section has a DT_DEBUG element, the run-time linker sets that
|
|
element's value to the address where this structure can be found. */
|
|
|
|
struct r_debug
|
|
{
|
|
int r_version; /* Version number for this protocol. */
|
|
|
|
struct link_map *r_map; /* Head of the chain of loaded objects. */
|
|
|
|
/* This is the address of a function internal to the run-time linker,
|
|
that will always be called when the linker begins to map in a
|
|
library or unmap it, and again when the mapping change is complete.
|
|
The debugger can set a breakpoint at this address if it wants to
|
|
notice shared object mapping changes. */
|
|
ElfW(Addr) r_brk;
|
|
enum
|
|
{
|
|
/* This state value describes the mapping change taking place when
|
|
the `r_brk' address is called. */
|
|
RT_CONSISTENT, /* Mapping change is complete. */
|
|
RT_ADD, /* Beginning to add a new object. */
|
|
RT_DELETE /* Beginning to remove an object mapping. */
|
|
} r_state;
|
|
|
|
ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */
|
|
};
|
|
|
|
/* This is the instance of that structure used by the dynamic linker. */
|
|
extern struct r_debug _r_debug;
|
|
|
|
/* This symbol refers to the "dynamic structure" in the `.dynamic' section
|
|
of whatever module refers to `_DYNAMIC'. So, to find its own
|
|
`struct r_debug', a program could do:
|
|
for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn)
|
|
if (dyn->d_tag == DT_DEBUG)
|
|
r_debug = (struct r_debug *) dyn->d_un.d_ptr;
|
|
*/
|
|
extern ElfW(Dyn) _DYNAMIC[];
|
|
|
|
/* 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. */
|
|
|
|
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. */
|
|
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. */
|
|
};
|
|
|
|
#ifdef __USE_GNU
|
|
|
|
struct dl_phdr_info
|
|
{
|
|
ElfW(Addr) dlpi_addr;
|
|
const char *dlpi_name;
|
|
const ElfW(Phdr) *dlpi_phdr;
|
|
ElfW(Half) dlpi_phnum;
|
|
|
|
/* Note: the next two 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 they are provided. */
|
|
|
|
/* Incremented when a new object may have been added. */
|
|
unsigned long long int dlpi_adds;
|
|
/* Incremented when an object may have been removed. */
|
|
unsigned long long int dlpi_subs;
|
|
};
|
|
|
|
__BEGIN_DECLS
|
|
|
|
extern int dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
|
|
size_t size, void *data),
|
|
void *data);
|
|
|
|
__END_DECLS
|
|
|
|
#endif
|
|
|
|
#endif /* link.h */
|