aboutsummaryrefslogtreecommitdiff
path: root/elf/link.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-06-10 20:19:39 +0000
committerRoland McGrath <roland@gnu.org>1996-06-10 20:19:39 +0000
commitba79d61b44be92bb81cba28076792a856585c4a0 (patch)
tree1ece0cbcd4568069643327ffe5da7511394e3ff8 /elf/link.h
parent567c63af19d2f03836d14856596b4ae6259c03a8 (diff)
downloadglibc-ba79d61b44be92bb81cba28076792a856585c4a0.zip
glibc-ba79d61b44be92bb81cba28076792a856585c4a0.tar.gz
glibc-ba79d61b44be92bb81cba28076792a856585c4a0.tar.bz2
* Makerules ($(common-objpfx)libc.so): Depend on $(elfobjdir)/ld.so.cvs/libc-960611
* elf/dl-close.c: New file. * elf/link.h: Declare _dl_close. * elf/Makefile (routines): Add dl-close. * elf/dlclose.c (dlclose): Use _dl_close. * elf/Makefile ($(objpfx)librtld.so): Remove libelf from deps. * elf/dl-runtime.c (_dl_global_scope): New variable. (_dl_object_relocation_scope): New function. (fixup): Use it. * elf/rtld.c (dl_main): Use it. * elf/dl-open.c (_dl_open): Use it. If (MODE & RTLD_GLOBAL), set the l_global bit and append the new map to _dl_global_scope. * elf/link.h: Declare _dl_global_scope, _dl_global_scope_alloc, and _dl_object_relocation_scope. * elf/link.h (struct link_map): Add l_loader member. Remove _dl_map_object_from_fd decl. * elf/dl-load.c (_dl_map_object): Pass LOADER to ... (_dl_map_object_from_fd): Take new arg LOADER and set l_loader member. (_dl_map_object): Try DT_RPATH from all loaders up the chain. * elf/dl-object.c (_dl_loaded): Variable removed. (_dl_default_scope): New variable replaces it. * elf/link.h (_dl_loaded): Remove variable decl; instead define as macro for _dl_default_scope[2]. (_dl_default_scope): Declare it. * sysdeps/i386/dl-machine.h (RTLD_START): Use _dl_default_scope[2] instead of _dl_loaded. * sysdeps/m68k/dl-machine.h (RTLD_START): Likewise. * elf/rtld.c (dl_main): Use _dl_default_scope for symbol lookups. * elf/dl-reloc.c (_dl_relocate_object): Remove check for _dl_rtld_map. * elf/rtld.c (dl_main): Pass 0 for LAZY flag when re-relocating self. * elf/link.h (struct link_map.l_type): Remove lt_interpreter. (struct link_map): Add new flag member l_global. * elf/dl-reloc.c (_dl_relocate_object): Check for _dl_rtld_map directly instead of looking for lt_interpreter. * sysdeps/i386/dl-machine.h (elf_machine_rel): Likewise. * elf/rtld.c (_dl_start): Don't bother setting BOOTSTRAP_MAP.l_type. (dl_main): Set _dl_rtld_map.l_type to lt_library. * elf/dl-deps.c (_dl_map_object_deps): Propagate MAP->l_type to dependencies loaded, downgrading lt_executable -> lt_library. * elf/dl-load.c (_dl_map_object_from_fd): Take new arg TYPE and set l_type from that, translating lt_library->lt_executable based on the file's ELF type. (_dl_map_object): Likewise. * elf/link.h: Update prototypes. * elf/dl-open.c: Pass type lt_loaded. * elf/rtld.c: Pass type lt_library. * elf/dl-load.c (_dl_map_object_from_fd): Handle null return from _dl_new_object. (_dl_map_object_from_fd: lose): Unchain and free L if it's not null. Free REALNAME, and just use NAME in error message. * elf/dl-object.c (_dl_new_object): If malloc fails, return null instead of calling _dl_signal_error. * elf/dl-load.c (_dl_map_object_from_fd): Close FD before signalling error for _dl_zerofd setup failure. * elf/dl-object.c (_dl_startup_loaded): Variable removed. * elf/link.h: Remove its decl. * elf/dl-reloc.c (_dl_relocate_object): Take new SCOPE arg and pass it through to _dl_lookup_symbol. * elf/link.h (_dl_relocate_object): Update comment and prototype. * elf/rtld.c (dl_main): Pass scope vector to _dl_relocate_object. * elf/dl-lookup.c (_dl_lookup_symbol): Arg SYMBOL_SCOPE is now a null-terminated vector of pointers, no longer a vector of exactly two. * elf/link.h (_dl_lookup_symbol): Update comment and prototype. * elf/dl-runtime.c (fixup): Set up scope for symbol lookup properly as done in _dl_relocate_object. * elf/dlopen.c: Pass "" to _dl_open when FILE is null.
Diffstat (limited to 'elf/link.h')
-rw-r--r--elf/link.h68
1 files changed, 47 insertions, 21 deletions
diff --git a/elf/link.h b/elf/link.h
index 6d284cb..89dfa20 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -106,6 +106,9 @@ struct link_map
struct link_map **l_searchlist;
unsigned int l_nsearchlist;
+ /* Dependent object that first caused this object to be loaded. */
+ struct link_map *l_loader;
+
/* Symbol hash table. */
ElfW(Word) l_nbuckets;
const ElfW(Word) *l_buckets, *l_chain;
@@ -114,14 +117,14 @@ struct link_map
enum /* Where this object came from. */
{
lt_executable, /* The main executable program. */
- lt_interpreter, /* The interpreter: the dynamic linker. */
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_init_running:1; /* Nonzero while DT_INIT function runs. */
- unsigned int l_reserved:3; /* Reserved for internal use. */
+ unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */
+ unsigned int l_reserved:2; /* Reserved for internal use. */
};
/* Internal functions of the run-time dynamic linker.
@@ -188,12 +191,7 @@ extern int _dlerror_run (void (*operate) (void));
LOADER's DT_RPATH is used in searching for NAME.
If the object is already opened, returns its existing map. */
extern struct link_map *_dl_map_object (struct link_map *loader,
- const char *name);
-
-/* Similar, but file found at REALNAME and opened on FD.
- REALNAME must malloc'd storage and is used in internal data structures. */
-extern struct link_map *_dl_map_object_from_fd (const char *name,
- int fd, char *realname);
+ const char *name, int type);
/* Call _dl_map_object on the dependencies of MAP, and
set up MAP->l_searchlist. */
@@ -210,21 +208,24 @@ extern void _dl_setup_hash (struct link_map *map);
extern struct link_map *_dl_open (struct link_map *loader,
const char *name, int mode);
+/* Close an object previously opened by _dl_open. */
+extern void _dl_close (struct link_map *map);
/* Search loaded objects' symbol tables for a definition of the symbol
referred to by UNDEF. *SYM is the symbol table entry containing the
reference; it is replaced with the defining symbol, and the base load
- address of the defining object is returned. Each of SYMBOL_SCOPE[0] and
- SYMBOL_SCOPE[1] that is not null and their dependencies are searched to
- resolve the name. REFERENCE_NAME should name the object containing the
- reference; it is used in error messages. RELOC_ADDR is the address
- being fixed up and the chosen symbol cannot be one with this value. If
- NOPLT is nonzero, then the reference must not be resolved to a PLT
- entry. */
+ address of the defining object is returned. SYMBOL_SCOPE is a
+ null-terminated list of object scopes to search; each object's
+ l_searchlist (i.e. the segment of the dependency tree starting at that
+ object) is searched in turn. REFERENCE_NAME should name the object
+ containing the reference; it is used in error messages. RELOC_ADDR is
+ the address being fixed up and the chosen symbol cannot be one with this
+ value. If NOPLT is nonzero, then the reference must not be resolved to
+ a PLT entry. */
extern ElfW(Addr) _dl_lookup_symbol (const char *undef,
const ElfW(Sym) **sym,
- struct link_map *symbol_scope[2],
+ struct link_map *symbol_scope[],
const char *reference_name,
ElfW(Addr) reloc_addr,
int noplt);
@@ -236,11 +237,33 @@ extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name);
/* Structure describing the dynamic linker itself. */
extern struct link_map _dl_rtld_map;
-/* List of objects currently loaded. */
-extern struct link_map *_dl_loaded;
+/* The list of objects currently loaded is the third element of the
+ `_dl_default_scope' array, and the fourth element is always null.
+ This leaves two slots before it that are used when resolving
+ DT_SYMBOLIC objects' references one after it for normal references
+ (see below). */
+#define _dl_loaded (_dl_default_scope[2])
+extern struct link_map *_dl_default_scope[5];
+
+/* Null-terminated list of objects in the dynamic `global scope'. The
+ list starts at [2]; i.e. &_dl_global_scope[2] is the argument
+ passed to _dl_lookup_symbol to search the global scope. To search
+ a specific object and its dependencies in preference to the global
+ scope, fill in the [1] slot and pass its address; for two specific
+ object scopes, fill [0] and [1]. The list is double-terminated; to
+ search the global scope and then a specific object and its
+ dependencies, set *_dl_global_scope_end. This variable initially
+ points to _dl_default_scope, and _dl_loaded is always kept in [2]
+ of this list. A new list is malloc'd when new objects are loaded
+ with RTLD_GLOBAL. */
+extern struct link_map **_dl_global_scope, **_dl_global_scope_end;
+extern size_t _dl_global_scope_alloc; /* Number of slots malloc'd. */
+
+/* Hack _dl_global_scope[0] and [1] as necessary, and return a pointer into
+ _dl_global_scope that should be passed to _dl_lookup_symbol for symbol
+ references made in the object MAP's relocations. */
+extern struct link_map **_dl_object_relocation_scope (struct link_map *map);
-/* Tail of that list which were loaded at startup. */
-extern struct link_map *_dl_startup_loaded;
/* Allocate a `struct link_map' for a new object being loaded,
and enter it into the _dl_loaded list. */
@@ -248,8 +271,11 @@ extern struct link_map *_dl_new_object (char *realname, const char *libname,
int type);
/* Relocate the given object (if it hasn't already been).
+ SCOPE is passed to _dl_lookup_symbol in symbol lookups.
If LAZY is nonzero, don't relocate its PLT. */
-extern void _dl_relocate_object (struct link_map *map, int lazy);
+extern void _dl_relocate_object (struct link_map *map,
+ struct link_map *scope[],
+ int lazy);
/* Return the address of the next initializer function for MAP or one of
its dependencies that has not yet been run. When there are no more