cleanup mbstowcs wrapper
[musl] / arch / x86_64 / reloc.h
1 #include <stdint.h>
2 #include <string.h>
3 #include <elf.h>
4
5 #define ETC_LDSO_PATH "/etc/ld-musl-x86_64.path"
6
7 #define IS_COPY(x) ((x)==R_X86_64_COPY)
8 #define IS_PLT(x) ((x)==R_X86_64_JUMP_SLOT)
9
10 static inline void do_single_reloc(
11         struct dso *self, unsigned char *base_addr,
12         size_t *reloc_addr, int type, size_t addend,
13         Sym *sym, size_t sym_size,
14         struct symdef def, size_t sym_val)
15 {
16         switch(type) {
17         case R_X86_64_GLOB_DAT:
18         case R_X86_64_JUMP_SLOT:
19         case R_X86_64_64:
20                 *reloc_addr = sym_val + addend;
21                 break;
22         case R_X86_64_32:
23                 *(uint32_t *)reloc_addr = sym_val + addend;
24                 break;
25         case R_X86_64_PC32:
26                 *reloc_addr = sym_val + addend - (size_t)reloc_addr + (size_t)base_addr;
27                 break;
28         case R_X86_64_RELATIVE:
29                 *reloc_addr = (size_t)base_addr + addend;
30                 break;
31         case R_X86_64_COPY:
32                 memcpy(reloc_addr, (void *)sym_val, sym_size);
33                 break;
34         case R_X86_64_DTPMOD64:
35                 *reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
36                 break;
37         case R_X86_64_DTPOFF64:
38                 *reloc_addr = def.sym->st_value + addend;
39                 break;
40         case R_X86_64_TPOFF64:
41                 *reloc_addr = (def.sym
42                         ? def.sym->st_value - def.dso->tls_offset
43                         : 0 - self->tls_offset) + addend;
44                 break;
45         }
46 }