当前位置: 首页 > news >正文

Linux 调试 (objdump/strace/strings)

目录

  • 1. Linux 调试 (objdump/strace/strings)
    • 1.1. 查看系统 glibc 版本号
    • 1.2. 查看 so/bin 中的依赖
    • 1.3. 调试 bin 报错原因
    • 1.4. 查看 so/bin 中字符串

1. Linux 调试 (objdump/strace/strings)

1.1. 查看系统 glibc 版本号

1. 第一种
# ldd --version
ldd (Ubuntu GLIBC 2.27-3ubuntu1) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.2. 第二种
# ls -alh /lib/x86_64-linux-gnu/libc.so.6 
lrwxrwxrwx 1 root root 12 Apr 17  2018 /lib/x86_64-linux-gnu/libc.so.6 -> libc-2.27.so
注意:libc-2.27.so :版本号即 2.27# strings /lib/x86_64-linux-gnu/libc-2.27.so |grep -in5 versionGNU C Library (Ubuntu GLIBC 2.27-3ubuntu1) stable release version 2.27.
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.3. 第三种
//glibc_version.c
#include <stdio.h>
#include <gnu/libc-version.h>
int main(void)
{printf("glic_version = %s\n",gnu_get_libc_version());return 0;
}
# gcc glibc_version.c
# ./a.out
glic_version = 2.27

1.2. 查看 so/bin 中的依赖

# objdump
Usage: objdump <option(s)> <file(s)>Display information from object <file(s)>.At least one of the following switches must be given:-a, --archive-headers    Display archive header information-f, --file-headers       Display the contents of the overall file header-p, --private-headers    Display object format specific file header contents-P, --private=OPT,OPT... Display object format specific contents-h, --[section-]headers  Display the contents of the section headers-x, --all-headers        Display the contents of all headers-d, --disassemble        Display assembler contents of executable sections-D, --disassemble-all    Display assembler contents of all sections-S, --source             Intermix source code with disassembly-s, --full-contents      Display the full contents of all sections requested-g, --debugging          Display debug information in object file-e, --debugging-tags     Display debug information using ctags style-G, --stabs              Display (in raw form) any STABS info in the file-W[lLiaprmfFsoRtUuTgAckK] or--dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=frames-interp,=str,=loc,=Ranges,=pubtypes,=gdb_index,=trace_info,=trace_abbrev,=trace_aranges,=addr,=cu_index,=links,=follow-links]Display DWARF info in the file-t, --syms               Display the contents of the symbol table(s)-T, --dynamic-syms       Display the contents of the dynamic symbol table-r, --reloc              Display the relocation entries in the file-R, --dynamic-reloc      Display the dynamic relocation entries in the file@<file>                  Read options from <file>-v, --version            Display this program's version number-i, --info               List object formats and architectures supported-H, --help               Display this information# objdump -x test| grep NEED

1.3. 调试 bin 报错原因

#  strace -h
usage: strace [-CdffhiqrtttTvVwxxy] [-I n] [-e expr]...[-a column] [-o file] [-s strsize] [-P path]...-p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]or: strace -c[dfw] [-I n] [-e expr]... [-O overhead] [-S sortby]-p pid... / [-D] [-E var=val]... [-u username] PROG [ARGS]Output format:-a column      alignment COLUMN for printing syscall results (default 40)-i             print instruction pointer at time of syscall-k             obtain stack trace between each syscall (experimental)-o file        send trace output to FILE instead of stderr-q             suppress messages about attaching, detaching, etc.-r             print relative timestamp-s strsize     limit length of print strings to STRSIZE chars (default 32)-t             print absolute timestamp-tt            print absolute timestamp with usecs-T             print time spent in each syscall-x             print non-ascii strings in hex-xx            print all strings in hex-y             print paths associated with file descriptor arguments-yy            print protocol specific information associated with socket file descriptorsStatistics:-c             count time, calls, and errors for each syscall and report summary-C             like -c but also print regular output-O overhead    set overhead for tracing syscalls to OVERHEAD usecs-S sortby      sort syscall counts by: time, calls, name, nothing (default time)-w             summarise syscall latency (default is system time)Filtering:-e expr        a qualifying expression: option=[!]all or option=[!]val1[,val2]...options:    trace, abbrev, verbose, raw, signal, read, write, fault-P path        trace accesses to pathTracing:-b execve      detach on execve syscall-D             run tracer process as a detached grandchild, not as parent-f             follow forks-ff            follow forks with output into separate files-I interruptible1:          no signals are blocked2:          fatal signals are blocked while decoding syscall (default)3:          fatal signals are always blocked (default if '-o FILE PROG')4:          fatal signals and SIGTSTP (^Z) are always blocked(useful to make 'strace -o FILE PROG' not stop on ^Z)Startup:-E var         remove var from the environment for command-E var=val     put var=val in the environment for command-p pid         trace process with process id PID, may be repeated-u username    run command as username handling setuid and/or setgidMiscellaneous:-d             enable debug output to stderr-v             verbose mode: print unabbreviated argv, stat, termios, etc. args-h             print help message-V             print version# strace -f ./test    

1.4. 查看 so/bin 中字符串

# strings -h
Usage: strings [option(s)] [file(s)]Display printable strings in [file(s)] (stdin by default)The options are:-a - --all                Scan the entire file, not just the data section [default]-d --data                 Only scan the data sections in the file-f --print-file-name      Print the name of the file before each string-n --bytes=[number]       Locate & print any NUL-terminated sequence of at-<number>                   least [number] characters (default 4).-t --radix={o,d,x}        Print the location of the string in base 8, 10 or 16-w --include-all-whitespace Include all whitespace as valid string characters-o                        An alias for --radix=o-T --target=<BFDNAME>     Specify the binary file format-e --encoding={s,S,b,l,B,L} Select character size and endianness:s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit-s --output-separator=<string> String used to separate strings in output.@<file>                   Read options from <file>-h --help                 Display this information-v -V --version           Print the program's version number
strings: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-bigobj-x86-64 pe-i386 plugin srec symbolsrec verilog tekhex binary ihex
Report bugs to <http://www.sourceware.org/bugzilla/># stirngs -a test.so |grep conf --color
http://www.lryc.cn/news/216990.html

相关文章:

  • CAS 单点登录详解
  • tbh常用的绘图快捷键
  • Android-Framework 清除应用用户数据,不清除权限
  • CS认证办理流程,CS认证好处
  • macOS 安装brew
  • H5: 使用Web Audio API播放音乐
  • Parasoft C/C++test:汽车网络安全ISO 21434最佳实践
  • 如何卸载干净 IDEA(图文讲解)windows和Mac教程
  • Docker搭建Gitlab
  • STM32F4X SDIO(四) SDIO控制器
  • 【flink】Task 故障恢复详解以及各重启策略适用场景说明
  • 一个计算机高手的成长3
  • 2023应届生能力考试含解析(Java后端开发)——(1)
  • Ansible中的任务执行控制
  • 利用maven的dependency插件分析工程的依赖
  • 【广州华锐互动】VR野外求生技能学习,让你感受真实的冒险之旅!
  • k8s、调度约束
  • Redis的介绍,以及Redis的安装(本机windows版,虚拟机Linux版)和Redis常用命令的介绍
  • 电子器件 MOS管的参数、选型与使用技巧
  • EtherCAT主站SOEM -- 2 -- SOEM之ethercatbase.h/c文件解析
  • Spring集成高性能队列Disruptor
  • C++——类和对象(中)完结
  • Sqoop的安装和使用
  • java毕业设计基于springboot+vue的村委会管理系统
  • 【C++】多态 ⑪ ( 纯虚函数和抽象类 | 纯虚函数语法 | 抽象类和实现 | 代码示例 )
  • node 第十四天 基于express的第三方中间件multer node后端处理用户上传文件
  • KnowledgeGPT:利用检索和存储访问知识库上增强大型语言模型10.30
  • Angular material Chips Autocomplete
  • 『亚马逊云科技产品测评』活动征文|搭建基础运维环境
  • 双指针扫描