我喜歡運行這個命令來在我的一些系統庫或內核上尋找類似于 sendfile、send、write writev 的函式名。命令
nm -D /usr/lib/libopenal.so.1 //or T option
但是我不知道在哪里可以找到這些函式的確切名稱這個想法是我只是使用帶有 grep 的管道運行上面的命令,這樣我就可以獲得像 sendfile 這樣的函式的確切名稱,
有人告訴我然后 write 可能有名稱 64__sys_write ,這是正確的王者,也許是其他一些功能,所以我想知道我可以在 ubuntu linux 上獲取此資訊
uj5u.com熱心網友回復:
但是不知道去哪里找這些功能
你不需要知道去哪里找,但你應該學會如何自己找出瑣碎問題(比如這個)的答案。
以下是您可以使用的步驟:
- 選擇一個程式,它行使功能(S)你有興趣,在的情況下
send,nc和telnet看起來很好的潛在候選人。 - 驗證所選程式確實呼叫
send:
nm -AD $(which nc telnet) | grep ' send'
/usr/bin/nc: U sendmsg@GLIBC_2.2.5
/usr/bin/telnet: U send@GLIBC_2.2.5
好吧,假設我們只對我們感興趣,我們的“目標”也是send如此telnet,nc而不是。
- 找出哪些庫
telnet使用:
ldd /usr/bin/telnet
linux-vdso.so.1 (0x00007ffe957d4000)
libstdc .so.6 => /lib/x86_64-linux-gnu/libstdc .so.6 (0x00007f2f2e2f4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2f2e12f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2f2dfea000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2f2e53c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2f2dfd0000)
該函式send必須在其中之一中定義。哪一個?
- 運行
nm -D | grep ' send'每一個,發現函式定義在libc.so.6:
nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep ' send'
00000000000fee60 W send@@GLIBC_2.2.5
00000000000f3430 T sendfile@@GLIBC_2.2.5
00000000000f3430 W sendfile64@@GLIBC_2.3
00000000000ff520 W sendmmsg@@GLIBC_2.14
00000000000fef20 W sendmsg@@GLIBC_2.2.5
00000000000fefc0 W sendto@@GLIBC_2.2.5
獎勵:你已經發現,sendfile在同樣的定義libc.so.6。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/386331.html
