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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#ifndef _EXTRACT_H_
#define _EXTRACT_H_
#include "arguments.h"
#include "ulp_common.h"
#include <libelf.h>
#include <link.h>
#include <stdbool.h>
#include <stdio.h>
struct argp_option;
/** Struct containing useful information for Userspace Livepatching retrieved
* from the target .so file.
*/
struct symbol
{
/** Name of the symbol (function, variable). */
const char *name;
/** Offset of such symbol. */
ElfW(Addr) offset;
/** Size of symbol. */
Elf32_Word size;
/** Symbol visibility. See elf.h. */
unsigned char st_info;
/** Symbol type and binding. See elf.h. */
unsigned char st_other;
/** Next symbol in the symbol table chain. */
struct symbol *next;
};
/** Struct containing the useful information for userspace livepatching
* retrieved from the .so file.
*/
struct ulp_so_info
{
/** Name of the library. Empty for none. */
const char *name;
/** Build ID for library. Zero for unitialized. */
unsigned char buildid[BUILDID_LEN];
/** List of symbols extracted from the target library. */
struct symbol *symbols;
};
void release_so_info(struct ulp_so_info *);
void release_symbol(struct symbol *symbol);
void write_ulp_so_info_json(FILE *stream, const struct ulp_so_info *info);
struct symbol *build_symbols_list(Elf *elf);
struct ulp_so_info *parse_so_elf(const char *target_path);
bool so_info_equal(struct ulp_so_info *a, struct ulp_so_info *b);
struct ulp_so_info *parse_so_json(const char *path);
void dump_ulp_so_info(const struct ulp_so_info *info);
struct symbol *get_symbol_with_name(struct ulp_so_info *info, const char *sym);
int run_extract(struct arguments *arguments);
struct ulp_so_info *ulp_so_info_open(const char *path);
struct argp_option *get_command_option_extract(void);
#endif /* _EXTRACT_H_. */
|