1 /* 2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. 3 ** Distributed under the terms of the NewOS License. 4 */ 5 #ifndef _KERNEL_ELF_PRIV_H 6 #define _KERNEL_ELF_PRIV_H 7 8 9 #include <elf32.h> 10 #include <image.h> 11 12 13 typedef struct elf_region { 14 area_id id; 15 addr_t start; 16 addr_t size; 17 long delta; 18 } elf_region; 19 20 struct elf_image_info { 21 struct elf_image_info *next; // next image in the hash 22 char *name; 23 image_id id; 24 int32 ref_count; 25 void *vnode; 26 elf_region text_region; 27 elf_region data_region; 28 addr_t dynamic_ptr; // pointer to the dynamic section 29 struct elf_linked_image *linked_images; 30 31 struct Elf32_Ehdr *eheader; 32 33 // pointer to symbol participation data structures 34 char *needed; 35 uint32 *symhash; 36 struct Elf32_Sym *syms; 37 char *strtab; 38 struct Elf32_Rel *rel; 39 int rel_len; 40 struct Elf32_Rela *rela; 41 int rela_len; 42 struct Elf32_Rel *pltrel; 43 int pltrel_len; 44 int pltrel_type; 45 46 struct Elf32_Sym *debug_symbols; 47 uint32 num_debug_symbols; 48 const char *debug_string_table; 49 }; 50 51 52 #define STRING(image, offset) ((char *)(&(image)->strtab[(offset)])) 53 #define SYMNAME(image, sym) STRING(image, (sym)->st_name) 54 #define SYMBOL(image, num) ((struct Elf32_Sym *)&(image)->syms[num]) 55 #define HASHTABSIZE(image) ((image)->symhash[0]) 56 #define HASHBUCKETS(image) ((unsigned int *)&(image)->symhash[2]) 57 #define HASHCHAINS(image) ((unsigned int *)&(image)->symhash[2+HASHTABSIZE(image)]) 58 59 extern 60 #ifdef __cplusplus 61 "C" 62 #endif 63 status_t elf_resolve_symbol(struct elf_image_info *image, struct Elf32_Sym *sym, 64 struct elf_image_info *shared_image, const char *sym_prepend, addr_t *sym_addr); 65 66 #endif /* _KERNEL_ELF_PRIV_H */ 67