1,测试代码
#include<stdio.h>
int fun()
{
int* ptr = NULL;
*ptr = 0x100;
int num = *ptr;
return num;
}
编译
lark@ubuntu:~/test1/1_backtrace$ gcc fun.c -g -fpic -shared -o libfun.so
1,反汇编查看问题
objdump -d libfun.so
libfun.so: file format elf32-i386
Disassembly of section .init:
000002dc <_init>:
2dc: 53 push %ebx
2dd: 83 ec 08 sub $0x8,%esp
2e0: e8 3b 00 00 00 call 320 <__x86.get_pc_thunk.bx>
2e5: 81 c3 1b 1d 00 00 add $0x1d1b,%ebx
2eb: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax
2f1: 85 c0 test %eax,%eax
2f3: 74 05 je 2fa <_init+0x1e>
2f5: e8 1e 00 00 00 call 318 <_init+0x3c>
2fa: 83 c4 08 add $0x8,%esp
2fd: 5b pop %ebx
2fe: c3 ret
Disassembly of section .plt:
00000300