binary hacks读数笔记(readelf命令)
可以用readelf命令来查看elf文件内容,跟objdump相比,这个命令更详细。
1、 readelf -h SimpleSection.o
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 45为E 4C为L 46为F
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 1056 (bytes into file) 段表在文件中的偏移
Flags: 0x0
Size of this header: 64 (bytes) 文件头大小
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes) 每个段表结构大小
Number of section headers: 13 段表头数目
Section header string table index: 12
2、readelf -S 查看段表结构
There are 13 section headers, starting at offset 0x420: Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000000000 00000040
0000000000000054 0000000000000000 AX 0 0 1
[ 2] .rela.text RELA 0000000000000000 00000310
0000000000000078 0000000000000018 I 10 1 8
[ 3] .data PROGBITS 0000000000000000 00000094
0000000000000008 0000000000000000 WA 0 0 4
[ 4] .bss NOBITS 0000000000000000 0000009c
0000000000000004 0000000000000000 WA 0 0 4
[ 5] .rodata PROGBITS 0000000000000000 0000009c
0000000000000004 0000000000000000 A 0 0 1
[ 6] .comment PROGBITS 0000000000000000 000000a0
000000000000002e 0000000000000001 MS 0 0 1
[ 7] .note.GNU-stack PROGBITS 0000000000000000 000000ce
0000000000000000 0000000000000000 0 0 1
[ 8] .eh_frame PROGBITS 0000000000000000 000000d0
0000000000000058 0000000000000000 A 0 0 8
[ 9] .rela.eh_frame RELA 0000000000000000 00000388
0000000000000030 0000000000000018 I 10 8 8
[10] .symtab SYMTAB 0000000000000000 00000128
0000000000000180 0000000000000018 11 11 8
[11] .strtab STRTAB 0000000000000000 000002a8
0000000000000066 0000000000000000 0 0 1
[12] .shstrtab STRTAB 0000000000000000 000003b8
0000000000000061 0000000000000000 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),
l (large), p (processor specific)
There are 13 section headers, starting at offset 0x420:
目标文件大小1888字节,段表在0x420开始,每个section header 64 bytes(见头文件)
因而: 0x420 + 64*13(dec)=1056 + 832 =1888正好。
3、查看字符串表与段表字符串表内容
od --skip-bytes 0x000002a8 --read-bytes 0x66 -t x2z SimpleSection.o(参数见2中段表信息 偏移与大小)
0001250 5300 6d69 6c70 5365 6365 6974 6e6f 632e >.SimpleSection.c<
0001270 7300 6174 6974 5f63 6176 2e72 3731 3033 >.static_var.1730<
0001310 7300 6174 6974 5f63 6176 3272 312e 3337 >.static_var2.173<
0001330 0031 6c67 626f 6c61 695f 696e 5f74 6176 >1.global_init_va<
0001350 0072 6c67 626f 6c61 755f 696e 696e 5f74 >r.global_uninit_<
0001370 6176 0072 7566 636e 0031 7270 6e69 6674 >var.func1.printf<
0001410 6d00 6961 006e >.main.<
0001416
4、查看段表字符串表内容
od --skip-bytes 0x000003b8 --read-bytes 0x61 -t x1z SimpleSection.o
0001670 00 2e 73 79 6d 74 61 62 00 2e 73 74 72 74 61 62 >..symtab..strtab<
0001710 00 2e 73 68 73 74 72 74 61 62 00 2e 72 65 6c 61 >..shstrtab..rela<
0001730 2e 74 65 78 74 00 2e 64 61 74 61 00 2e 62 73 73 >.text..data..bss<
0001750 00 2e 72 6f 64 61 74 61 00 2e 63 6f 6d 6d 65 6e >..rodata..commen<
0001770 74 00 2e 6e 6f 74 65 2e 47 4e 55 2d 73 74 61 63 >t..note.GNU-stac<
0002010 6b 00 2e 72 65 6c 61 2e 65 68 5f 66 72 61 6d 65 >k..rela.eh_frame<
0002030 00 >.<
0002031
5、查看符号表信息
readelf -s SimpleSection.c (小 写 s)
Symbol table '.symtab' contains 16 entries:
Num: Value(符号值) Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS SimpleSection.c
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 3
4: 0000000000000000 0 SECTION LOCAL DEFAULT 4
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000004 4 OBJECT LOCAL DEFAULT 3 static_var.1730
7: 0000000000000000 4 OBJECT LOCAL DEFAULT 4 static_var2.1731
8: 0000000000000000 0 SECTION LOCAL DEFAULT 7
9: 0000000000000000 0 SECTION LOCAL DEFAULT 8
10: 0000000000000000 0 SECTION LOCAL DEFAULT 6
11: 0000000000000000 4 OBJECT GLOBAL DEFAULT 3 global_init_var 全局变量,定义在第 3 段 (.data)
12: 0000000000000004 4 OBJECT GLOBAL DEFAULT COM global_uninit_var
13: 0000000000000000 33 FUNC GLOBAL DEFAULT 1 func1
14: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND printf
15: 0000000000000021 51 FUNC GLOBAL DEFAULT 1 main
binary hacks读数笔记(readelf命令)的更多相关文章
- binary hacks读数笔记(readelf基本命令)
一.首先对readelf常用的参数进行简单说明: readelf命令是Linux下的分析ELF文件的命令,这个命令在分析ELF文件格式时非常有用,下面以ELF格式可执行文件test为例详细介绍: 1. ...
- binary hacks读数笔记(objdump命令)
一.首先看一下几个常用参数的基本含义: objdump命令是Linux下的反汇编目标文件或者可执行文件的命令,它还有其他作用,下面以ELF格式可执行文件test为例详细介绍: 1.objdump -f ...
- binary hacks读数笔记(nm命令)
nm命令(names):输出包含三个部分:1 符号值.默认显示十六进制,也可以指定: 2 符号类型.小写表示是本地符号,大写表示全局符号(external); 3 符号名称. 例如:nm Simple ...
- binary hacks读数笔记(od命令)
Linux od命令用于输出文件内容. od指令会读取所给予的文件的内容,并将其内容以八进制字码呈现出来 -t<输出格式>或--format=<输出格式> 设置输出格式. 实例 ...
- binary hacks读数笔记(file命令与magic file)
file命令的作用是用于检验文件的类型,并打印至终端.file命令检验文件类型按以下顺序来完成: 检验文件系统(Filesystem)中支持的文件类型. 检验magic file规则. 检验文件内容的 ...
- binary hacks读数笔记(装载)
1.地址空间 在linux系统中,每个进程拥有自己独立的虚拟地址空间,这个虚拟地址空间的大小是由计算机硬件决定的,具体地说,是由CPU的位数决定的.比如,32位硬件平台决定的虚拟地址空间大小:0--2 ...
- binary hacks读数笔记(ld 链接讲解 二)
这块将介绍一下ld链接命令的具体使用.ld的作用:ld是GNU binutils工具集中的一个,是众多Linkers(链接器)的一种.完成的功能自然也就是链接器的基本功能:把各种目标文件和库文件链接起 ...
- binary hacks读数笔记(ld 链接讲解 一)
首先我们先看两段代码: a.c extern int shared; int main(){ int a=100; swap(&a,&shared); } b.c int shared ...
- binary hacks读数笔记(堆、栈 VMA的分布)
一.首先看一个简单的程序: #include<stdlib.h> int main() { while(1) { sleep(1000); } return 0; } gcc -stati ...
随机推荐
- 极简 Node.js 入门 - 5.2 url & querystring
极简 Node.js 入门系列教程:https://www.yuque.com/sunluyong/node 本文更佳阅读体验:https://www.yuque.com/sunluyong/node ...
- centos8平台给sudo配置日志
一,sudo日志的用途: 我们可以记录下来用户账号在哪个时间进行过sudo 这样不需要再从secure日志中查找用户的sudo记录 说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://w ...
- shell脚本在后台运行以及日志重定向输出
后台运行命令 在命令行后加上 &,表示进程到后台中执行,如:cmd & 日志输出重定向 如:cmd > out.log & Linux默认定义两个变量:1和2: 1 表示 ...
- dubbo-config-spring自定义xml标签扩展
要实现自定义自定义标签扩展,需要有如下步骤(在spring中定义了两个接口NamespaceHandler.BeanDefinitionParser,用来实现扩展) 1.设计配置属性和JavaBean ...
- 3分钟学完Python,直接从入门到精通
作为帅气小编,我已经把python一些模块的甩在这儿了qwq,只要你拿到这些干货,包你玩转python,直接冲向"大佬"的段位,如果已经学了C或者C++或者说如果你需要你的一段关键 ...
- drf (学习第二部)
目录 http球球处理 请求与响应 Response 常用属性 状态码 http请求处理 drf除了在数据序列化部分简写代码之外,还在视图中提供了简写操作.所以在Django原有的Django.vie ...
- 利用ADB命令强制卸载oppo自带浏览器
前言 oppo手机是自带oppo浏览器的,这个自带的浏览器带有oppo推荐的负面新闻很多,而且有时也自动推送一些消息给用户,页面不够简洁,打开浏览器负面内容比较多,所以想要强制卸载oppo浏览器,然后 ...
- ES2020链判断运算符?.和Null判断运算符??
链判断运算符 ?. 业务场景: 1 // 假设data是个数组,如果data没有值,为undefinded,则直接复制会报错,因为没有length这个属性 2 3 const dateCount = ...
- E. Almost Regular Bracket Sequence 解析(思維)
Codeforce 1095 E. Almost Regular Bracket Sequence 解析(思維) 今天我們來看看CF1095E 題目連結 題目 給你一個括號序列,求有幾個字元改括號方向 ...
- selenium中如何保证操作元素的成功率?也就是说如何保证我点击的元素一定是可以点击的?
1.在寻找元素时,加上显示等待或者隐式等待,这样在对元素进行操作之前保证元素被找到,进而提高成功率: 2.在对元素操作之前,比如click,如果该元素未display(非hidden),就需要先滚动到 ...