欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux下查看.so和可執(zhí)行文件是否debug編譯的方法(必看)

 更新時(shí)間:2017年03月16日 10:32:57   投稿:jingxian  
下面小編就為大家?guī)硪黄狶inux下查看.so和可執(zhí)行文件是否debug編譯的方法(必看)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

今天同事問我,如何判斷一個(gè).so是否是debug編譯的。

我記得以前自己是用file來查看一個(gè).so,根據(jù)是否包含"not stripped"來判斷該.so是否是debug編譯的,于是就沒做實(shí)驗(yàn)就回答。

然而,stripped/not stripped并不是debug/release編譯的判斷標(biāo)準(zhǔn). 我對(duì)debug和release的.so運(yùn)行file后,得出幾乎相同的輸出, 都是not stripped. 所以我算是誤導(dǎo)同事了。

根據(jù)<Computers Systems - A Programmer's Perspective>所言, debug/release的區(qū)別更多的表現(xiàn)在.so和可執(zhí)行程序所擁有的段上。debug編譯出來的。so和可執(zhí)行程序擁有很多附加的段來包含哪些debug的信息。 所以查看段信息是一種判斷的方式。

我在Ubuntu 11.04上分別對(duì)同一個(gè)開源軟件進(jìn)行debug和release編譯,并且查看某個(gè).so的段(readelf -S),發(fā)現(xiàn)release編譯的只有29個(gè)段:

There are 29 section headers, starting at offset 0x1b7d78:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .note.gnu.build-i NOTE 00000000000001c8 000001c8
0000000000000024 0000000000000000 A 0 0 4
[ 2] .gnu.hash GNU_HASH 00000000000001f0 000001f0
0000000000003430 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000003620 00003620
000000000000b400 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 000000000000ea20 0000ea20
00000000000083e2 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 0000000000016e02 00016e02
0000000000000f00 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 0000000000017d08 00017d08
0000000000000080 0000000000000000 A 4 2 8
[ 7] .rela.dyn RELA 0000000000017d88 00017d88
0000000000009570 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 00000000000212f8 000212f8
00000000000080d0 0000000000000018 A 3 10 8
[ 9] .init PROGBITS 00000000000293c8 000293c8
0000000000000018 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 00000000000293e0 000293e0
00000000000055f0 0000000000000010 AX 0 0 4
[11] .text PROGBITS 000000000002e9d0 0002e9d0
0000000000144658 0000000000000000 AX 0 0 16
[12] .fini PROGBITS 0000000000173028 00173028
000000000000000e 0000000000000000 AX 0 0 4
[13] .rodata PROGBITS 0000000000173040 00173040
000000000001e9a0 0000000000000000 A 0 0 32
[14] .eh_frame_hdr PROGBITS 00000000001919e0 001919e0
000000000000427c 0000000000000000 A 0 0 4
[15] .eh_frame PROGBITS 0000000000195c60 00195c60
0000000000017d7c 0000000000000000 A 0 0 8
[16] .ctors PROGBITS 00000000003ae1e8 001ae1e8
0000000000000010 0000000000000000 WA 0 0 8
[17] .dtors PROGBITS 00000000003ae1f8 001ae1f8
0000000000000010 0000000000000000 WA 0 0 8
[18] .jcr PROGBITS 00000000003ae208 001ae208
0000000000000008 0000000000000000 WA 0 0 8
[19] .data.rel.ro PROGBITS 00000000003ae220 001ae220
0000000000005b38 0000000000000000 WA 0 0 32
[20] .dynamic DYNAMIC 00000000003b3d58 001b3d58
00000000000001a0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 00000000003b3ef8 001b3ef8
00000000000010e8 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 00000000003b4fe8 001b4fe8
0000000000002b08 0000000000000008 WA 0 0 8
[23] .data PROGBITS 00000000003b7b00 001b7b00
0000000000000158 0000000000000000 WA 0 0 32
[24] .bss NOBITS 00000000003b7c58 001b7c58
0000000000000010 0000000000000000 WA 0 0 8
[25] .comment PROGBITS 0000000000000000 001b7c58
000000000000002a 0000000000000001 MS 0 0 1
[26] .shstrtab STRTAB 0000000000000000 001b7c82
00000000000000f5 0000000000000000 0 0 1
[27] .symtab SYMTAB 0000000000000000 001b84b8
000000000000fdb0 0000000000000018 28 788 8
[28] .strtab STRTAB 0000000000000000 001c8268
000000000000b8b0 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

而debug編譯的則有38個(gè)段, 且所有比release編譯多出來的段,都是以.debug_作為開始字符串來命名的:

There are 38 section headers, starting at offset 0xdacc00:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .note.gnu.build-i NOTE 00000000000001c8 000001c8
0000000000000024 0000000000000000 A 0 0 4
[ 2] .gnu.hash GNU_HASH 00000000000001f0 000001f0
0000000000003620 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000003810 00003810
000000000000c000 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 000000000000f810 0000f810
0000000000008ccb 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 00000000000184dc 000184dc
0000000000001000 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 00000000000194e0 000194e0
0000000000000070 0000000000000000 A 4 2 8
[ 7] .rela.dyn RELA 0000000000019550 00019550
0000000000009b40 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 0000000000023090 00023090
0000000000008388 0000000000000018 A 3 10 8
[ 9] .init PROGBITS 000000000002b418 0002b418
0000000000000018 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 000000000002b430 0002b430
00000000000057c0 0000000000000010 AX 0 0 4
[11] .text PROGBITS 0000000000030bf0 00030bf0
00000000001d2428 0000000000000000 AX 0 0 16
[12] .fini PROGBITS 0000000000203018 00203018
000000000000000e 0000000000000000 AX 0 0 4
[13] .rodata PROGBITS 0000000000203040 00203040
00000000000276b8 0000000000000000 A 0 0 32
[14] .eh_frame_hdr PROGBITS 000000000022a6f8 0022a6f8
00000000000059dc 0000000000000000 A 0 0 4
[15] .eh_frame PROGBITS 00000000002300d8 002300d8
000000000001715c 0000000000000000 A 0 0 8
[16] .ctors PROGBITS 0000000000448018 00248018
0000000000000010 0000000000000000 WA 0 0 8
[17] .dtors PROGBITS 0000000000448028 00248028
0000000000000010 0000000000000000 WA 0 0 8
[18] .jcr PROGBITS 0000000000448038 00248038
0000000000000008 0000000000000000 WA 0 0 8
[19] .data.rel.ro PROGBITS 0000000000448040 00248040
0000000000005b38 0000000000000000 WA 0 0 32
[20] .dynamic DYNAMIC 000000000044db78 0024db78
00000000000001a0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 000000000044dd18 0024dd18
00000000000012d0 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 000000000044efe8 0024efe8
0000000000002bf0 0000000000000008 WA 0 0 8
[23] .data PROGBITS 0000000000451be0 00251be0
0000000000000160 0000000000000000 WA 0 0 32
[24] .bss NOBITS 0000000000451d40 00251d40
0000000000000040 0000000000000000 WA 0 0 16
[25] .comment PROGBITS 0000000000000000 00251d40
0000000000000054 0000000000000001 MS 0 0 1
[26] .debug_aranges PROGBITS 0000000000000000 00251d94
00000000000030c0 0000000000000000 0 0 1
[27] .debug_pubnames PROGBITS 0000000000000000 00254e54
000000000000b8cb 0000000000000000 0 0 1
[28] .debug_info PROGBITS 0000000000000000 0026071f
000000000097f69b 0000000000000000 0 0 1
[29] .debug_abbrev PROGBITS 0000000000000000 00bdfdba
0000000000028211 0000000000000000 0 0 1
[30] .debug_line PROGBITS 0000000000000000 00c07fcb
0000000000075fbf 0000000000000000 0 0 1
[31] .debug_str PROGBITS 0000000000000000 00c7df8a
0000000000019789 0000000000000001 MS 0 0 1
[32] .debug_loc PROGBITS 0000000000000000 00c97713
0000000000043528 0000000000000000 0 0 1
[33] .debug_pubtypes PROGBITS 0000000000000000 00cdac3b
00000000000d1c97 0000000000000000 0 0 1
[34] .debug_ranges PROGBITS 0000000000000000 00dac8d2
00000000000001c0 0000000000000000 0 0 1
[35] .shstrtab STRTAB 0000000000000000 00daca92
000000000000016e 0000000000000000 0 0 1
[36] .symtab SYMTAB 0000000000000000 00dad580
0000000000014688 0000000000000018 37 1437 8
[37] .strtab STRTAB 0000000000000000 00dc1c08
000000000000e5a1 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)

對(duì)于可執(zhí)行文件也有類似的區(qū)別。

所以這應(yīng)當(dāng)是判斷debug/release的一個(gè)比較正確的方法了。

===================================

命令

readelf -S libxxx.so |grep debug

以上這篇Linux下查看.so和可執(zhí)行文件是否debug編譯的方法(必看)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Shell實(shí)現(xiàn)文本去重并操持原有順序

    Shell實(shí)現(xiàn)文本去重并操持原有順序

    這篇文章主要介紹了Shell實(shí)現(xiàn)文本去重并操持原有順序,本文分步驟講解如何解決需求,并給出了若干方法,需要的朋友可以參考下
    2015-03-03
  • 比較兩個(gè)字符串是否相等的shell代碼

    比較兩個(gè)字符串是否相等的shell代碼

    比較兩個(gè)字符串是否相等的shell代碼,需要的朋友可以參考下
    2013-02-02
  • awk中RS、ORS、FS、OFS的區(qū)別和聯(lián)系小結(jié)

    awk中RS、ORS、FS、OFS的區(qū)別和聯(lián)系小結(jié)

    這篇文章主要介紹了awk中RS、ORS、FS、OFS的區(qū)別和聯(lián)系小結(jié),用大量實(shí)例來說明和講解,需要的朋友可以參考下
    2014-07-07
  • 查找目錄下同名但不同后綴名文件的shell腳本代碼

    查找目錄下同名但不同后綴名文件的shell腳本代碼

    這個(gè)腳本可以實(shí)現(xiàn)指定目錄下同名但不同后綴名的查找,可以拓展為刪除指定的文件的腳本,覺得很實(shí)用,分享一下
    2013-02-02
  • Linux磁盤管理之LVM詳解及l(fā)vm磁盤操作命令

    Linux磁盤管理之LVM詳解及l(fā)vm磁盤操作命令

    LVM,Logical Volume Manger,是linux內(nèi)核提供的一種邏輯卷管理功能,由內(nèi)核驅(qū)動(dòng)和應(yīng)用層工具組成,它是在硬盤的分區(qū)基礎(chǔ)上,創(chuàng)建了一個(gè)邏輯層,可以非常靈活且非常方便的管理存儲(chǔ)設(shè)備,這篇文章主要介紹了Linux磁盤管理之LVM詳解及l(fā)vm磁盤操作命令,需要的朋友可以參考下
    2023-03-03
  • 解決linux的redhat版上mysql字符亂碼的問題

    解決linux的redhat版上mysql字符亂碼的問題

    下面小編就為大家?guī)硪黄鉀Qlinux的redhat版上mysql字符亂碼的問題。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-06-06
  • ubuntu中root和普通用戶切換方法(推薦)

    ubuntu中root和普通用戶切換方法(推薦)

    下面小編就為大家?guī)硪黄猽buntu中root和普通用戶切換方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-08-08
  • Linux常用高頻命令

    Linux常用高頻命令

    這篇文章介紹了Linux常用的高頻命令,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • shell腳本實(shí)現(xiàn)字符串的動(dòng)態(tài)替換方法

    shell腳本實(shí)現(xiàn)字符串的動(dòng)態(tài)替換方法

    這篇文章主要介紹了shell腳本實(shí)現(xiàn)字符串的動(dòng)態(tài)替換,在shell腳本中全部替換的方式為${var//old/new},本文通過實(shí)現(xiàn)腳本給大家詳細(xì)講解,需要的朋友可以參考下
    2022-10-10
  • Linux解壓縮(打開)Gz文件的命令詳解

    Linux解壓縮(打開)Gz文件的命令詳解

    GNU 的 Gzip 是一種流行的數(shù)據(jù)壓縮程序,而 GZ 文件是由標(biāo)準(zhǔn) Gzip 壓縮的存檔文件,本文給大家介紹了如何在Linux解壓縮(打開)Gz 文件,文中有詳細(xì)的代碼示例供大家參考,需要的朋友可以參考下
    2023-12-12

最新評(píng)論