123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- #ifndef _LDSODEFS_H
- #define _LDSODEFS_H 1
- #include <stdbool.h>
- #define __need_size_t
- #define __need_NULL
- #include <stddef.h>
- #include <sys/mman.h>
- #include <elf/elf.h>
- #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
- extern ElfW(Dyn) _DYNAMIC[];
- #define ELFW(type) _ElfW (ELF, __ELF_NATIVE_CLASS, type)
- #define D_PTR(sym) (sym)->d_un.d_ptr
- #if 0
- #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
- #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
- #endif
- #define DL_ADDR_SYM_MATCH(L, SYM, MATCHSYM, ADDR) \
- ((ADDR) >= (L)->l_addr + (SYM)->st_value \
- && ((((SYM)->st_shndx == SHN_UNDEF || (SYM)->st_size == 0) \
- && (ADDR) == (L)->l_addr + (SYM)->st_value) \
- || (ADDR) < (L)->l_addr + (SYM)->st_value + (SYM)->st_size) \
- && ((MATCHSYM) == NULL || (MATCHSYM)->st_value < (SYM)->st_value))
- #ifndef DL_UNMAP_IS_SPECIAL
- # define DL_UNMAP(map) \
- __munmap ((void *) (map)->l_map_start, \
- (map)->l_map_end - (map)->l_map_start)
- #endif
- #ifndef DL_STATIC_INIT
- # define DL_STATIC_INIT(map)
- #endif
- #define ELF_RTYPE_CLASS_PLT 1
- #ifndef DL_NO_COPY_RELOCS
- # define ELF_RTYPE_CLASS_COPY 2
- #else
- # define ELF_RTYPE_CLASS_COPY 0
- #endif
- #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)))
- struct r_found_version
- {
- const char *name;
- ElfW(Word) hash;
- int hidden;
- const char *filename;
- };
- enum r_dir_status { unknown, nonexisting, existing };
- struct r_search_path_elem
- {
-
- struct r_search_path_elem *next;
-
- const char *what;
- const char *where;
-
- const char *dirname;
- size_t dirnamelen;
- enum r_dir_status status[0];
- };
- struct r_strlenpair
- {
- const char *str;
- size_t len;
- };
- struct libname_list
- {
- const char *name;
- struct libname_list *next;
- int dont_free;
- };
- enum allowmask
- {
- allow_libc = 1,
- allow_libdl = 2,
- allow_libpthread = 4,
- allow_ldso = 8
- };
- enum
- {
-
- dl_lookup_add_dependency = 1,
-
- dl_lookup_return_newest = 2,
-
- dl_lookup_gscope_lock = 4,
- };
- #define DL_LOOKUP_ADD_DEPENDENCY dl_lookup_add_dependency
- #define DL_LOOKUP_RETURN_NEWEST dl_lookup_return_newest
- #define DL_LOOKUP_GSCOPE_LOCK dl_lookup_gscope_lock
- #endif
|