kprobes: Make kprobe register via symbol name
In Linux kernel, kprobe can choose to register by address or symbol name, but currently F9 microkernel can only register by address.
In F9 microkernel, it can include ksymbols when compiling kernel with CONFIG_SYMMAP, which means F9 microkernel can support regiser kprobe via symbol name, too.
This commit change two parts in F9 microkernel, ksym and kprobes.
- ksym
- Adding ksym_lookup_name to search function address via symbol name.
- kprobes
- Adding new field
symbol_namein struct kprobe. - When kprobe is registering, it will get the correct address via
help function
kprobe_addr,kprobe_addrwill return correct function address. Also,kprobe_addrwill failed when it cannot match the symbol name in symtab, or address and symbol name are used in the same time.
- Adding new field
Example usage:
static struct kprobe kp = {
.symbol_name = "ktimer_handler"
};
or
extern void ktimer_handler(void);
static struct kprobe kp = {
.addr = ktimer_handler
};
CI fails because of incorrect linkage.
@jserv How could I prevent kernel / user function multiple define?
l4test and kernel all define the name strcmp
build/discoveryf4/user/apps/l4test/string.o: In function `strcmp':
/home/travis/build/f9micro/f9-kernel/user/apps/l4test/string.c:21: multiple definition of `strcmp'
build/discoveryf4/kernel/lib/strcmp.o:/home/travis/build/f9micro/f9-kernel/kernel/lib/strcmp.c:12: first defined here
make: *** [build/discoveryf4/f9_nosym.elf] Error 1
@grapherd, there should be only one implementation providing strcmp: kernel/lib/strcmp.c. You would need appropriate declarations where user applications include include/lib/string.h