• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _INTERNAL_RELOC_H
2 #define _INTERNAL_RELOC_H
3 
4 #include <features.h>
5 #include <elf.h>
6 #include <stdint.h>
7 #include <stddef.h>
8 #include <stdarg.h>
9 
10 #if UINTPTR_MAX == 0xffffffff
11 typedef Elf32_Ehdr Ehdr;
12 typedef Elf32_Phdr Phdr;
13 typedef Elf32_Sym Sym;
14 #define R_TYPE(x) ((x)&255)
15 #define R_SYM(x) ((x)>>8)
16 #define R_INFO ELF32_R_INFO
17 #else
18 typedef Elf64_Ehdr Ehdr;
19 typedef Elf64_Phdr Phdr;
20 typedef Elf64_Sym Sym;
21 #define R_TYPE(x) ((x)&0x7fffffff)
22 #define R_SYM(x) ((x)>>32)
23 #define R_INFO ELF64_R_INFO
24 #endif
25 
26 /* These enum constants provide unmatchable default values for
27  * any relocation type the arch does not use. */
28 enum {
29 	REL_NONE = 0,
30 	REL_SYMBOLIC = -100,
31 	REL_USYMBOLIC,
32 	REL_GOT,
33 	REL_PLT,
34 	REL_RELATIVE,
35 	REL_OFFSET,
36 	REL_OFFSET32,
37 	REL_COPY,
38 	REL_SYM_OR_REL,
39 	REL_DTPMOD,
40 	REL_DTPOFF,
41 	REL_TPOFF,
42 	REL_TPOFF_NEG,
43 	REL_TLSDESC,
44 	REL_FUNCDESC,
45 	REL_FUNCDESC_VAL,
46 };
47 
48 struct fdpic_loadseg {
49 	uintptr_t addr, p_vaddr, p_memsz;
50 };
51 
52 struct fdpic_loadmap {
53 	unsigned short version, nsegs;
54 	struct fdpic_loadseg segs[];
55 };
56 
57 struct fdpic_dummy_loadmap {
58 	unsigned short version, nsegs;
59 	struct fdpic_loadseg segs[1];
60 };
61 
62 #include "reloc.h"
63 
64 #ifndef FDPIC_CONSTDISP_FLAG
65 #define FDPIC_CONSTDISP_FLAG 0
66 #endif
67 
68 #ifndef DL_FDPIC
69 #define DL_FDPIC 0
70 #endif
71 
72 #ifndef DL_NOMMU_SUPPORT
73 #define DL_NOMMU_SUPPORT 0
74 #endif
75 
76 #if !DL_FDPIC
77 #define IS_RELATIVE(x,s) ( \
78 	(R_TYPE(x) == REL_RELATIVE) || \
79 	(R_TYPE(x) == REL_SYM_OR_REL && !R_SYM(x)) )
80 #else
81 #define IS_RELATIVE(x,s) ( ( \
82 	(R_TYPE(x) == REL_FUNCDESC_VAL) || \
83 	(R_TYPE(x) == REL_SYMBOLIC) ) \
84 	&& (((s)[R_SYM(x)].st_info & 0xf) == STT_SECTION) )
85 #endif
86 
87 #ifndef NEED_MIPS_GOT_RELOCS
88 #define NEED_MIPS_GOT_RELOCS 0
89 #endif
90 
91 #ifndef DT_DEBUG_INDIRECT
92 #define DT_DEBUG_INDIRECT 0
93 #endif
94 
95 #define AUX_CNT 32
96 #define DYN_CNT 32
97 
98 typedef void (*stage2_func)(unsigned char *, size_t *);
99 
100 hidden void *__dlsym(void *restrict, const char *restrict, void *restrict);
101 
102 hidden void __dl_seterr(const char *, ...);
103 hidden int __dl_invalid_handle(void *);
104 hidden void __dl_vseterr(const char *, va_list);
105 
106 hidden ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic();
107 
108 hidden extern int __malloc_replaced;
109 hidden extern int __aligned_alloc_replaced;
110 hidden void __malloc_donate(char *, char *);
111 hidden int __malloc_allzerop(void *);
112 
113 #endif
114