当前位置:   article > 正文

二进制安全-ELF-实验:查看ELF内容_elf文件怎么查看

elf文件怎么查看

1 需求

查看ELF依赖库

  • ldd main
  • readelf -d main | grep NEEDED

查看ELF section header

  • readelf -S --wide main
  • objdump -h --wide main

查看各个section具体内容

  •  objdump -s --wide main

查看静态符号表、动态符号表

  • readelf -s main
  • readelf --dyn-sym main
  • objdump -t main
  • objdump -T main

查看字符串符号表、指定wection具体内容

  • readelf -p 27 main

2 语法


3 示例

  1. #include <stdio.h>
  2. const char varConst[] = "I am const var";
  3. char varGlobal[] = "I am global var";
  4. char varGlobalNull;
  5. int main() {
  6. static char varStatic[] = "I am static var";
  7. char varLocal[] = "I am local var";
  8. char varLocalNull;
  9. printf("%s\n", varConst);
  10. printf("%s\n", varGlobal);
  11. printf("%s\n", varStatic);
  12. printf("%s\n", varLocal);
  13. return 0;
  14. }

gcc -o main main.c 


3 示例: 

file main

main: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=a69faf64ea4b1fd4ea2df0916499848d1c09609f, not stripped

size main

  1. text data bss dec hex filename
  2. 1726 640 8 2374 946 main

3 示例: 

ldd main

  1. linux-vdso.so.1 (0x00007ffe6b5e8000)
  2. libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f92bb71c000)
  3. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f92bb32b000)
  4. libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f92bb127000)
  5. libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f92baf08000)
  6. /lib64/ld-linux-x86-64.so.2 (0x00007f92bbb25000)

readelf -d main | grep NEEDED

0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

3 示例: 

readelf -S --wide main

  1. There are 29 section headers, starting at offset 0x1a10:
  2. Section Headers:
  3. [Nr] Name Type Address Off Size ES Flg Lk Inf Al
  4. [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
  5. [ 1] .interp PROGBITS 0000000000000238 000238 00001c 00 A 0 0 1
  6. [ 2] .note.ABI-tag NOTE 0000000000000254 000254 000020 00 A 0 0 4
  7. [ 3] .note.gnu.build-id NOTE 0000000000000274 000274 000024 00 A 0 0 4
  8. [ 4] .gnu.hash GNU_HASH 0000000000000298 000298 00001c 00 A 5 0 8
  9. [ 5] .dynsym DYNSYM 00000000000002b8 0002b8 0000c0 18 A 6 1 8
  10. [ 6] .dynstr STRTAB 0000000000000378 000378 00009d 00 A 0 0 1
  11. [ 7] .gnu.version VERSYM 0000000000000416 000416 000010 02 A 5 0 2
  12. [ 8] .gnu.version_r VERNEED 0000000000000428 000428 000030 00 A 6 1 8
  13. [ 9] .rela.dyn RELA 0000000000000458 000458 0000c0 18 A 5 0 8
  14. [10] .rela.plt RELA 0000000000000518 000518 000030 18 AI 5 22 8
  15. [11] .init PROGBITS 0000000000000548 000548 000017 00 AX 0 0 4
  16. [12] .plt PROGBITS 0000000000000560 000560 000030 10 AX 0 0 16
  17. [13] .plt.got PROGBITS 0000000000000590 000590 000008 08 AX 0 0 8
  18. [14] .text PROGBITS 00000000000005a0 0005a0 000202 00 AX 0 0 16
  19. [15] .fini PROGBITS 00000000000007a4 0007a4 000009 00 AX 0 0 4
  20. [16] .rodata PROGBITS 00000000000007b0 0007b0 000017 00 A 0 0 8
  21. [17] .eh_frame_hdr PROGBITS 00000000000007c8 0007c8 00003c 00 A 0 0 4
  22. [18] .eh_frame PROGBITS 0000000000000808 000808 000108 00 A 0 0 8
  23. [19] .init_array INIT_ARRAY 0000000000200db0 000db0 000008 08 WA 0 0 8
  24. [20] .fini_array FINI_ARRAY 0000000000200db8 000db8 000008 08 WA 0 0 8
  25. [21] .dynamic DYNAMIC 0000000000200dc0 000dc0 0001f0 10 WA 6 0 8
  26. [22] .got PROGBITS 0000000000200fb0 000fb0 000050 08 WA 0 0 8
  27. [23] .data PROGBITS 0000000000201000 001000 000030 00 WA 0 0 16
  28. [24] .bss NOBITS 0000000000201030 001030 000008 00 WA 0 0 1
  29. [25] .comment PROGBITS 0000000000000000 001030 000029 01 MS 0 0 1
  30. [26] .symtab SYMTAB 0000000000000000 001060 000660 18 27 44 8
  31. [27] .strtab STRTAB 0000000000000000 0016c0 00024e 00 0 0 1
  32. [28] .shstrtab STRTAB 0000000000000000 00190e 0000fe 00 0 0 1
  33. Key to Flags:
  34. W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  35. L (link order), O (extra OS processing required), G (group), T (TLS),
  36. C (compressed), x (unknown), o (OS specific), E (exclude),
  37. l (large), p (processor specific)

3 示例: 

 objdump -s --wide main

  • text:代码、已初始化的非静态局部变量
  • data:已初始化的全局变量、已初始化的静态局部变量
  • bss:
  • rodata:常量、函数实参
  • symtab:静态符号表
  • dynsym:动态符号表
  • strtab:字符串符号表
  • dynstr:动态字符串符号表

 

  1. main: file format elf64-x86-64
  2. Contents of section .interp:
  3. 0238 2f6c6962 36342f6c 642d6c69 6e75782d /lib64/ld-linux-
  4. 0248 7838362d 36342e73 6f2e3200 x86-64.so.2.
  5. Contents of section .note.ABI-tag:
  6. 0254 04000000 10000000 01000000 474e5500 ............GNU.
  7. 0264 00000000 03000000 02000000 00000000 ................
  8. Contents of section .note.gnu.build-id:
  9. 0274 04000000 14000000 03000000 474e5500 ............GNU.
  10. 0284 a69faf64 ea4b1fd4 ea2df091 6499848d ...d.K...-..d...
  11. 0294 1c09609f ..`.
  12. Contents of section .gnu.hash:
  13. 0298 01000000 01000000 01000000 00000000 ................
  14. 02a8 00000000 00000000 00000000 ............
  15. Contents of section .dynsym:
  16. 02b8 00000000 00000000 00000000 00000000 ................
  17. 02c8 00000000 00000000 58000000 20000000 ........X... ...
  18. 02d8 00000000 00000000 00000000 00000000 ................
  19. 02e8 0b000000 12000000 00000000 00000000 ................
  20. 02f8 00000000 00000000 10000000 12000000 ................
  21. 0308 00000000 00000000 00000000 00000000 ................
  22. 0318 30000000 12000000 00000000 00000000 0...............
  23. 0328 00000000 00000000 74000000 20000000 ........t... ...
  24. 0338 00000000 00000000 00000000 00000000 ................
  25. 0348 83000000 20000000 00000000 00000000 .... ...........
  26. 0358 00000000 00000000 21000000 22000000 ........!..."...
  27. 0368 00000000 00000000 00000000 00000000 ................
  28. Contents of section .dynstr:
  29. 0378 006c6962 632e736f 2e360070 75747300 .libc.so.6.puts.
  30. 0388 5f5f7374 61636b5f 63686b5f 6661696c __stack_chk_fail
  31. 0398 005f5f63 78615f66 696e616c 697a6500 .__cxa_finalize.
  32. 03a8 5f5f6c69 62635f73 74617274 5f6d6169 __libc_start_mai
  33. 03b8 6e00474c 4942435f 322e3400 474c4942 n.GLIBC_2.4.GLIB
  34. 03c8 435f322e 322e3500 5f49544d 5f646572 C_2.2.5._ITM_der
  35. 03d8 65676973 74657254 4d436c6f 6e655461 egisterTMCloneTa
  36. 03e8 626c6500 5f5f676d 6f6e5f73 74617274 ble.__gmon_start
  37. 03f8 5f5f005f 49544d5f 72656769 73746572 __._ITM_register
  38. 0408 544d436c 6f6e6554 61626c65 00 TMCloneTable.
  39. Contents of section .gnu.version:
  40. 0416 00000000 02000300 02000000 00000200 ................
  41. Contents of section .gnu.version_r:
  42. 0428 01000200 01000000 10000000 00000000 ................
  43. 0438 1469690d 00000300 42000000 10000000 .ii.....B.......
  44. 0448 751a6909 00000200 4c000000 00000000 u.i.....L.......
  45. Contents of section .rela.dyn:
  46. 0458 b00d2000 00000000 08000000 00000000 .. .............
  47. 0468 a0060000 00000000 b80d2000 00000000 .......... .....
  48. 0478 08000000 00000000 60060000 00000000 ........`.......
  49. 0488 08102000 00000000 08000000 00000000 .. .............
  50. 0498 08102000 00000000 d80f2000 00000000 .. ....... .....
  51. 04a8 06000000 01000000 00000000 00000000 ................
  52. 04b8 e00f2000 00000000 06000000 04000000 .. .............
  53. 04c8 00000000 00000000 e80f2000 00000000 .......... .....
  54. 04d8 06000000 05000000 00000000 00000000 ................
  55. 04e8 f00f2000 00000000 06000000 06000000 .. .............
  56. 04f8 00000000 00000000 f80f2000 00000000 .......... .....
  57. 0508 06000000 07000000 00000000 00000000 ................
  58. Contents of section .rela.plt:
  59. 0518 c80f2000 00000000 07000000 02000000 .. .............
  60. 0528 00000000 00000000 d00f2000 00000000 .......... .....
  61. 0538 07000000 03000000 00000000 00000000 ................
  62. Contents of section .init:
  63. 0548 4883ec08 488b0595 0a200048 85c07402 H...H.... .H..t.
  64. 0558 ffd04883 c408c3 ..H....
  65. Contents of section .plt:
  66. 0560 ff35520a 2000ff25 540a2000 0f1f4000 .5R. ..%T. ...@.
  67. 0570 ff25520a 20006800 000000e9 e0ffffff .%R. .h.........
  68. 0580 ff254a0a 20006801 000000e9 d0ffffff .%J. .h.........
  69. Contents of section .plt.got:
  70. 0590 ff25620a 20006690 .%b. .f.
  71. Contents of section .text:
  72. 05a0 31ed4989 d15e4889 e24883e4 f050544c 1.I..^H..H...PTL
  73. 05b0 8d05ea01 0000488d 0d730100 00488d3d ......H..s...H.=
  74. 05c0 e6000000 ff15160a 2000f40f 1f440000 ........ ....D..
  75. 05d0 488d3d59 0a200055 488d0551 0a200048 H.=Y. .UH..Q. .H
  76. 05e0 39f84889 e5741948 8b05ea09 20004885 9.H..t.H.... .H.
  77. 05f0 c0740d5d ffe0662e 0f1f8400 00000000 .t.]..f.........
  78. 0600 5dc30f1f 4000662e 0f1f8400 00000000 ]...@.f.........
  79. 0610 488d3d19 0a200048 8d35120a 20005548 H.=.. .H.5.. .UH
  80. 0620 29fe4889 e548c1fe 034889f0 48c1e83f ).H..H...H..H..?
  81. 0630 4801c648 d1fe7418 488b05b1 09200048 H..H..t.H.... .H
  82. 0640 85c0740c 5dffe066 0f1f8400 00000000 ..t.]..f........
  83. 0650 5dc30f1f 4000662e 0f1f8400 00000000 ]...@.f.........
  84. 0660 803dc909 20000075 2f48833d 87092000 .=.. ..u/H.=.. .
  85. 0670 00554889 e5740c48 8b3d8a09 2000e80d .UH..t.H.=.. ...
  86. 0680 ffffffe8 48ffffff c605a109 2000015d ....H....... ..]
  87. 0690 c30f1f80 00000000 f3c3660f 1f440000 ..........f..D..
  88. 06a0 554889e5 5de966ff ffff5548 89e54883 UH..].f...UH..H.
  89. 06b0 ec206448 8b042528 00000048 8945f831 . dH..%(...H.E.1
  90. 06c0 c048b849 20616d20 6c6f6348 8945e9c7 .H.I am locH.E..
  91. 06d0 45f1616c 207666c7 45f56172 c645f700 E.al vf.E.ar.E..
  92. 06e0 488d3dd1 000000e8 84feffff 488d3d1d H.=.........H.=.
  93. 06f0 092000e8 78feffff 488d3d21 092000e8 . ..x...H.=!. ..
  94. 0700 6cfeffff 488d45e9 4889c7e8 60feffff l...H.E.H...`...
  95. 0710 b8000000 00488b55 f8644833 14252800 .....H.U.dH3.%(.
  96. 0720 00007405 e857feff ffc9c30f 1f440000 ..t..W.......D..
  97. 0730 41574156 4989d741 5541544c 8d256e06 AWAVI..AUATL.%n.
  98. 0740 20005548 8d2d6e06 20005341 89fd4989 .UH.-n. .SA..I.
  99. 0750 f64c29e5 4883ec08 48c1fd03 e8e7fdff .L).H...H.......
  100. 0760 ff4885ed 742031db 0f1f8400 00000000 .H..t 1.........
  101. 0770 4c89fa4c 89f64489 ef41ff14 dc4883c3 L..L..D..A...H..
  102. 0780 014839dd 75ea4883 c4085b5d 415c415d .H9.u.H...[]A\A]
  103. 0790 415e415f c390662e 0f1f8400 00000000 A^A_..f.........
  104. 07a0 f3c3 ..
  105. Contents of section .fini:
  106. 07a4 4883ec08 4883c408 c3 H...H....
  107. Contents of section .rodata:
  108. 07b0 01000200 00000000 4920616d 20636f6e ........I am con
  109. 07c0 73742076 617200 st var.
  110. Contents of section .eh_frame_hdr:
  111. 07c8 011b033b 3c000000 06000000 98fdffff ...;<...........
  112. 07d8 88000000 c8fdffff b0000000 d8fdffff ................
  113. 07e8 58000000 e2feffff c8000000 68ffffff X...........h...
  114. 07f8 e8000000 d8ffffff 30010000 ........0...
  115. Contents of section .eh_frame:
  116. 0808 14000000 00000000 017a5200 01781001 .........zR..x..
  117. 0818 1b0c0708 90010710 14000000 1c000000 ................
  118. 0828 78fdffff 2b000000 00000000 00000000 x...+...........
  119. 0838 14000000 00000000 017a5200 01781001 .........zR..x..
  120. 0848 1b0c0708 90010000 24000000 1c000000 ........$.......
  121. 0858 08fdffff 30000000 000e1046 0e184a0f ....0......F..J.
  122. 0868 0b770880 003f1a3b 2a332422 00000000 .w...?.;*3$"....
  123. 0878 14000000 44000000 10fdffff 08000000 ....D...........
  124. 0888 00000000 00000000 1c000000 5c000000 ............\...
  125. 0898 12feffff 81000000 00410e10 8602430d .........A....C.
  126. 08a8 06027c0c 07080000 44000000 7c000000 ..|.....D...|...
  127. 08b8 78feffff 65000000 00420e10 8f02420e x...e....B....B.
  128. 08c8 188e0345 0e208d04 420e288c 05480e30 ...E. ..B.(..H.0
  129. 08d8 8606480e 3883074d 0e40720e 38410e30 ..H.8..M.@r.8A.0
  130. 08e8 410e2842 0e20420e 18420e10 420e0800 A.(B. B..B..B...
  131. 08f8 10000000 c4000000 a0feffff 02000000 ................
  132. 0908 00000000 00000000 ........
  133. Contents of section .init_array:
  134. 200db0 a0060000 00000000 ........
  135. Contents of section .fini_array:
  136. 200db8 60060000 00000000 `.......
  137. Contents of section .dynamic:
  138. 200dc0 01000000 00000000 01000000 00000000 ................
  139. 200dd0 0c000000 00000000 48050000 00000000 ........H.......
  140. 200de0 0d000000 00000000 a4070000 00000000 ................
  141. 200df0 19000000 00000000 b00d2000 00000000 .......... .....
  142. 200e00 1b000000 00000000 08000000 00000000 ................
  143. 200e10 1a000000 00000000 b80d2000 00000000 .......... .....
  144. 200e20 1c000000 00000000 08000000 00000000 ................
  145. 200e30 f5feff6f 00000000 98020000 00000000 ...o............
  146. 200e40 05000000 00000000 78030000 00000000 ........x.......
  147. 200e50 06000000 00000000 b8020000 00000000 ................
  148. 200e60 0a000000 00000000 9d000000 00000000 ................
  149. 200e70 0b000000 00000000 18000000 00000000 ................
  150. 200e80 15000000 00000000 00000000 00000000 ................
  151. 200e90 03000000 00000000 b00f2000 00000000 .......... .....
  152. 200ea0 02000000 00000000 30000000 00000000 ........0.......
  153. 200eb0 14000000 00000000 07000000 00000000 ................
  154. 200ec0 17000000 00000000 18050000 00000000 ................
  155. 200ed0 07000000 00000000 58040000 00000000 ........X.......
  156. 200ee0 08000000 00000000 c0000000 00000000 ................
  157. 200ef0 09000000 00000000 18000000 00000000 ................
  158. 200f00 1e000000 00000000 08000000 00000000 ................
  159. 200f10 fbffff6f 00000000 01000008 00000000 ...o............
  160. 200f20 feffff6f 00000000 28040000 00000000 ...o....(.......
  161. 200f30 ffffff6f 00000000 01000000 00000000 ...o............
  162. 200f40 f0ffff6f 00000000 16040000 00000000 ...o............
  163. 200f50 f9ffff6f 00000000 03000000 00000000 ...o............
  164. 200f60 00000000 00000000 00000000 00000000 ................
  165. 200f70 00000000 00000000 00000000 00000000 ................
  166. 200f80 00000000 00000000 00000000 00000000 ................
  167. 200f90 00000000 00000000 00000000 00000000 ................
  168. 200fa0 00000000 00000000 00000000 00000000 ................
  169. Contents of section .got:
  170. 200fb0 c00d2000 00000000 00000000 00000000 .. .............
  171. 200fc0 00000000 00000000 76050000 00000000 ........v.......
  172. 200fd0 86050000 00000000 00000000 00000000 ................
  173. 200fe0 00000000 00000000 00000000 00000000 ................
  174. 200ff0 00000000 00000000 00000000 00000000 ................
  175. Contents of section .data:
  176. 201000 00000000 00000000 08102000 00000000 .......... .....
  177. 201010 4920616d 20676c6f 62616c20 76617200 I am global var.
  178. 201020 4920616d 20737461 74696320 76617200 I am static var.
  179. Contents of section .comment:
  180. 0000 4743433a 20285562 756e7475 20372e35 GCC: (Ubuntu 7.5
  181. 0010 2e302d33 7562756e 7475317e 31382e30 .0-3ubuntu1~18.0
  182. 0020 34292037 2e352e30 00 4) 7.5.0.

3 示例:

readelf -s main

  1. Symbol table '.dynsym' contains 8 entries:
  2. Num: Value Size Type Bind Vis Ndx Name
  3. 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
  4. 1: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
  5. 2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2)
  6. 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@GLIBC_2.4 (3)
  7. 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (2)
  8. 5: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
  9. 6: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
  10. 7: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.2.5 (2)
  11. Symbol table '.symtab' contains 68 entries:
  12. Num: Value Size Type Bind Vis Ndx Name
  13. 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
  14. 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1
  15. 2: 0000000000000254 0 SECTION LOCAL DEFAULT 2
  16. 3: 0000000000000274 0 SECTION LOCAL DEFAULT 3
  17. 4: 0000000000000298 0 SECTION LOCAL DEFAULT 4
  18. 5: 00000000000002b8 0 SECTION LOCAL DEFAULT 5
  19. 6: 0000000000000378 0 SECTION LOCAL DEFAULT 6
  20. 7: 0000000000000416 0 SECTION LOCAL DEFAULT 7
  21. 8: 0000000000000428 0 SECTION LOCAL DEFAULT 8
  22. 9: 0000000000000458 0 SECTION LOCAL DEFAULT 9
  23. 10: 0000000000000518 0 SECTION LOCAL DEFAULT 10
  24. 11: 0000000000000548 0 SECTION LOCAL DEFAULT 11
  25. 12: 0000000000000560 0 SECTION LOCAL DEFAULT 12
  26. 13: 0000000000000590 0 SECTION LOCAL DEFAULT 13
  27. 14: 00000000000005a0 0 SECTION LOCAL DEFAULT 14
  28. 15: 00000000000007a4 0 SECTION LOCAL DEFAULT 15
  29. 16: 00000000000007b0 0 SECTION LOCAL DEFAULT 16
  30. 17: 00000000000007c8 0 SECTION LOCAL DEFAULT 17
  31. 18: 0000000000000808 0 SECTION LOCAL DEFAULT 18
  32. 19: 0000000000200db0 0 SECTION LOCAL DEFAULT 19
  33. 20: 0000000000200db8 0 SECTION LOCAL DEFAULT 20
  34. 21: 0000000000200dc0 0 SECTION LOCAL DEFAULT 21
  35. 22: 0000000000200fb0 0 SECTION LOCAL DEFAULT 22
  36. 23: 0000000000201000 0 SECTION LOCAL DEFAULT 23
  37. 24: 0000000000201030 0 SECTION LOCAL DEFAULT 24
  38. 25: 0000000000000000 0 SECTION LOCAL DEFAULT 25
  39. 26: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
  40. 27: 00000000000005d0 0 FUNC LOCAL DEFAULT 14 deregister_tm_clones
  41. 28: 0000000000000610 0 FUNC LOCAL DEFAULT 14 register_tm_clones
  42. 29: 0000000000000660 0 FUNC LOCAL DEFAULT 14 __do_global_dtors_aux
  43. 30: 0000000000201030 1 OBJECT LOCAL DEFAULT 24 completed.7698
  44. 31: 0000000000200db8 0 OBJECT LOCAL DEFAULT 20 __do_global_dtors_aux_fin
  45. 32: 00000000000006a0 0 FUNC LOCAL DEFAULT 14 frame_dummy
  46. 33: 0000000000200db0 0 OBJECT LOCAL DEFAULT 19 __frame_dummy_init_array_
  47. 34: 0000000000000000 0 FILE LOCAL DEFAULT ABS main.c
  48. 35: 0000000000201020 16 OBJECT LOCAL DEFAULT 23 varStatic.2252
  49. 36: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
  50. 37: 000000000000090c 0 OBJECT LOCAL DEFAULT 18 __FRAME_END__
  51. 38: 0000000000000000 0 FILE LOCAL DEFAULT ABS
  52. 39: 0000000000200db8 0 NOTYPE LOCAL DEFAULT 19 __init_array_end
  53. 40: 0000000000200dc0 0 OBJECT LOCAL DEFAULT 21 _DYNAMIC
  54. 41: 0000000000200db0 0 NOTYPE LOCAL DEFAULT 19 __init_array_start
  55. 42: 00000000000007c8 0 NOTYPE LOCAL DEFAULT 17 __GNU_EH_FRAME_HDR
  56. 43: 0000000000200fb0 0 OBJECT LOCAL DEFAULT 22 _GLOBAL_OFFSET_TABLE_
  57. 44: 00000000000007a0 2 FUNC GLOBAL DEFAULT 14 __libc_csu_fini
  58. 45: 0000000000201010 16 OBJECT GLOBAL DEFAULT 23 varGlobal
  59. 46: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
  60. 47: 0000000000201000 0 NOTYPE WEAK DEFAULT 23 data_start
  61. 48: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@@GLIBC_2.2.5
  62. 49: 0000000000201030 0 NOTYPE GLOBAL DEFAULT 23 _edata
  63. 50: 00000000000007a4 0 FUNC GLOBAL DEFAULT 15 _fini
  64. 51: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@@GLIBC_2
  65. 52: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
  66. 53: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 23 __data_start
  67. 54: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
  68. 55: 0000000000201008 0 OBJECT GLOBAL HIDDEN 23 __dso_handle
  69. 56: 00000000000007b0 4 OBJECT GLOBAL DEFAULT 16 _IO_stdin_used
  70. 57: 0000000000000730 101 FUNC GLOBAL DEFAULT 14 __libc_csu_init
  71. 58: 0000000000201038 0 NOTYPE GLOBAL DEFAULT 24 _end
  72. 59: 00000000000005a0 43 FUNC GLOBAL DEFAULT 14 _start
  73. 60: 0000000000201030 0 NOTYPE GLOBAL DEFAULT 24 __bss_start
  74. 61: 00000000000006aa 129 FUNC GLOBAL DEFAULT 14 main
  75. 62: 0000000000201030 0 OBJECT GLOBAL HIDDEN 23 __TMC_END__
  76. 63: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
  77. 64: 00000000000007b8 15 OBJECT GLOBAL DEFAULT 16 varConst
  78. 65: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@@GLIBC_2.2
  79. 66: 0000000000000548 0 FUNC GLOBAL DEFAULT 11 _init
  80. 67: 0000000000201031 1 OBJECT GLOBAL DEFAULT 24 varGlobalNull

readelf --dyn-sym main

  1. Symbol table '.dynsym' contains 8 entries:
  2. Num: Value Size Type Bind Vis Ndx Name
  3. 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
  4. 1: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_deregisterTMCloneTab
  5. 2: 0000000000000000 0 FUNC GLOBAL DEFAULT UND puts@GLIBC_2.2.5 (2)
  6. 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@GLIBC_2.4 (3)
  7. 4: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 (2)
  8. 5: 0000000000000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
  9. 6: 0000000000000000 0 NOTYPE WEAK DEFAULT UND _ITM_registerTMCloneTable
  10. 7: 0000000000000000 0 FUNC WEAK DEFAULT UND __cxa_finalize@GLIBC_2.2.5 (2)

objdump -t main

  1. main: file format elf64-x86-64
  2. SYMBOL TABLE:
  3. 0000000000000238 l d .interp 0000000000000000 .interp
  4. 0000000000000254 l d .note.ABI-tag 0000000000000000 .note.ABI-tag
  5. 0000000000000274 l d .note.gnu.build-id 0000000000000000 .note.gnu.build-id
  6. 0000000000000298 l d .gnu.hash 0000000000000000 .gnu.hash
  7. 00000000000002b8 l d .dynsym 0000000000000000 .dynsym
  8. 0000000000000378 l d .dynstr 0000000000000000 .dynstr
  9. 0000000000000416 l d .gnu.version 0000000000000000 .gnu.version
  10. 0000000000000428 l d .gnu.version_r 0000000000000000 .gnu.version_r
  11. 0000000000000458 l d .rela.dyn 0000000000000000 .rela.dyn
  12. 0000000000000518 l d .rela.plt 0000000000000000 .rela.plt
  13. 0000000000000548 l d .init 0000000000000000 .init
  14. 0000000000000560 l d .plt 0000000000000000 .plt
  15. 0000000000000590 l d .plt.got 0000000000000000 .plt.got
  16. 00000000000005a0 l d .text 0000000000000000 .text
  17. 00000000000007a4 l d .fini 0000000000000000 .fini
  18. 00000000000007b0 l d .rodata 0000000000000000 .rodata
  19. 00000000000007c8 l d .eh_frame_hdr 0000000000000000 .eh_frame_hdr
  20. 0000000000000808 l d .eh_frame 0000000000000000 .eh_frame
  21. 0000000000200db0 l d .init_array 0000000000000000 .init_array
  22. 0000000000200db8 l d .fini_array 0000000000000000 .fini_array
  23. 0000000000200dc0 l d .dynamic 0000000000000000 .dynamic
  24. 0000000000200fb0 l d .got 0000000000000000 .got
  25. 0000000000201000 l d .data 0000000000000000 .data
  26. 0000000000201030 l d .bss 0000000000000000 .bss
  27. 0000000000000000 l d .comment 0000000000000000 .comment
  28. 0000000000000000 l df *ABS* 0000000000000000 crtstuff.c
  29. 00000000000005d0 l F .text 0000000000000000 deregister_tm_clones
  30. 0000000000000610 l F .text 0000000000000000 register_tm_clones
  31. 0000000000000660 l F .text 0000000000000000 __do_global_dtors_aux
  32. 0000000000201030 l O .bss 0000000000000001 completed.7698
  33. 0000000000200db8 l O .fini_array 0000000000000000 __do_global_dtors_aux_fini_array_entry
  34. 00000000000006a0 l F .text 0000000000000000 frame_dummy
  35. 0000000000200db0 l O .init_array 0000000000000000 __frame_dummy_init_array_entry
  36. 0000000000000000 l df *ABS* 0000000000000000 main.c
  37. 0000000000201020 l O .data 0000000000000010 varStatic.2252
  38. 0000000000000000 l df *ABS* 0000000000000000 crtstuff.c
  39. 000000000000090c l O .eh_frame 0000000000000000 __FRAME_END__
  40. 0000000000000000 l df *ABS* 0000000000000000
  41. 0000000000200db8 l .init_array 0000000000000000 __init_array_end
  42. 0000000000200dc0 l O .dynamic 0000000000000000 _DYNAMIC
  43. 0000000000200db0 l .init_array 0000000000000000 __init_array_start
  44. 00000000000007c8 l .eh_frame_hdr 0000000000000000 __GNU_EH_FRAME_HDR
  45. 0000000000200fb0 l O .got 0000000000000000 _GLOBAL_OFFSET_TABLE_
  46. 00000000000007a0 g F .text 0000000000000002 __libc_csu_fini
  47. 0000000000201010 g O .data 0000000000000010 varGlobal
  48. 0000000000000000 w *UND* 0000000000000000 _ITM_deregisterTMCloneTable
  49. 0000000000201000 w .data 0000000000000000 data_start
  50. 0000000000000000 F *UND* 0000000000000000 puts@@GLIBC_2.2.5
  51. 0000000000201030 g .data 0000000000000000 _edata
  52. 00000000000007a4 g F .fini 0000000000000000 _fini
  53. 0000000000000000 F *UND* 0000000000000000 __stack_chk_fail@@GLIBC_2.4
  54. 0000000000000000 F *UND* 0000000000000000 __libc_start_main@@GLIBC_2.2.5
  55. 0000000000201000 g .data 0000000000000000 __data_start
  56. 0000000000000000 w *UND* 0000000000000000 __gmon_start__
  57. 0000000000201008 g O .data 0000000000000000 .hidden __dso_handle
  58. 00000000000007b0 g O .rodata 0000000000000004 _IO_stdin_used
  59. 0000000000000730 g F .text 0000000000000065 __libc_csu_init
  60. 0000000000201038 g .bss 0000000000000000 _end
  61. 00000000000005a0 g F .text 000000000000002b _start
  62. 0000000000201030 g .bss 0000000000000000 __bss_start
  63. 00000000000006aa g F .text 0000000000000081 main
  64. 0000000000201030 g O .data 0000000000000000 .hidden __TMC_END__
  65. 0000000000000000 w *UND* 0000000000000000 _ITM_registerTMCloneTable
  66. 00000000000007b8 g O .rodata 000000000000000f varConst
  67. 0000000000000000 w F *UND* 0000000000000000 __cxa_finalize@@GLIBC_2.2.5
  68. 0000000000000548 g F .init 0000000000000000 _init
  69. 0000000000201031 g O .bss 0000000000000001 varGlobalNull

objdump -T main

  1. main: file format elf64-x86-64
  2. DYNAMIC SYMBOL TABLE:
  3. 0000000000000000 w D *UND* 0000000000000000 _ITM_deregisterTMCloneTable
  4. 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 puts
  5. 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.4 __stack_chk_fail
  6. 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __libc_start_main
  7. 0000000000000000 w D *UND* 0000000000000000 __gmon_start__
  8. 0000000000000000 w D *UND* 0000000000000000 _ITM_registerTMCloneTable
  9. 0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_finalize

3 示例: 

readelf -p 27 main

  1. String dump of section '.strtab':
  2. [ 1] crtstuff.c
  3. [ c] deregister_tm_clones
  4. [ 21] __do_global_dtors_aux
  5. [ 37] completed.7698
  6. [ 46] __do_global_dtors_aux_fini_array_entry
  7. [ 6d] frame_dummy
  8. [ 79] __frame_dummy_init_array_entry
  9. [ 98] main.c
  10. [ 9f] varStatic.2252
  11. [ ae] __FRAME_END__
  12. [ bc] __init_array_end
  13. [ cd] _DYNAMIC
  14. [ d6] __init_array_start
  15. [ e9] __GNU_EH_FRAME_HDR
  16. [ fc] _GLOBAL_OFFSET_TABLE_
  17. [ 112] __libc_csu_fini
  18. [ 122] varGlobal
  19. [ 12c] _ITM_deregisterTMCloneTable
  20. [ 148] puts@@GLIBC_2.2.5
  21. [ 15a] _edata
  22. [ 161] __stack_chk_fail@@GLIBC_2.4
  23. [ 17d] __libc_start_main@@GLIBC_2.2.5
  24. [ 19c] __data_start
  25. [ 1a9] __gmon_start__
  26. [ 1b8] __dso_handle
  27. [ 1c5] _IO_stdin_used
  28. [ 1d4] __libc_csu_init
  29. [ 1e4] __bss_start
  30. [ 1f0] main
  31. [ 1f5] __TMC_END__
  32. [ 201] _ITM_registerTMCloneTable
  33. [ 21b] varConst
  34. [ 224] __cxa_finalize@@GLIBC_2.2.5
  35. [ 240] varGlobalNull

readelf -p 6 main 

  1. String dump of section '.dynstr':
  2. [ 1] libc.so.6
  3. [ b] puts
  4. [ 10] __stack_chk_fail
  5. [ 21] __cxa_finalize
  6. [ 30] __libc_start_main
  7. [ 42] GLIBC_2.4
  8. [ 4c] GLIBC_2.2.5
  9. [ 58] _ITM_deregisterTMCloneTable
  10. [ 74] __gmon_start__
  11. [ 83] _ITM_registerTMCloneTable

 readelf -p 23 main 

  1. String dump of section '.data':
  2. [ a]
  3. [ 10] I am global var
  4. [ 20] I am static var

readelf -p 16 main

  1. String dump of section '.rodata':
  2. [ 8] I am const var

readelf -p 24 main

Section '.bss' has no data to dump.

4 参考资料

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/160639
推荐阅读
相关标签
  

闽ICP备14008679号