mirror of https://github.com/dynup/kpatch
lookup: add 'objname' to lookup table and lookup results
This will be needed for the upcoming dynrela refactoring. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
parent
7e1f2b0e07
commit
3064cf3c60
|
@ -3605,10 +3605,11 @@ int main(int argc, char *argv[])
|
|||
kpatch_elf_teardown(kelf_patched);
|
||||
|
||||
/* create symbol lookup table */
|
||||
lookup = lookup_open(parent_symtab, mod_symvers, hint, base_locals);
|
||||
for (sym_comp = base_locals; sym_comp && sym_comp->name; sym_comp++) {
|
||||
lookup = lookup_open(parent_symtab, parent_name, mod_symvers, hint,
|
||||
base_locals);
|
||||
|
||||
for (sym_comp = base_locals; sym_comp && sym_comp->name; sym_comp++)
|
||||
free(sym_comp->name);
|
||||
}
|
||||
free(base_locals);
|
||||
free(hint);
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ struct lookup_table {
|
|||
struct object_symbol *obj_syms;
|
||||
struct export_symbol *exp_syms;
|
||||
struct object_symbol *local_syms;
|
||||
char *objname;
|
||||
};
|
||||
|
||||
#define for_each_obj_symbol(ndx, iter, table) \
|
||||
|
@ -167,13 +168,15 @@ static void find_local_syms(struct lookup_table *table, char *hint,
|
|||
if (!locals_match(table, i, child_locals))
|
||||
continue;
|
||||
if (table->local_syms)
|
||||
ERROR("find_local_syms for %s: found_dup", hint);
|
||||
ERROR("found duplicate matches for %s local symbols in %s symbol table",
|
||||
hint, table->objname);
|
||||
|
||||
table->local_syms = sym;
|
||||
}
|
||||
|
||||
if (!table->local_syms)
|
||||
ERROR("find_local_syms for %s: couldn't find in vmlinux symbol table", hint);
|
||||
ERROR("couldn't find matching %s local symbols in %s symbol table",
|
||||
hint, table->objname);
|
||||
}
|
||||
|
||||
/* Strip the path and replace '-' with '_' */
|
||||
|
@ -359,8 +362,9 @@ static void symvers_read(struct lookup_table *table, char *path)
|
|||
fclose(file);
|
||||
}
|
||||
|
||||
struct lookup_table *lookup_open(char *symtab_path, char *symvers_path,
|
||||
char *hint, struct sym_compare_type *locals)
|
||||
struct lookup_table *lookup_open(char *symtab_path, char *objname,
|
||||
char *symvers_path, char *hint,
|
||||
struct sym_compare_type *locals)
|
||||
{
|
||||
struct lookup_table *table;
|
||||
|
||||
|
@ -369,6 +373,7 @@ struct lookup_table *lookup_open(char *symtab_path, char *symvers_path,
|
|||
ERROR("malloc table");
|
||||
memset(table, 0, sizeof(*table));
|
||||
|
||||
table->objname = objname;
|
||||
symtab_read(table, symtab_path);
|
||||
symvers_read(table, symvers_path);
|
||||
find_local_syms(table, hint, locals);
|
||||
|
@ -429,6 +434,7 @@ bool lookup_local_symbol(struct lookup_table *table, char *name,
|
|||
if (!match)
|
||||
return false;
|
||||
|
||||
result->objname = table->objname;
|
||||
result->sympos = sympos;
|
||||
result->addr = sym->addr;
|
||||
result->size = sym->size;
|
||||
|
@ -445,6 +451,7 @@ bool lookup_global_symbol(struct lookup_table *table, char *name,
|
|||
for_each_obj_symbol(i, sym, table) {
|
||||
if ((sym->bind == STB_GLOBAL || sym->bind == STB_WEAK) &&
|
||||
!strcmp(sym->name, name)) {
|
||||
result->objname = table->objname;
|
||||
result->addr = sym->addr;
|
||||
result->size = sym->size;
|
||||
result->sympos = 0; /* always 0 for global symbols */
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
struct lookup_table;
|
||||
|
||||
struct lookup_result {
|
||||
char *objname;
|
||||
unsigned long addr;
|
||||
unsigned long size;
|
||||
unsigned long sympos;
|
||||
|
@ -16,8 +17,9 @@ struct sym_compare_type {
|
|||
int type;
|
||||
};
|
||||
|
||||
struct lookup_table *lookup_open(char *symtab_path, char *symvers_path,
|
||||
char *hint, struct sym_compare_type *locals);
|
||||
struct lookup_table *lookup_open(char *symtab_path, char *objname,
|
||||
char *symvers_path, char *hint,
|
||||
struct sym_compare_type *locals);
|
||||
void lookup_close(struct lookup_table *table);
|
||||
bool lookup_local_symbol(struct lookup_table *table, char *name,
|
||||
struct lookup_result *result);
|
||||
|
|
Loading…
Reference in New Issue