您好,登录后才能下订单哦!
关于这个问题,其实编译器带-g就会有调试信息。这是gcc相关的。
默认其实android编译的就是带符号表的,只是在strip掉了。
例如下面的操作:
/$ find . | grep libext2_e2p.so
./obj/SHARED_LIBRARIES/libext2_e2p_intermediates/LINKED/libext2_e2p.so
./obj/lib/libext2_e2p.so
./symbols/system/lib64/libext2_e2p.so
./symbols/system/lib/libext2_e2p.so
./obj_arm/SHARED_LIBRARIES/libext2_e2p_intermediates/LINKED/libext2_e2p.so
./obj_arm/lib/libext2_e2p.so
./system/lib64/libext2_e2p.so
./system/lib/libext2_e2p.so
/$ ls -l ./obj/SHARED_LIBRARIES/libext2_e2p_intermediates/LINKED/libext2_e2p.so
-rwxrwxr-x 1 neil neil 109808 12月 19 21:20 ./obj/SHARED_LIBRARIES/libext2_e2p_intermediates/LINKED/libext2_e2p.so
/$ ls -l ./obj/lib/libext2_e2p.so
-rwxrwxr-x 1 neil neil 31448 12月 19 21:25 ./obj/lib/libext2_e2p.so
/$ ls -l ./symbols/system/lib64/libext2_e2p.so
-rwxrwxr-x 1 neil neil 109808 12月 19 21:24 ./symbols/system/lib64/libext2_e2p.so
/$ ls -l ./symbols/system/lib/libext2_e2p.so
-rwxrwxr-x 1 neil neil 86172 12月 19 21:20 ./symbols/system/lib/libext2_e2p.so
/$ ls -l ./system/lib64/libext2_e2p.so
-rwxrwxr-x 1 neil neil 31448 12月 19 21:27 ./system/lib64/libext2_e2p.so
/$ ls -l ./system/lib/libext2_e2p.so
-rwxrwxr-x 1 neil neil 22444 12月 19 21:25 ./system/lib/libext2_e2p.so
从上面可以看出,stip前和strip后,文件大小不同。
由于strip前后,elf文件的其他section段的内容没有变化,只是删除了symbol和debug的section,所以程序跑strip后的elf文件,调试时使用strip前有符号表的elf文件,不会出问题,因为他们的代码和数据部分相同。
/$ readelf -S ./system/lib/libext2_e2p.so
There are 21 section headers, starting at offset 0x5464:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00000134 000134 000013 00 A 0 0 1
[ 2] .dynsym DYNSYM 00000148 000148 0004b0 10 A 3 1 4
[ 3] .dynstr STRTAB 000005f8 0005f8 000381 00 A 0 0 1
[ 4] .hash HASH 0000097c 00097c 000240 04 A 2 0 4
[ 5] .rel.dyn REL 00000bbc 000bbc 0002e8 08 A 2 0 4
[ 6] .rel.plt REL 00000ea4 000ea4 000180 08 A 2 7 4
[ 7] .plt PROGBITS 00001024 001024 000254 00 AX 0 0 4
[ 8] .text PROGBITS 00001278 001278 001da0 00 AX 0 0 4
[ 9] .ARM.exidx ARM_EXIDX 00003018 003018 000108 08 AL 8 0 4
[10] .rodata PROGBITS 00003120 003120 000fb8 00 A 0 0 4
[11] .ARM.extab PROGBITS 000040d8 0040d8 00000c 00 A 0 0 4
[12] .fini_array FINI_ARRAY 00005e60 004e60 000004 00 WA 0 0 4
[13] .dynamic DYNAMIC 00005e64 004e64 0000c8 08 WA 3 0 4
[14] .got PROGBITS 00005f2c 004f2c 0000d4 00 WA 0 0 4
[15] .data PROGBITS 00006000 005000 000344 00 WA 0 0 4
[16] .bss NOBITS 00006344 005344 0001f0 00 WA 0 0 4
[17] .comment PROGBITS 00000000 005344 000010 01 MS 0 0 1
[18] .note.gnu.gold-ve NOTE 00000000 005354 00001c 00 0 0 4
[19] .ARM.attributes ARM_ATTRIBUTES 00000000 005370 000040 00 0 0 1
[20] .shstrtab STRTAB 00000000 0053b0 0000b4 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
/$ readelf -S ./symbols/system/lib/libext2_e2p.so
There are 31 section headers, starting at offset 0x14bc4:
可以看到上面的文件没有symbol的section
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00000134 000134 000013 00 A 0 0 1
[ 2] .dynsym DYNSYM 00000148 000148 0004b0 10 A 3 1 4
[ 3] .dynstr STRTAB 000005f8 0005f8 000381 00 A 0 0 1
[ 4] .hash HASH 0000097c 00097c 000240 04 A 2 0 4
[ 5] .rel.dyn REL 00000bbc 000bbc 0002e8 08 A 2 0 4
[ 6] .rel.plt REL 00000ea4 000ea4 000180 08 A 2 0 4
[ 7] .plt PROGBITS 00001024 001024 000254 00 AX 0 0 4
[ 8] .text PROGBITS 00001278 001278 001da0 00 AX 0 0 4
[ 9] .ARM.exidx ARM_EXIDX 00003018 003018 000108 08 AL 8 0 4
[10] .rodata PROGBITS 00003120 003120 000fb8 00 A 0 0 4
[11] .ARM.extab PROGBITS 000040d8 0040d8 00000c 00 A 0 0 4
[12] .fini_array FINI_ARRAY 00005e60 004e60 000004 00 WA 0 0 4
[13] .dynamic DYNAMIC 00005e64 004e64 0000c8 08 WA 3 0 4
[14] .got PROGBITS 00005f2c 004f2c 0000d4 00 WA 0 0 4
[15] .data PROGBITS 00006000 005000 000344 00 WA 0 0 4
[16] .bss NOBITS 00006344 005344 0001f0 00 WA 0 0 4
[17] .comment PROGBITS 00000000 005344 000010 01 MS 0 0 1
[18] .debug_info PROGBITS 00000000 005354 005b3f 00 0 0 1
[19] .debug_abbrev PROGBITS 00000000 00ae93 001daf 00 0 0 1
[20] .debug_loc PROGBITS 00000000 00cc42 002d90 00 0 0 1
[21] .debug_aranges PROGBITS 00000000 00f9d2 0002e8 00 0 0 1
[22] .debug_ranges PROGBITS 00000000 00fcba 000438 00 0 0 1
[23] .debug_line PROGBITS 00000000 0100f2 001aa6 00 0 0 1
[24] .debug_str PROGBITS 00000000 011b98 001432 01 MS 0 0 1
[25] .debug_frame PROGBITS 00000000 012fcc 000514 00 0 0 4
[26] .note.gnu.gold-ve NOTE 00000000 0134e0 00001c 00 0 0 4
[27] .ARM.attributes ARM_ATTRIBUTES 00000000 0134fc 000040 00 0 0 1
[28] .symtab SYMTAB 00000000 01353c 001030 10 29 185 4
[29] .strtab STRTAB 00000000 01456c 00052e 00 0 0 1
[30] .shstrtab STRTAB 00000000 014a9a 00012a 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
/$
可以看到上面的文件有symbol的section
可以看到,symbol/system目录的.so库文件大小比system目录的大。因为含有符号表。
关于ELF文件的介绍和linux中的加载原理和实现,欢迎观看我的视频:
https://edu.51cto.com/course/17147.html
关于具体的写linux驱动的方法、技巧和注意事项,欢迎观看我的《如何编写linux设备驱动》的视频:
https://edu.51cto.com/course/17132.html
另外我的相关培训视频请看:
欢迎观看我发布的各个课程: https://edu.51cto.com/lecturer/8896847.html
另外我的免费的linux各种驱动开发课程如下:
https://edu.51cto.com/course/17138.html
我的新的更多优惠的打包课程链接如下:
https://edu.51cto.com/sd/0a9d4
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。