1 #ifndef SYMFILTER_H 2 #define SYMFILTER_H 3 4 /* This file describes the interface for parsing the list of symbols. Currently, 5 this is just a text file with each symbol on a separate line. We build an 6 in-memory linked list of symbols out of this image. 7 */ 8 9 #include <stdio.h> 10 #include <libelf.h> 11 #include <gelf.h> 12 #include <sys/types.h> 13 #include <sys/stat.h> 14 #include <libebl.h> /* defines bool */ 15 16 typedef struct symfilter_list_t symfilter_list_t; 17 struct symfilter_list_t { 18 symfilter_list_t *next; 19 const char *name; 20 unsigned int len; /* strlen(name) */ 21 Elf32_Word index; 22 GElf_Sym symbol; 23 }; 24 25 typedef struct symfilter_t { 26 27 int fd; /* symbol-filter-file descriptor */ 28 off_t fsize; /* size of file */ 29 void *mmap; /* symbol-fiter-file memory mapping */ 30 31 section_info_t symtab; 32 section_info_t hash; 33 symfilter_list_t *symbols; 34 35 /* The total number of symbols in the symfilter. */ 36 unsigned int num_symbols; 37 /* The total number of bytes occupied by the names of the symbols, including 38 the terminating null characters. 39 */ 40 unsigned int total_name_length; 41 42 bool *symbols_to_keep; 43 /* must be the same as the number of symbols in the dynamic table! */ 44 int num_symbols_to_keep; 45 } symfilter_t; 46 47 void build_symfilter(const char *name, Elf *elf, symfilter_t *filter, off_t); 48 void destroy_symfilter(symfilter_t *); 49 50 #endif/*SYMFILTER_H*/ 51