⑴ 如何查看linux动态库中包含哪些函数
1、方法1
nm *.so
2、方法2
readelf -a *.so
PS:readelf
Options are:
-a --all Equivalent to: -h -l -S -s -r -d -V -A -I
-h --file-header Display the ELF file header
-l --program-headers Display the program headers
--segments An alias for --program-headers
-S --section-headers Display the sections' header
--sections An alias for --section-headers
-g --section-groups Display the section groups
-t --section-details Display the section details
-e --headers Equivalent to: -h -l -S
-s --syms Display the symbol table
--symbols An alias for --syms
-n --notes Display the core notes (if present)
-r --relocs Display the relocations (if present)
-u --unwind Display the unwind info (if present)
-d --dynamic Display the dynamic section (if present)
-V --version-info Display the version sections (if present)
-A --arch-specific Display architecture specific information (if any).
-c --archive-index Display the symbol/file index in an archive
-D --use-dynamic Use the dynamic section info when displaying symbols
-x --hex-mp=<number|>
Dump the contents of section <number|name> as bytes
-p --string-mp=<number|name>
Dump the contents of section <number|name> as strings
-R --relocated-mp=<number|name>
Dump the contents of section <number|name> as relocated bytes
-w[lLiaprmfFsoR] or
--debug-mp[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]
Display the contents of DWARF2 debug sections
-I --histogram Display histogram of bucket list lengths
-W --wide Allow output width to exceed 80 characters
@<file> Read options from <file>
-H --help Display this information
⑵ linux 中的软件安装在哪个位置
在linux中文件与软件一般都是安装在到/usr/share和/usr/local中了,如果我们需要查看软件安装路径linux为我们提供了查看命令,whereis 就可以帮我查找文件安装路径在哪里了。
查询运行文件所在路径:
如果你只要查询文件的运行文件所在地址,直接用下面的命令就可以了(还是以Oracle为例):
which oracle
结果会显示:
/usr/bin/oracle
以上只适合安装路径加入PATH里
如果是源码安装的话,你可以使用-prefix指定安装路径,这样,你可以很轻松知道软件的安装路径;
3.如果是rpm包安装的话,可以使用rpm -qal查询一下
rpm -qf /路径/程序名 可以查到一个程序属于哪个rpm包,然后rpm -ql那个包可以看到那个包的所有文件和路径等等。还可以解开成一个cpio文件等等之类的,仔细研究一下rpm的参数吧。完全可以做到任何你想做的。想了解更为详细的Linux知识可参考书籍《Linux就该这么学》。
⑶ p , l, c, d, s符号在LINUX下代表什么文件
d:表示是一个目录(directory),事实上在ext2fs中,目录是一个特殊的文件。
-:表示这是一个普通的文件。
l: 表示这是一个符号链接(symbol link)文件,实际上它指向另一个文件。
b、c:分别表示区块(block)设备和字符(character)设备,是特殊类型的文件。
s、p:这些文件关系到系统的数据结构和管道(pipe),通常很少见到。
⑷ linux内核模块怎么调用
在编写linux内核模块的时候,有时候我们需要调用一只内核模块里面的函数,然而如果是在不同目录下面编译生成的内核模块,此时A模块去调用B模块的函数时候会出现函数未定义,无法调用的情况。那么以前我是在同一个目录下面,先后写两个makefile,然后编译生成两个不同的内核模块,这种方式可以正常实现A模块调用B模块里面的函数,不过非常麻烦。本博文将会针对这种情况提出一种可以同时生成多个内核模块,不要再次编译的方面,下面贴出源码:
内核模块cal.ko:
#include <linux/mole.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
int add(int a, int b) {
return a+b;
}
int sub(int a, int b) {
return a-b;
}
static int sym_init() {
return 0;
}
static int sym_exit() {
return 0;
}
mole_init(sym_init);
mole_exit(sym_exit);
EXPORT_SYMBOL(add);
EXPORT_SYMBOL(sub);
内核模块hello.ko
#include <linux/mole.h>
#include <linux/init.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Xie");
MODULE_DESCRIPTION("Hello World Mole");
MODULE_ALIAS("a simplest mole");
static int age = 10;
mole_param(age, int, S_IRUGO);//allow all user to use this param
int add(int a, int b);
int sub(int a, int b);
static int hello_init(void)
{
printk("<0>"" Hello World! age = %d\n", add(10, 20));//调用内核模块cal.ko里面的add函数
return 0;
}
static void hello_exit(void)
{
printk("<0>""hello exit %d\n", sub(30,10));//调用内核模块cal.ko里面的sub函数
}
mole_init(hello_init);
mole_exit(hello_exit);
可以生成多个内核模块的makefile
ifneq ($(KERNELRELEASE),)
obj-m := cal.o hello.o
cal-objs := operator.o
hello-objs := main.o
else
KDIR := /lib/moles/2.6.32-21-generic/build
all:
make -C $(KDIR) M=$(PWD) moles
clean:
rm -f *.ko *.o *.mod.o *.mod.c *.symvers *.order
endif
此时在当前目录执行make就会产生cal.ko和hello.ko两个内核模块
⑸ 怎样解决“symbol file could not be found”问题
关于windbg调试符号表配置路径错误的问题探讨 (转载)
打开windbg.exe 开始进行‘内核调试’(kernel debug)时,
命令行窗口输出错误提示 :
Connected to Windows XP 2600 x86 compatible target, ptr64 FALSE
*** ERROR: Symbol file could not be found. Defaulted to export symbols for ntkrnlpa.exe -
Loading Kernel Symbols
..................................................................................................................................................
Loading User Symbols
............................................................................................................
Loading unloaded mole list
.........................
当在命令行中输入!process 0 0命令时,output窗口输出内容为:
lkd> !process
NT symbols are incorrect, please fix symbols
以上信息说明 符号文件(symbol files)与当前调试的系统版本不符 或者 符号文件路径设置错误
在下载符号文件时,应该先确定我们将要调试的系统的版本:如版本为xp_sp3_enu,则下载相应的符号文件:WindowsXP-
KB936929-SP3-x86-symbols-update-ENU.exe。如果版本为中文版,则下载相应的CHS版。
⑹ linux 加载模块驱动时出问题 Unknown symbol in mole
内核与模块是否都是你编译的啊?
内核主文件与模块两者有很多东西必须匹配,编译器版本、源码版本、编译时的设置(.config)。