summaryrefslogtreecommitdiffstats
path: root/tools/soslim/symfilter.h
blob: f73fd506c4046e457fc1d090606d924f62791d47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef SYMFILTER_H
#define SYMFILTER_H

/* This file describes the interface for parsing the list of symbols. Currently,
   this is just a text file with each symbol on a separate line.  We build an
   in-memory linked list of symbols out of this image.
*/

#include <stdio.h>
#include <libelf.h>
#include <gelf.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libebl.h> /* defines bool */

typedef struct symfilter_list_t symfilter_list_t;
struct symfilter_list_t {
    symfilter_list_t *next;
    const char *name;
    unsigned int len; /* strlen(name) */
    Elf32_Word index;
    GElf_Sym symbol;
};

typedef struct symfilter_t {

    int fd; /* symbol-filter-file descriptor */
    off_t fsize; /* size of file */
    void *mmap; /* symbol-fiter-file memory mapping */

    section_info_t symtab;
    section_info_t hash;
    symfilter_list_t *symbols;

    /* The total number of symbols in the symfilter. */
    unsigned int num_symbols;
    /* The total number of bytes occupied by the names of the symbols, including
       the terminating null characters.
    */
    unsigned int total_name_length;

    bool *symbols_to_keep;
    /* must be the same as the number of symbols in the dynamic table! */
    int num_symbols_to_keep;
} symfilter_t;

void build_symfilter(const char *name, Elf *elf, symfilter_t *filter, off_t);
void destroy_symfilter(symfilter_t *);

#endif/*SYMFILTER_H*/