Commit 0c274729 authored by Yonghong Song's avatar Yonghong Song

fix get_kprobe_functions

Fix issue #1747.

In commit #1647, we excluded all symbols outside [_stext, _etext].
This is incorrect as it excluded module symbols as well.

This patch changed the algorithm to only skip symbols
in init sections [__init_begin, __init_end].
Signed-off-by: default avatarYonghong Song <yhs@fb.com>
parent 0a436339
...@@ -495,17 +495,18 @@ class BPF(object): ...@@ -495,17 +495,18 @@ class BPF(object):
blacklist = set([line.rstrip().split()[1] for line in blacklist_f]) blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
fns = [] fns = []
found_stext = False in_init_section = 0
with open("/proc/kallsyms", "rb") as avail_file: with open("/proc/kallsyms", "rb") as avail_file:
for line in avail_file: for line in avail_file:
(_, t, fn) = line.rstrip().split()[:3] (t, fn) = line.rstrip().split()[1:3]
if found_stext is False: if in_init_section == 0:
if fn == b'_stext': if fn == b'__init_begin':
found_stext = True in_init_section = 1
continue
elif in_init_section == 1:
if fn == b'__init_end':
in_init_section = 2
continue continue
if fn == b'_etext':
break
if (t.lower() in [b't', b'w']) and re.match(event_re, fn) \ if (t.lower() in [b't', b'w']) and re.match(event_re, fn) \
and fn not in blacklist: and fn not in blacklist:
fns.append(fn) fns.append(fn)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment