George Nechifor
George Nechifor

Reputation: 439

Linux kernel: get function address for kernel driver

Is it possible in a linux kernel module to get the pointer of a function exported by another kernel module (something like cat /proc/kallsyms) but with api calls. Also if it would be possbile to load the intended module into memory if it doesn't exist. Basically what i am trying to do is to introduce a soft dependency between 2 modules. so i can execute one with or without the other.

Upvotes: 1

Views: 2952

Answers (2)

Zibri
Zibri

Reputation: 9857

You can use: kallsyms_lookup_name(const char *name) Just include linux/kallsyms.h

Upvotes: 0

Abhijeet Kasurde
Abhijeet Kasurde

Reputation: 4127

Yes, this is possible. Using following Linux Kernel APIs,

  1. Using find_symbol API, you can search for desired symbol exists or not
  2. If it fails to find symbol, then you can try to load desired module which exports symbol which you intended to use using APIs called find_module and request_module. Here is sample code for these APIs here

Upvotes: 1

Related Questions