相关疑难解决方法(0)

为什么GCC编译C程序需要.eh_frame部分?

测试在32位x86 Linux和gcc4.6.3上进行

gcc用于编译C程序并使用readelf检查部分信息时,我可以看到里面的.eh_frame部分和.eh_frame_hdr部分.

例如,这是二进制程序的部分信息Perlbench.

readelf -S perlbench

There are 28 section headers, starting at offset 0x102e48:

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        08048154 000154 000013 00   A  0   0  1
[ 2] .note.ABI-tag     NOTE            08048168 000168 000020 00   A  0   0  4
[ 3] .note.gnu.build-i …
Run Code Online (Sandbox Code Playgroud)

c x86 assembly exception-handling elf

37
推荐指数
1
解决办法
2万
查看次数

帮助理解GDB中一个非常基本的main()反汇编

Heyo,

我已经编写了这个非常基本的主要功能来试验反汇编,还可以看到并希望了解更低层次的情况:

int main() {
  return 6;
}
Run Code Online (Sandbox Code Playgroud)

使用gdb来disas main产生这个:

0x08048374 <main+0>:    lea    0x4(%esp),%ecx
0x08048378 <main+4>:    and    $0xfffffff0,%esp
0x0804837b <main+7>:    pushl  -0x4(%ecx)
0x0804837e <main+10>:   push   %ebp
0x0804837f <main+11>:   mov    %esp,%ebp
0x08048381 <main+13>:   push   %ecx
0x08048382 <main+14>:   mov    $0x6,%eax
0x08048387 <main+19>:   pop    %ecx
0x08048388 <main+20>:   pop    %ebp
0x08048389 <main+21>:   lea    -0x4(%ecx),%esp
0x0804838c <main+24>:   ret  
Run Code Online (Sandbox Code Playgroud)

这是我最好的猜测,我认为正在发生什么以及我需要逐行帮助:

lea 0x4(%esp),%ecx

将esp + 4的地址加载到ecx中.为什么我们为esp添加4?

我在某处读到这是命令行参数的地址.但是当我这样做时,x/d $ecx我得到了argc的值.存储的实际命令行参数值在哪里?

and $0xfffffff0,%esp

对齐堆栈

pushl -0x4(%ecx)

将esp最初的地址推入堆栈.这样做的目的是什么?

push %ebp

将基指针推入堆栈

mov %esp,%ebp

将当前堆栈指针移动到基指针中

push %ecx …

linux x86 assembly gdb disassembly

12
推荐指数
1
解决办法
5219
查看次数

标签 统计

assembly ×2

x86 ×2

c ×1

disassembly ×1

elf ×1

exception-handling ×1

gdb ×1

linux ×1