该篇为Linux命令的续篇,上一篇更贴近于日常的操作,该篇所列命令更贴近于我们开发过程中的应用。
使用strace+可执行程序:
strace - tracesystem calls and signals
strace hello.exe跟踪该可执行文件
使用网络文件系统启动你的下位机系统,需要在上位机的操作:
service iptablesstop(关闭系统防火墙)
service portmapstart
service nfsstart
wc - printnewline,word,and byte counts for each FILE, and a total line if more than oneFILE is specified.Whith no FILE, or when FILE is -,read standard input.
例wc file0
87 241 1885file0
(放在昨天的内容中更好的)
信號捕捉:
trap"cmds" signal-list
man 7 signal可以查看signals
如trap "echo hello" 2 3 14
trap signal-list接受信号的默认操作
trap "" signal-list 忽视这一信号
对信号11(段违例)不能捕捉,因为shell本身需要捕捉该信号去进行内存的转储
ldd命令查看动态库加载情况ldd hello.exe
mknod 命令建立一个目录项和一个特殊文件的对应索引节点。
b标志表示这个特殊文件是面向块的设备(磁盘、软盘或磁带),c标志表示这个特殊文件是面向字符的设备(其他设备)。
mknod - makeblock or character special files.
lsmod - programto show the status of modules in the linux kernel
insmod: errorinserting 'xxx.ko': -1 Device or resource busy
出现这个原因是定义的设备号有冲突,可以通过 cat /proc/devices 查看有哪些设备号还没被使用。或者直接由系统分配。
在编写好驱动后,用insmod注册到内核中,并存储于/proc/devices中。这时/dev下还没有这个设备文件。需要用mknod创建一个设备节点。
rmmod – simpleprogram to remove a module from the Linux Kernel.
(arm-linux-)objdump- display information from object files.
-d -disassemble
将a.elf 文件反汇编为a.txt文件
(arm-elf-)objdump-d a.elf > a.txt
readelf - displayinformation about the contents of ELF format files
(arm-linux-)readelf-a ./a.out | grep "Shared" 查看执行文件所依赖的共享库。
od - dump filesin octal and other formats.
使用od -c xxx.c > file
od - octal dump.可以以十进制,八进制,十六进制和ASCII码来显示文本或者流,默认使用八进制。对于访问或可视的检查文件中不能直接显示在终端上的字符很有用。
(arm-linux-)size -- list section sizes andtotal size. 显示二进制文件中节的大小,默认输入文件为a.out
(arm-linux-)nm-- list symbols from object files.
GNU nm lists thesymbols from object files...If no object files are listed as arguments, nmassumes the file a.out.
nm -D/lib/libc.so.6 | grep log 显示log相关的动态符号,-D选项仅对于动态目标,如特定类型的共享库有意义。
strip - discardsymbols from object files.
(arm-linux-)strip去掉其中的调试信息,执行文件也将小很多。
(arm-elf-)objcopy代码转换工具,可以将elf文件转变成hex或bin文件。
(arm-elf-)objcopy-O binary a.out a.bin,将a.out转换成a.bin
(arm-elf-)objcopy-I binary -O ihex a.bin a.hex将a.bin转换成a.hex