0

I want to read some Linux Kernel source code, and I found LXR. It's great, but sometimes when I click on some function, like 'kfree', and I got this: enter image description here

When 'link' using ld, there must be no conflicts. So the question is : How to determine which one is THE ONE??? (I think gcc+makefile is the solution, but I don't know how to do it...)

Thanks!

4

2 回答 2

0

1.如果你对内核有一些隐含的了解,你会注意到kfree是slub或slab或slob的一部分。查看内核配置,您可能会注意到您使用了 slub 分配器(通过 dfefault)。所以你得出结论——正确的答案是 mm/slub.c:3334。

2.

nm -a ./vmlinux | grep kfree
ffffffff81151bd0 T kfree
addr2line -e ./vmlinux 0xffffffff81151bd0
/home/alexhoppus/Desktop/linux/mm/slub.c:3335
于 2014-10-09T19:16:19.763 回答
0

这是另一个 linux 交叉引用搜索,可能包含更详细的信息

https://code-grep.com/view/project/54b083273b2082684a000008/linux-3.19-rc2?search=kfree&type=definitions&page=0

如您所见,有些是预处理器定义,有些是函数。要知道哪个是正确的,您可以查看配置选项,通常在内核的 .config 文件中。

于 2015-01-12T06:10:14.223 回答