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