⑴ 如何查看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)。