Mac查看so文件的具体信息

了解ELF的文件格式可通过SO(ELF)文件格式详解

通过命令greadelf -a xxx.so和gobjdump -x xxx.so以及readelf这三个命令得到so的信息
我个人常用readelf命令,具体指令的使用可参考readelf命令使用说明

命令安装和配置

运行下述命令:
brew update
brew install binutils

执行安装命令 brew install binutils,控制台会打印如下信息
If you need to have binutils first in your PATH run:
echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> ~/.bash_profile

配置Mac环境变量即可
vi ~/.bash_profile 添加path即可
source ~/.bash_profile 命令生效

执行结果预览

以armeabi-v7a包下的声网 libagora-rtc-sdk-jni.so 为例

具体指令可安装之后输入对应的命令,查看命令行提示自行选用,个人常用

-h --file-header Display the ELF file header
-a --all Equivalent to: -h -l -S -s -r -d -V -A -I

readelf -h libagora-rtc-sdk-jni.so

ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM
Version: 0x1
Entry point address: 0x0
Start of program headers: 52 (bytes into file)
Start of section headers: 9480288 (bytes into file)
Flags: 0x5000200, Version5 EABI, soft-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 28
Section header string table index: 27

greadelf -a libagora-rtc-sdk-jni.so

ELF Header:

ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM (x86的此处为 Intel 80386)
Version: 0x1
Entry point address: 0x0
Start of program headers: 52 (bytes into file)
Start of section headers: 9480288 (bytes into file)
Flags: 0x5000200, Version5 EABI, soft-float ABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 28
Section header string table index: 27

Section Headers:

Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .note.androi[...] NOTE 00000134 000134 000098 00 A 0 0 4
[ 2] .note.gnu.bu[...] NOTE 000001cc 0001cc 000024 00 A 0 0 4
[ 3] .dynsym DYNSYM 000001f0 0001f0 00d440 10 A 4 1 4
[ 4] .dynstr STRTAB 0000d630 00d630 01fb31 00 A 0 0 1
[ 5] .hash HASH 0002d164 02d164 00552c 04 A 3 0 4
[ 6] .gnu.version VERSYM 00032690 032690 001a88 02 A 3 0 2
[ 7] .gnu.version_d VERDEF 00034118 034118 00001c 00 A 4 1 4
[ 8] .gnu.version_r VERNEED 00034134 034134 000060 00 A 4 3 4
[ 9] .rel.dyn REL 00034194 034194 04ceb8 08 A 3 0 4
[10] .rel.plt REL 0008104c 08104c 000a68 08 AI 3 21 4
[11] .plt PROGBITS 00081ab4 081ab4 000fb0 00 AX 0 0 4
[12] .text PROGBITS 00082a70 082a70 5b579c 00 AX 0 0 16
[13] .ARM.exidx ARM_EXIDX 0063820c 63820c 0433e0 08 AL 12 0 4
[14] .ARM.extab PROGBITS 0067b5ec 67b5ec 04b270 00 A 0 0 4
[15] .rodata PROGBITS 006c6860 6c6860 1360fc 00 A 0 0 16
[16] .data.rel.ro[...] PROGBITS 007fdde0 7fcde0 000b24 00 WA 0 0 8
[17] .fini_array FINI_ARRAY 007fe904 7fd904 00000c 04 WA 0 0 4
[18] .data.rel.ro PROGBITS 007fe910 7fd910 046970 00 WA 0 0 16
[19] .init_array INIT_ARRAY 00845280 844280 000150 04 WA 0 0 4
[20] .dynamic DYNAMIC 008453d0 8443d0 000140 08 WA 4 0 4
[21] .got PROGBITS 00845514 844514 002aec 00 WA 0 0 4
[22] .data PROGBITS 00848000 847000 0c357c 00 WA 0 0 16
[23] .bss NOBITS 0090b580 90a57c 122718 00 WA 0 0 16
[24] .comment PROGBITS 00000000 90a57c 000163 01 MS 0 0 1
[25] .note.gnu.go[...] NOTE 00000000 90a6e0 00001c 00 0 0 4
[26] .ARM.attributes ARM_ATTRIBUTES 00000000 90a6fc 00003a 00 0 0 1
[27] .shstrtab STRTAB 00000000 90a736 00012a 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
y (purecode), p (processor specific)

There are no section groups in this file.

gobjdump -x libagora-rtc-sdk-jni.so

ibagora-rtc-sdk.so: file format elf32-littlearm
libagora-rtc-sdk.so
architecture: armv7, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00000000

Program Header:
PHDR off 0x00000034 vaddr 0x00000034 paddr 0x00000034 align 22
filesz 0x00000100 memsz 0x00000100 flags r--
LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2
12
filesz 0x007fc95c memsz 0x007fc95c flags r-x
LOAD off 0x007fcde0 vaddr 0x007fdde0 paddr 0x007fdde0 align 212
filesz 0x0010d79c memsz 0x0022feb8 flags rw-
DYNAMIC off 0x008443d0 vaddr 0x008453d0 paddr 0x008453d0 align 2
2
filesz 0x00000140 memsz 0x00000140 flags rw-
NOTE off 0x00000134 vaddr 0x00000134 paddr 0x00000134 align 22
filesz 0x000000bc memsz 0x000000bc flags r--
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2
4
filesz 0x00000000 memsz 0x00000000 flags rw-
0x70000001 off 0x0063820c vaddr 0x0063820c paddr 0x0063820c align 22
filesz 0x000433e0 memsz 0x000433e0 flags r--
RELRO off 0x007fcde0 vaddr 0x007fdde0 paddr 0x007fdde0 align 2
4
filesz 0x0004a220 memsz 0x0004a220 flags rw-

Dynamic Section:
PLTGOT 0x00847ac0
PLTRELSZ 0x00000a68
JMPREL 0x0008104c
PLTREL 0x00000011
REL 0x00034194
RELSZ 0x0004ceb8
RELENT 0x00000008
RELCOUNT 0x0000999e
SYMTAB 0x000001f0
SYMENT 0x00000010
STRTAB 0x0000d630
STRSZ 0x0001fb31
HASH 0x0002d164
NEEDED libOpenSLES.so
NEEDED libEGL.so
NEEDED libGLESv1_CM.so
NEEDED libGLESv2.so
NEEDED libdl.so
NEEDED libm.so
NEEDED liblog.so
NEEDED libc.so
SONAME libagora-rtc-sdk.so
FINI_ARRAY 0x007fe904
FINI_ARRAYSZ 0x0000000c
INIT_ARRAY 0x00845280
INIT_ARRAYSZ 0x00000150
SYMBOLIC 0x00000000
FLAGS 0x0000000a
FLAGS_1 0x00000001
VERSYM 0x00032690
VERDEF 0x00034118
VERDEFNUM 0x00000001
VERNEED 0x00034134
VERNEEDNUM 0x00000003

Version definitions:
1 0x01 0x0e4641cf libagora-rtc-sdk.so

Version References:
required from libc.so:
0x00050d63 0x00 02 LIBC
required from libm.so:
0x00050d63 0x00 03 LIBC
required from libdl.so:
0x00050d63 0x00 04 LIBC
private flags = 0x5000200: [Version5 EABI] [soft-float ABI]

Sections:
Idx Name Size VMA LMA File off Algn
0 .note.android.ident 00000098 00000134 00000134 00000134 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.gnu.build-id 00000024 000001cc 000001cc 000001cc 2
2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .dynsym 0000d440 000001f0 000001f0 000001f0 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynstr 0001fb31 0000d630 0000d630 0000d630 2
0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .hash 0000552c 0002d164 0002d164 0002d164 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.version 00001a88 00032690 00032690 00032690 2
1
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .gnu.version_d 0000001c 00034118 00034118 00034118 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .gnu.version_r 00000060 00034134 00034134 00034134 2
2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .rel.dyn 0004ceb8 00034194 00034194 00034194 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .rel.plt 00000a68 0008104c 0008104c 0008104c 2
2
CONTENTS, ALLOC, LOAD, READONLY, DATA
10 .plt 00000fb0 00081ab4 00081ab4 00081ab4 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .text 005b579c 00082a70 00082a70 00082a70 2
4
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .ARM.exidx 000433e0 0063820c 0063820c 0063820c 22
CONTENTS, ALLOC, LOAD, READONLY, DATA
13 .ARM.extab 0004b270 0067b5ec 0067b5ec 0067b5ec 2
2
CONTENTS, ALLOC, LOAD, READONLY, DATA
14 .rodata 001360fc 006c6860 006c6860 006c6860 24
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .data.rel.ro.local 00000b24 007fdde0 007fdde0 007fcde0 2
3
CONTENTS, ALLOC, LOAD, DATA
16 .fini_array 0000000c 007fe904 007fe904 007fd904 22
CONTENTS, ALLOC, LOAD, DATA
17 .data.rel.ro 00046970 007fe910 007fe910 007fd910 2
4
CONTENTS, ALLOC, LOAD, DATA
18 .init_array 00000150 00845280 00845280 00844280 22
CONTENTS, ALLOC, LOAD, DATA
19 .dynamic 00000140 008453d0 008453d0 008443d0 2
2
CONTENTS, ALLOC, LOAD, DATA
20 .got 00002aec 00845514 00845514 00844514 22
CONTENTS, ALLOC, LOAD, DATA
21 .data 000c357c 00848000 00848000 00847000 2
4
CONTENTS, ALLOC, LOAD, DATA
22 .bss 00122718 0090b580 0090b580 0090a57c 24
ALLOC
23 .comment 00000163 00000000 00000000 0090a57c 2
0
CONTENTS, READONLY
24 .note.gnu.gold-version 0000001c 00000000 00000000 0090a6e0 22
CONTENTS, READONLY, OCTETS
25 .ARM.attributes 0000003a 00000000 00000000 0090a6fc 2
0
CONTENTS, READONLY
SYMBOL TABLE:
no symbols

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,817评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,329评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,354评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,498评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,600评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,829评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,979评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,722评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,189评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,519评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,654评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,329评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,940评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,762评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,993评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,382评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,543评论 2 349

推荐阅读更多精彩内容