⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ldsodefs.h

📁 Newlib 嵌入式 C库 标准实现代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Run-time dynamic linker data structures for loaded ELF shared objects.   Copyright (C) 1995-1999, 2000, 2001 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	_LDSODEFS_H#define	_LDSODEFS_H	1#include <features.h>#define __need_size_t#define __need_NULL#include <stddef.h>#include <string.h>#include <elf.h>#include <link.h>#include <dl-lookupcfg.h>#include <bits/libc-lock.h>#include "dl-local.h"__BEGIN_DECLS/* 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 internal_function /* All references to the value of l_info[DT_PLTGOT],  l_info[DT_STRTAB], l_info[DT_SYMTAB], l_info[DT_RELA],  l_info[DT_REL], l_info[DT_JMPREL], and l_info[VERSYMIDX (DT_VERSYM)]  have to be accessed via the D_PTR macro.  The macro is needed since for  most architectures the entry is already relocated - but for some not  and we need to relocate at access time.  */#ifdef DL_RO_DYN_SECTION# define D_PTR(map,i) (map->i->d_un.d_ptr + map->l_addr)#else# define D_PTR(map,i) map->i->d_un.d_ptr#endif/* On some platforms more information than just the address of the symbol   is needed from the lookup functions.  In this case we return the whole   link map.  */#ifdef DL_LOOKUP_RETURNS_MAPtypedef struct link_map *lookup_t;# define LOOKUP_VALUE(map) map# define LOOKUP_VALUE_ADDRESS(map) (map ? map->l_addr : 0)#elsetypedef ElfW(Addr) lookup_t;# define LOOKUP_VALUE(map) map->l_addr# define LOOKUP_VALUE_ADDRESS(address) address#endif/* on some architectures a pointer to a function is not just a pointer   to the actual code of the function but rather an architecture   specific descriptor. */#ifndef ELF_FUNCTION_PTR_IS_SPECIAL# define DL_SYMBOL_ADDRESS(map, ref) \ (void *) (LOOKUP_VALUE_ADDRESS (map) + ref->st_value)# define DL_LOOKUP_ADDRESS(addr) ((ElfW(Addr)) (addr))# define DL_DT_INIT_ADDRESS(map, start) (start)# define DL_DT_FINI_ADDRESS(map, start) (start)#endif/* Unmap a loaded object, called by _dl_close (). */#ifndef DL_UNMAP_IS_SPECIAL# define DL_UNMAP(map) \ __munmap ((void *) (map)->l_map_start,					      \	   (map)->l_map_end - (map)->l_map_start)#endif/* By default we do not need special support to initialize DSOs loaded   by statically linked binaries.  */#ifndef DL_STATIC_INIT# define DL_STATIC_INIT(map)#endif/* Reloc type classes as returned by elf_machine_type_class().   ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by   some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be   satisfied by any symbol in the executable.  */#define ELF_RTYPE_CLASS_PLT 1#define ELF_RTYPE_CLASS_COPY 2/* ELF uses the PF_x macros to specify the segment permissions, mmap   uses PROT_xxx.  In most cases the three macros have the values 1, 2,   and 3 but not in a matching order.  The following macros allows   converting from the PF_x values to PROT_xxx values.  */#define PF_TO_PROT \  ((PROT_READ << (PF_R * 4))						      \   | (PROT_WRITE << (PF_W * 4))						      \   | (PROT_EXEC << (PF_X * 4))						      \   | ((PROT_READ | PROT_WRITE) << ((PF_R | PF_W) * 4))			      \   | ((PROT_READ | PROT_EXEC) << ((PF_R | PF_X) * 4))			      \   | ((PROT_WRITE | PROT_EXEC) << (PF_W | PF_X) * 4)			      \   | ((PROT_READ | PROT_WRITE | PROT_EXEC) << ((PF_R | PF_W | PF_X) * 4)))/* For the version handling we need an array with only names and their   hash values.  */struct r_found_version  {    const char *name;    ElfW(Word) hash;    int hidden;    const char *filename;  };/* We want to cache information about the searches for shared objects.  */enum r_dir_status { unknown, nonexisting, existing };struct r_search_path_elem  {    /* This link is only used in the `all_dirs' member of `r_search_path'.  */    struct r_search_path_elem *next;    /* Strings saying where the definition came from.  */    const char *what;    const char *where;    /* Basename for this search path element.  The string must end with       a slash character.  */    const char *dirname;    size_t dirnamelen;    enum r_dir_status status[0];  };struct r_strlenpair  {    const char *str;    size_t len;  };/* A data structure for a simple single linked list of strings.  */struct libname_list  {    const char *name;		/* Name requested (before search).  */    struct libname_list *next;	/* Link to next name for this object.  */    int dont_free;		/* Flag whether this element should be freed				   if the object is not entirely unloaded.  */  };/* Test whether given NAME matches any of the names of the given object.  */static __inline int__attribute__ ((unused))_dl_name_match_p (const char *__name, struct link_map *__map){  int __found = strcmp (__name, __map->l_name) == 0;  struct libname_list *__runp = __map->l_libname;  while (! __found && __runp != NULL)    if (strcmp (__name, __runp->name) == 0)      __found = 1;    else      __runp = __runp->next;  return __found;}/* Function used as argument for `_dl_receive_error' function.  The   arguments are the error code, error string, and the objname the   error occurred in.  */typedef void (*receiver_fct) (int, const char *, const char *);/* Internal functions of the run-time dynamic linker.   These can be accessed if you link again the dynamic linker   as a shared library, as in `-lld' or `/lib/ld.so' explicitly;   but are not normally of interest to user programs.   The `-ldl' library functions in <dlfcn.h> provide a simple   user interface to run-time dynamic linking.  *//* Parameters passed to the dynamic linker.  */extern char **_dl_argv;/* Cached value of `getpagesize ()'.  */extern size_t _dl_pagesize;/* OS version.  */extern unsigned int _dl_osversion;/* File descriptor referring to the zero-fill device.  */extern int _dl_zerofd;/* Name of the shared object to be profiled (if any).  */extern const char *_dl_profile;/* Map of shared object to be profiled.  */extern struct link_map *_dl_profile_map;/* Filename of the output file.  */extern const char *_dl_profile_output;/* If nonzero the appropriate debug information is printed.  */extern int _dl_debug_mask;#define DL_DEBUG_LIBS	    (1 << 0)#define DL_DEBUG_IMPCALLS   (1 << 1)#define DL_DEBUG_BINDINGS   (1 << 2)#define DL_DEBUG_SYMBOLS    (1 << 3)#define DL_DEBUG_VERSIONS   (1 << 4)#define DL_DEBUG_RELOC      (1 << 5)#define DL_DEBUG_FILES      (1 << 6)#define DL_DEBUG_STATISTICS (1 << 7)/* This one is used only internally.  */#define DL_DEBUG_HELP       (1 << 8)/* Expect cache ID.  */extern int _dl_correct_cache_id;/* Mask for hardware capabilities that are available.  */extern unsigned long int _dl_hwcap;/* Mask for important hardware capabilities we honour. */extern unsigned long int _dl_hwcap_mask;/* File descriptor to write debug messages to.  */extern int _dl_debug_fd;/* Names of shared object for which the RPATH should be ignored.  */extern const char *_dl_inhibit_rpath;/* Nonzero if references should be treated as weak during runtime linking.  */extern int _dl_dynamic_weak;/* The array with message we print as a last resort.  */extern const char _dl_out_of_memory[];/* Nonzero if runtime lookups should not update the .got/.plt.  */extern int _dl_bind_not;/* List of search directories.  */extern struct r_search_path_elem *_dl_all_dirs;extern struct r_search_path_elem *_dl_init_all_dirs;/* OS-dependent function to open the zero-fill device.  */extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c *//* During the program run we must not modify the global data of   loaded shared object simultanously in two threads.  Therefore we   protect `_dl_open' and `_dl_close' in dl-close.c.   This must be a recursive lock since the initializer function of   the loaded object might as well require a call to this function.   At this time it is not anymore a problem to modify the tables.  */__libc_lock_define_recursive (extern, _dl_load_lock)/* Write message on the debug file descriptor.  The parameters are   interpreted as for a `printf' call.  All the lines start with a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -