mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 20:48:49 +08:00
selftests/bpf: Add load_kallsyms_refresh function
Adding load_kallsyms_refresh function to re-read symbols from /proc/kallsyms file. This will be needed to get proper functions addresses from bpf_testmod.ko module, which is loaded/unloaded several times during the tests run, so symbols might be already old when we need to use them. Acked-by: Song Liu <song@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20221025134148.3300700-6-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
e22061b2d3
commit
10705b2b7a
@ -23,7 +23,7 @@ static int ksym_cmp(const void *p1, const void *p2)
|
||||
return ((struct ksym *)p1)->addr - ((struct ksym *)p2)->addr;
|
||||
}
|
||||
|
||||
int load_kallsyms(void)
|
||||
int load_kallsyms_refresh(void)
|
||||
{
|
||||
FILE *f;
|
||||
char func[256], buf[256];
|
||||
@ -31,12 +31,7 @@ int load_kallsyms(void)
|
||||
void *addr;
|
||||
int i = 0;
|
||||
|
||||
/*
|
||||
* This is called/used from multiplace places,
|
||||
* load symbols just once.
|
||||
*/
|
||||
if (sym_cnt)
|
||||
return 0;
|
||||
sym_cnt = 0;
|
||||
|
||||
f = fopen("/proc/kallsyms", "r");
|
||||
if (!f)
|
||||
@ -57,6 +52,17 @@ int load_kallsyms(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_kallsyms(void)
|
||||
{
|
||||
/*
|
||||
* This is called/used from multiplace places,
|
||||
* load symbols just once.
|
||||
*/
|
||||
if (sym_cnt)
|
||||
return 0;
|
||||
return load_kallsyms_refresh();
|
||||
}
|
||||
|
||||
struct ksym *ksym_search(long key)
|
||||
{
|
||||
int start = 0, end = sym_cnt;
|
||||
|
@ -10,6 +10,8 @@ struct ksym {
|
||||
};
|
||||
|
||||
int load_kallsyms(void);
|
||||
int load_kallsyms_refresh(void);
|
||||
|
||||
struct ksym *ksym_search(long key);
|
||||
long ksym_get_addr(const char *name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user