summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/a.out.h5
-rw-r--r--include/alloca.h41
-rw-r--r--include/dlfcn.h98
-rw-r--r--include/link.h208
4 files changed, 352 insertions, 0 deletions
diff --git a/include/a.out.h b/include/a.out.h
new file mode 100644
index 000000000..d963de74c
--- /dev/null
+++ b/include/a.out.h
@@ -0,0 +1,5 @@
+#ifdef _LIBC
+# include_next <linux/a.out.h>
+#else
+# include <linux/a.out.h>
+#endif
diff --git a/include/alloca.h b/include/alloca.h
new file mode 100644
index 000000000..741eca743
--- /dev/null
+++ b/include/alloca.h
@@ -0,0 +1,41 @@
+/* Copyright (C) 1992, 1996, 1997, 1998 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.
+
+ 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.
+
+ 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. */
+
+#ifndef _ALLOCA_H
+#define _ALLOCA_H 1
+
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+__BEGIN_DECLS
+
+/* Remove any previous definitions. */
+#undef alloca
+
+/* Allocate a block that will be freed when the calling function exits. */
+extern __ptr_t alloca __P ((size_t __size));
+
+#ifdef __GNUC__
+# define alloca(size) __builtin_alloca (size)
+#endif /* GCC. */
+
+__END_DECLS
+
+#endif /* alloca.h */
diff --git a/include/dlfcn.h b/include/dlfcn.h
new file mode 100644
index 000000000..998350baa
--- /dev/null
+++ b/include/dlfcn.h
@@ -0,0 +1,98 @@
+/* User functions for run-time dynamic loading.
+ Copyright (C) 1995-1999, 2000 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.
+
+ 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.
+
+ 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. */
+
+#ifndef _DLFCN_H
+#define _DLFCN_H 1
+
+#include <features.h>
+
+/* Collect various system dependent definitions and declarations. */
+#include <bits/dlfcn.h>
+
+/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT
+ the run-time address of the symbol called NAME in the next shared
+ object is returned. The "next" relation is defined by the order
+ the shared objects were loaded. */
+#define RTLD_NEXT ((void *) -1l)
+
+/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT
+ the run-time address of the symbol called NAME in the global scope
+ is returned. */
+#define RTLD_DEFAULT ((void *) 0)
+
+__BEGIN_DECLS
+
+/* Open the shared object FILE and map it in; return a handle that can be
+ passed to `dlsym' to get symbol values from it. */
+extern void *dlopen __P ((__const char *__file, int __mode));
+
+/* Unmap and close a shared object opened by `dlopen'.
+ The handle cannot be used again after calling `dlclose'. */
+extern int dlclose __P ((void *__handle));
+
+/* Find the run-time address in the shared object HANDLE refers to
+ of the symbol called NAME. */
+extern void *dlsym __P ((void *__restrict __handle,
+ __const char *__restrict __name));
+
+#ifdef __USE_GNU
+/* Find the run-time address in the shared object HANDLE refers to
+ of the symbol called NAME with VERSION. */
+extern void *dlvsym __P ((void *__restrict __handle,
+ __const char *__restrict __name,
+ __const char *__restrict __version));
+#endif
+
+/* When any of the above functions fails, call this function
+ to return a string describing the error. Each call resets
+ the error string so that a following call returns null. */
+extern char *dlerror __P ((void));
+
+#ifdef __USE_GNU
+/* Fill in *INFO with the following information about ADDRESS.
+ Returns 0 iff no shared object's segments contain that address. */
+typedef struct
+ {
+ __const char *dli_fname; /* File name of defining object. */
+ void *dli_fbase; /* Load address of that object. */
+ __const char *dli_sname; /* Name of nearest symbol. */
+ void *dli_saddr; /* Exact value of nearest symbol. */
+ } Dl_info;
+extern int dladdr __P ((const void *__address, Dl_info *__info));
+
+/* To support profiling of shared objects it is a good idea to call
+ the function found using `dlsym' using the following macro since
+ these calls do not use the PLT. But this would mean the dynamic
+ loader has no chance to find out when the function is called. The
+ macro applies the necessary magic so that profiling is possible.
+ Rewrite
+ foo = (*fctp) (arg1, arg2);
+ into
+ foo = DL_CALL_FCT (fctp, (arg1, arg2));
+*/
+# define DL_CALL_FCT(fctp, args) \
+ (_dl_mcount_wrapper_check (fctp), (*(fctp)) args)
+
+/* This function calls the profiling functions. */
+extern void _dl_mcount_wrapper_check __P ((void *__selfpc));
+#endif
+
+__END_DECLS
+
+#endif /* dlfcn.h */
diff --git a/include/link.h b/include/link.h
new file mode 100644
index 000000000..070eabb6d
--- /dev/null
+++ b/include/link.h
@@ -0,0 +1,208 @@
+/* Data structure for communication from the run-time dynamic linker for
+ loaded ELF shared objects.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999 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.
+
+ 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.
+
+ 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. */
+
+#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[];
+
+
+/* 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. */
+
+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. */
+
+ /* 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_PROCNUM) are indexed by the tag minus DT_LOPROC.
+ [DT_NUM+DT_PROCNUM,DT_NUM+DT_PROCNUM+DT_EXTRANUM) are indexed
+ by DT_EXTRATAGIDX(tagvalue) and
+ [DT_NUM+DT_PROCNUM+DT_VERSIONTAGNUM,
+ DT_NUM+DT_PROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM)
+ are indexed by DT_EXTRATAGIDX(tagvalue) (see <elf.h>). */
+
+ ElfW(Dyn) *l_info[DT_NUM + DT_PROCNUM + 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. */
+
+ /* 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. */
+ ElfW(Symndx) l_nbuckets;
+ const ElfW(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_init_running:1; /* Nonzero while DT_INIT function runs. */
+ unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */
+ unsigned int l_reserved:2; /* Reserved for internal use. */
+
+ /* 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(Half) *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;
+
+ /* Nonzero if the data structure pointed to by `l_phdr' is allocated. */
+ int l_phdr_allocated;
+ };
+
+#endif /* link.h */