mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 18:11:20 +00:00
module: Use the binary search for symbols resolution
Takes advantage of the order and locates symbols using binary search. This work was supported by a hardware donation from the CE Linux Forum. Signed-off-by: Alessio Igor Bogani <abogani@kernel.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Tested-by: Dirk Behme <dirk.behme@googlemail.com>
This commit is contained in:
parent
1a94dc35bc
commit
403ed27846
1 changed files with 16 additions and 5 deletions
|
@ -57,6 +57,7 @@
|
||||||
#include <linux/kmemleak.h>
|
#include <linux/kmemleak.h>
|
||||||
#include <linux/jump_label.h>
|
#include <linux/jump_label.h>
|
||||||
#include <linux/pfn.h>
|
#include <linux/pfn.h>
|
||||||
|
#include <linux/bsearch.h>
|
||||||
|
|
||||||
#define CREATE_TRACE_POINTS
|
#define CREATE_TRACE_POINTS
|
||||||
#include <trace/events/module.h>
|
#include <trace/events/module.h>
|
||||||
|
@ -363,17 +364,27 @@ static bool check_symbol(const struct symsearch *syms,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmp_name(const void *va, const void *vb)
|
||||||
|
{
|
||||||
|
const char *a;
|
||||||
|
const struct kernel_symbol *b;
|
||||||
|
a = va; b = vb;
|
||||||
|
return strcmp(a, b->name);
|
||||||
|
}
|
||||||
|
|
||||||
static bool find_symbol_in_section(const struct symsearch *syms,
|
static bool find_symbol_in_section(const struct symsearch *syms,
|
||||||
struct module *owner,
|
struct module *owner,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
struct find_symbol_arg *fsa = data;
|
struct find_symbol_arg *fsa = data;
|
||||||
unsigned int i;
|
struct kernel_symbol *sym;
|
||||||
|
|
||||||
|
sym = bsearch(fsa->name, syms->start, syms->stop - syms->start,
|
||||||
|
sizeof(struct kernel_symbol), cmp_name);
|
||||||
|
|
||||||
|
if (sym != NULL && check_symbol(syms, owner, sym - syms->start, data))
|
||||||
|
return true;
|
||||||
|
|
||||||
for (i = 0; i < syms->stop - syms->start; i++) {
|
|
||||||
if (strcmp(syms->start[i].name, fsa->name) == 0)
|
|
||||||
return check_symbol(syms, owner, i, data);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue