4 #include <dl-string.h> /* before elf.h to get ELF_USES_RELOCA right */
8 /* Forward declarations for stuff defined in ld_hash.h */
13 #ifdef __LDSO_CACHE_SUPPORT__
14 extern int _dl_map_cache(void);
15 extern int _dl_unmap_cache(void);
17 static inline void _dl_map_cache(void) { }
18 static inline void _dl_unmap_cache(void) { }
22 /* Function prototypes for non-static stuff in readelflib1.c */
23 extern void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
24 unsigned long rel_addr, unsigned long rel_size);
25 extern int _dl_parse_relocation_information(struct dyn_elf *rpnt,
26 unsigned long rel_addr, unsigned long rel_size);
27 extern struct elf_resolve * _dl_load_shared_library(int secure,
28 struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
29 int trace_loaded_objects);
30 extern struct elf_resolve * _dl_load_elf_shared_library(int secure,
31 struct dyn_elf **rpnt, char *libname);
32 extern struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
33 int trace_loaded_objects);
34 extern int _dl_linux_resolve(void);
35 extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
36 extern void _dl_protect_relro (struct elf_resolve *l);
39 * Datatype of a relocation on this platform
41 #ifdef ELF_USES_RELOCA
42 # define ELF_RELOC ElfW(Rela)
43 # define DT_RELOC_TABLE_ADDR DT_RELA
44 # define DT_RELOC_TABLE_SIZE DT_RELASZ
45 # define DT_RELOCCOUNT DT_RELACOUNT
46 # define UNSUPPORTED_RELOC_TYPE DT_REL
47 # define UNSUPPORTED_RELOC_STR "REL"
49 # define ELF_RELOC ElfW(Rel)
50 # define DT_RELOC_TABLE_ADDR DT_REL
51 # define DT_RELOC_TABLE_SIZE DT_RELSZ
52 # define DT_RELOCCOUNT DT_RELCOUNT
53 # define UNSUPPORTED_RELOC_TYPE DT_RELA
54 # define UNSUPPORTED_RELOC_STR "RELA"
57 /* OS and/or GNU dynamic extensions */
59 #define DT_RELCONT_IDX DT_NUM
61 #ifndef ARCH_DYNAMIC_INFO
62 /* define in arch specific code, if needed */
66 #define DYNAMIC_SIZE (DT_NUM+OS_NUM+ARCH_NUM)
68 extern void _dl_parse_dynamic_info(Elf32_Dyn *dpnt, unsigned long dynamic_info[], void *debug_addr);
70 static inline __attribute__((always_inline))
71 void __dl_parse_dynamic_info(Elf32_Dyn *dpnt, unsigned long dynamic_info[], void *debug_addr)
73 for (; dpnt->d_tag; dpnt++) {
74 if (dpnt->d_tag < DT_NUM) {
75 dynamic_info[dpnt->d_tag] = dpnt->d_un.d_val;
77 if (dpnt->d_tag == DT_DEBUG)
78 dpnt->d_un.d_val = (unsigned long)debug_addr;
80 if (dpnt->d_tag == DT_BIND_NOW)
81 dynamic_info[DT_BIND_NOW] = 1;
82 if (dpnt->d_tag == DT_FLAGS &&
83 (dpnt->d_un.d_val & DF_BIND_NOW))
84 dynamic_info[DT_BIND_NOW] = 1;
85 if (dpnt->d_tag == DT_TEXTREL)
86 dynamic_info[DT_TEXTREL] = 1;
87 } else if (dpnt->d_tag < DT_LOPROC) {
88 if (dpnt->d_tag == DT_RELOCCOUNT)
89 dynamic_info[DT_RELCONT_IDX] = dpnt->d_un.d_val;
90 if (dpnt->d_tag == DT_FLAGS_1 &&
91 (dpnt->d_un.d_val & DF_1_NOW))
92 dynamic_info[DT_BIND_NOW] = 1;
94 #ifdef ARCH_DYNAMIC_INFO
96 ARCH_DYNAMIC_INFO(dpnt, dynamic_info, debug_addr);
102 /* Reloc type classes as returned by elf_machine_type_class().
103 ELF_RTYPE_CLASS_PLT means this reloc should not be satisfied by
104 some PLT symbol, ELF_RTYPE_CLASS_COPY means this reloc should not be
105 satisfied by any symbol in the executable. Some architectures do
106 not support copy relocations. In this case we define the macro to
107 zero so that the code for handling them gets automatically optimized
109 #ifdef DL_NO_COPY_RELOCS
110 # define ELF_RTYPE_CLASS_COPY (0x0)
112 # define ELF_RTYPE_CLASS_COPY (0x2)
114 #define ELF_RTYPE_CLASS_PLT (0x1)
117 /* Convert between the Linux flags for page protections and the
118 ones specified in the ELF standard. */
119 #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
120 (((X) & PF_W) ? PROT_WRITE : 0) | \
121 (((X) & PF_X) ? PROT_EXEC : 0))
124 #endif /* LINUXELF_H */