riscv32: add arch headers
[musl.git] / src / internal / dynlink.h
blob40c743e2fcbe0fb96e37010adba694ee95a04df5
1 #ifndef _INTERNAL_RELOC_H
2 #define _INTERNAL_RELOC_H
4 #include <features.h>
5 #include <elf.h>
6 #include <stdint.h>
7 #include <stddef.h>
8 #include <stdarg.h>
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
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,
48 struct fdpic_loadseg {
49 uintptr_t addr, p_vaddr, p_memsz;
52 struct fdpic_loadmap {
53 unsigned short version, nsegs;
54 struct fdpic_loadseg segs[];
57 struct fdpic_dummy_loadmap {
58 unsigned short version, nsegs;
59 struct fdpic_loadseg segs[1];
62 #include "reloc.h"
64 #ifndef FDPIC_CONSTDISP_FLAG
65 #define FDPIC_CONSTDISP_FLAG 0
66 #endif
68 #ifndef DL_FDPIC
69 #define DL_FDPIC 0
70 #endif
72 #ifndef DL_NOMMU_SUPPORT
73 #define DL_NOMMU_SUPPORT 0
74 #endif
76 #ifndef TLSDESC_BACKWARDS
77 #define TLSDESC_BACKWARDS 0
78 #endif
80 #if !DL_FDPIC
81 #define IS_RELATIVE(x,s) ( \
82 (R_TYPE(x) == REL_RELATIVE) || \
83 (R_TYPE(x) == REL_SYM_OR_REL && !R_SYM(x)) )
84 #else
85 #define IS_RELATIVE(x,s) ( ( \
86 (R_TYPE(x) == REL_FUNCDESC_VAL) || \
87 (R_TYPE(x) == REL_SYMBOLIC) ) \
88 && (((s)[R_SYM(x)].st_info & 0xf) == STT_SECTION) )
89 #endif
91 #ifndef NEED_MIPS_GOT_RELOCS
92 #define NEED_MIPS_GOT_RELOCS 0
93 #endif
95 #ifndef DT_DEBUG_INDIRECT
96 #define DT_DEBUG_INDIRECT 0
97 #endif
99 #ifndef DT_DEBUG_INDIRECT_REL
100 #define DT_DEBUG_INDIRECT_REL 0
101 #endif
103 #define AUX_CNT 32
104 #define DYN_CNT 37
106 typedef void (*stage2_func)(unsigned char *, size_t *);
108 hidden void *__dlsym(void *restrict, const char *restrict, void *restrict);
110 hidden void __dl_seterr(const char *, ...);
111 hidden int __dl_invalid_handle(void *);
112 hidden void __dl_vseterr(const char *, va_list);
114 hidden ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic();
116 hidden extern int __malloc_replaced;
117 hidden extern int __aligned_alloc_replaced;
118 hidden void __malloc_donate(char *, char *);
119 hidden int __malloc_allzerop(void *);
121 #endif