《coredump问题原理探究》Linux x86版7.6节 Map coredump例子

定位一个map相关的coredump来熟悉一下:

Core was generated by `./xuzhina_dump_c07_s3_ex 5 / 6'.Program terminated with signal 11, Segmentation fault.#0 0x00000000 in ?? ()Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.149.el6_6.4.i686 libgcc-4.4.7-11.el6.i686 libstdc++-4.4.7-11.el6.i686(gdb) bt#0 0x00000000 in ?? ()#1 0x08048bd0 in main ()(gdb) i r eax0x55ecx0x00edx0x00ebx0x66esp0xbfd3de7c0xbfd3de7cebp0xbfd3dee80xbfd3dee8esi0x00edi0x00eip0x00eflags0x210296[ PF AF SF IF RF ID ]cs0x73115ss0x7b123ds0x7b123es0x7b123fs0x00gs0x3351

由于栈顶的指令地址为0x0,而eip的值也是0x0,可以知道是调用了函数指针,且函数指针的值为空.而这个函数指针是由main函数调用

看一下main函数的汇编:

(gdb) disassemble Dump of assembler code for function main: 0x0804898f <+0>:push %ebp 0x08048990 <+1>:mov %esp,%ebp 0x08048992 <+3>:and $0xfffffff0,%esp 0x08048995 <+6>:push %esi 0x08048996 <+7>:push %ebx 0x08048997 <+8>:sub $0x58,%esp 0x0804899a <+11>:cmpl $0x3,0x8(%ebp) 0x0804899e <+15>:jg0x80489b6 <main+39> 0x080489a0 <+17>:movl $0x8049ce4,(%esp) 0x080489a7 <+24>:call 0x804883c <puts@plt> 0x080489ac <+29>:mov $0xffffffff,%ebx 0x080489b1 <+34>:jmp 0x8048c42 <main+691> 0x080489b6 <+39>:lea 0x18(%esp),%eax 0x080489ba <+43>:mov %eax,(%esp) 0x080489bd <+46>:call 0x8048c6e <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEEC2Ev> 0x080489c2 <+51>:lea 0x37(%esp),%eax 0x080489c6 <+55>:mov %eax,(%esp) 0x080489c9 <+58>:call 0x804887c <_ZNSaIcEC1Ev@plt> 0x080489ce <+63>:lea 0x37(%esp),%eax 0x080489d2 <+67>:mov %eax,0x8(%esp) 0x080489d6 <+71>:movl $0x8049cfa,0x4(%esp)—Type <return> to continue, or q <return> to quit— 0x080489de <+79>:lea 0x30(%esp),%eax 0x080489e2 <+83>:mov %eax,(%esp) 0x080489e5 <+86>:call 0x80487ec <_ZNSsC1EPKcRKSaIcE@plt> 0x080489ea <+91>:lea 0x30(%esp),%eax 0x080489ee <+95>:mov %eax,0x4(%esp) 0x080489f2 <+99>:lea 0x18(%esp),%eax 0x080489f6 <+103>:mov %eax,(%esp) 0x080489f9 <+106>:call 0x8048cfc <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEEixERS5_> 0x080489fe <+111>:movl $0x8048964,(%eax) 0x08048a04 <+117>:lea 0x30(%esp),%eax 0x08048a08 <+121>:mov %eax,(%esp) 0x08048a0b <+124>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048a10 <+129>:jmp 0x8048a41 <main+178> 0x08048a12 <+131>:mov %edx,%ebx 0x08048a14 <+133>:mov %eax,%esi 0x08048a16 <+135>:lea 0x30(%esp),%eax 0x08048a1a <+139>:mov %eax,(%esp) 0x08048a1d <+142>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048a22 <+147>:mov %esi,%eax 0x08048a24 <+149>:mov %ebx,%edx 0x08048a26 <+151>:jmp 0x8048a28 <main+153> 0x08048a28 <+153>:mov %edx,%ebx—Type <return> to continue, or q <return> to quit— 0x08048a2a <+155>:mov %eax,%esi 0x08048a2c <+157>:lea 0x37(%esp),%eax 0x08048a30 <+161>:mov %eax,(%esp) 0x08048a33 <+164>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048a38 <+169>:mov %esi,%eax 0x08048a3a <+171>:mov %ebx,%edx 0x08048a3c <+173>:jmp 0x8048c26 <main+663> 0x08048a41 <+178>:lea 0x37(%esp),%eax 0x08048a45 <+182>:mov %eax,(%esp) 0x08048a48 <+185>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048a4d <+190>:lea 0x3f(%esp),%eax 0x08048a51 <+194>:mov %eax,(%esp) 0x08048a54 <+197>:call 0x804887c <_ZNSaIcEC1Ev@plt> 0x08048a59 <+202>:lea 0x3f(%esp),%eax 0x08048a5d <+206>:mov %eax,0x8(%esp) 0x08048a61 <+210>:movl $0x8049cfc,0x4(%esp) 0x08048a69 <+218>:lea 0x38(%esp),%eax 0x08048a6d <+222>:mov %eax,(%esp) 0x08048a70 <+225>:call 0x80487ec <_ZNSsC1EPKcRKSaIcE@plt> 0x08048a75 <+230>:lea 0x38(%esp),%eax 0x08048a79 <+234>:mov %eax,0x4(%esp) 0x08048a7d <+238>:lea 0x18(%esp),%eax 0x08048a81 <+242>:mov %eax,(%esp)—Type <return> to continue, or q <return> to quit— 0x08048a84 <+245>:call 0x8048cfc <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEEixERS5_> 0x08048a89 <+250>:movl $0x8048972,(%eax) 0x08048a8f <+256>:lea 0x38(%esp),%eax 0x08048a93 <+260>:mov %eax,(%esp) 0x08048a96 <+263>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048a9b <+268>:jmp 0x8048acc <main+317> 0x08048a9d <+270>:mov %edx,%ebx 0x08048a9f <+272>:mov %eax,%esi 0x08048aa1 <+274>:lea 0x38(%esp),%eax 0x08048aa5 <+278>:mov %eax,(%esp) 0x08048aa8 <+281>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048aad <+286>:mov %esi,%eax 0x08048aaf <+288>:mov %ebx,%edx 0x08048ab1 <+290>:jmp 0x8048ab3 <main+292> 0x08048ab3 <+292>:mov %edx,%ebx 0x08048ab5 <+294>:mov %eax,%esi 0x08048ab7 <+296>:lea 0x3f(%esp),%eax 0x08048abb <+300>:mov %eax,(%esp) 0x08048abe <+303>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048ac3 <+308>:mov %esi,%eax 0x08048ac5 <+310>:mov %ebx,%edx 0x08048ac7 <+312>:jmp 0x8048c26 <main+663>—Type <return> to continue, or q <return> to quit— 0x08048acc <+317>:lea 0x3f(%esp),%eax 0x08048ad0 <+321>:mov %eax,(%esp) 0x08048ad3 <+324>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048ad8 <+329>:lea 0x47(%esp),%eax 0x08048adc <+333>:mov %eax,(%esp) 0x08048adf <+336>:call 0x804887c <_ZNSaIcEC1Ev@plt> 0x08048ae4 <+341>:lea 0x47(%esp),%eax 0x08048ae8 <+345>:mov %eax,0x8(%esp) 0x08048aec <+349>:movl $0x8049cfe,0x4(%esp) 0x08048af4 <+357>:lea 0x40(%esp),%eax 0x08048af8 <+361>:mov %eax,(%esp) 0x08048afb <+364>:call 0x80487ec <_ZNSsC1EPKcRKSaIcE@plt> 0x08048b00 <+369>:lea 0x40(%esp),%eax 0x08048b04 <+373>:mov %eax,0x4(%esp) 0x08048b08 <+377>:lea 0x18(%esp),%eax 0x08048b0c <+381>:mov %eax,(%esp) 0x08048b0f <+384>:call 0x8048cfc <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEEixERS5_> 0x08048b14 <+389>:movl $0x8048983,(%eax) 0x08048b1a <+395>:lea 0x40(%esp),%eax 0x08048b1e <+399>:mov %eax,(%esp) 0x08048b21 <+402>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048b26 <+407>:jmp 0x8048b57 <main+456>—Type <return> to continue, or q <return> to quit— 0x08048b28 <+409>:mov %edx,%ebx 0x08048b2a <+411>:mov %eax,%esi 0x08048b2c <+413>:lea 0x40(%esp),%eax 0x08048b30 <+417>:mov %eax,(%esp) 0x08048b33 <+420>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048b38 <+425>:mov %esi,%eax 0x08048b3a <+427>:mov %ebx,%edx 0x08048b3c <+429>:jmp 0x8048b3e <main+431> 0x08048b3e <+431>:mov %edx,%ebx 0x08048b40 <+433>:mov %eax,%esi 0x08048b42 <+435>:lea 0x47(%esp),%eax 0x08048b46 <+439>:mov %eax,(%esp) 0x08048b49 <+442>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048b4e <+447>:mov %esi,%eax 0x08048b50 <+449>:mov %ebx,%edx 0x08048b52 <+451>:jmp 0x8048c26 <main+663> 0x08048b57 <+456>:lea 0x47(%esp),%eax 0x08048b5b <+460>:mov %eax,(%esp) 0x08048b5e <+463>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048b63 <+468>:lea 0x4f(%esp),%eax 0x08048b67 <+472>:mov %eax,(%esp) 0x08048b6a <+475>:call 0x804887c <_ZNSaIcEC1Ev@plt> 0x08048b6f <+480>:mov 0xc(%ebp),%eax—Type <return> to continue, or q <return> to quit— 0x08048b72 <+483>:add $0x8,%eax 0x08048b75 <+486>:mov (%eax),%eax 0x08048b77 <+488>:lea 0x4f(%esp),%edx 0x08048b7b <+492>:mov %edx,0x8(%esp) 0x08048b7f <+496>:mov %eax,0x4(%esp) 0x08048b83 <+500>:lea 0x48(%esp),%eax 0x08048b87 <+504>:mov %eax,(%esp) 0x08048b8a <+507>:call 0x80487ec <_ZNSsC1EPKcRKSaIcE@plt> 0x08048b8f <+512>:lea 0x48(%esp),%eax 0x08048b93 <+516>:mov %eax,0x4(%esp) 0x08048b97 <+520>:lea 0x18(%esp),%eax 0x08048b9b <+524>:mov %eax,(%esp) 0x08048b9e <+527>:call 0x8048cfc <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEEixERS5_> 0x08048ba3 <+532>:mov (%eax),%esi 0x08048ba5 <+534>:mov 0xc(%ebp),%eax 0x08048ba8 <+537>:add $0xc,%eax 0x08048bab <+540>:mov (%eax),%eax 0x08048bad <+542>:mov %eax,(%esp) 0x08048bb0 <+545>:call 0x80487fc <atoi@plt> 0x08048bb5 <+550>:mov %eax,%ebx 0x08048bb7 <+552>:mov 0xc(%ebp),%eax 0x08048bba <+555>:add $0x4,%eax—Type <return> to continue, or q <return> to quit— 0x08048bbd <+558>:mov (%eax),%eax 0x08048bbf <+560>:mov %eax,(%esp) 0x08048bc2 <+563>:call 0x80487fc <atoi@plt> 0x08048bc7 <+568>:mov %ebx,0x4(%esp) 0x08048bcb <+572>:mov %eax,(%esp) 0x08048bce <+575>:call *%esi=> 0x08048bd0 <+577>:mov %eax,%ebx 0x08048bd2 <+579>:lea 0x48(%esp),%eax 0x08048bd6 <+583>:mov %eax,(%esp) 0x08048bd9 <+586>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048bde <+591>:jmp 0x8048c0c <main+637> 0x08048be0 <+593>:mov %edx,%ebx 0x08048be2 <+595>:mov %eax,%esi 0x08048be4 <+597>:lea 0x48(%esp),%eax 0x08048be8 <+601>:mov %eax,(%esp) 0x08048beb <+604>:call 0x80487cc <_ZNSsD1Ev@plt> 0x08048bf0 <+609>:mov %esi,%eax 0x08048bf2 <+611>:mov %ebx,%edx 0x08048bf4 <+613>:jmp 0x8048bf6 <main+615> 0x08048bf6 <+615>:mov %edx,%ebx 0x08048bf8 <+617>:mov %eax,%esi 0x08048bfa <+619>:lea 0x4f(%esp),%eax 0x08048bfe <+623>:mov %eax,(%esp) 0x08048c01 <+626>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048c06 <+631>:mov %esi,%eax 0x08048c08 <+633>:mov %ebx,%edx 0x08048c0a <+635>:jmp 0x8048c26 <main+663> 0x08048c0c <+637>:lea 0x4f(%esp),%eax 0x08048c10 <+641>:mov %eax,(%esp) 0x08048c13 <+644>:call 0x804882c <_ZNSaIcED1Ev@plt> 0x08048c18 <+649>:lea 0x18(%esp),%eax 0x08048c1c <+653>:mov %eax,(%esp) 0x08048c1f <+656>:call 0x8048c5a <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEED2Ev> 0x08048c24 <+661>:jmp 0x8048c42 <main+691> 0x08048c26 <+663>:mov %edx,%ebx 0x08048c28 <+665>:mov %eax,%esi 0x08048c2a <+667>:lea 0x18(%esp),%eax 0x08048c2e <+671>:mov %eax,(%esp) 0x08048c31 <+674>:call 0x8048c5a <_ZNSt3mapISsPFiiiESt4lessISsESaISt4pairIKSsS1_EEED2Ev> 0x08048c36 <+679>:mov %esi,%eax 0x08048c38 <+681>:mov %ebx,%edx 0x08048c3a <+683>:mov %eax,(%esp) 0x08048c3d <+686>:call 0x804889c <_Unwind_Resume@plt> 0x08048c42 <+691>:mov %ebx,%eax 0x08048c44 <+693>:add $0x58,%esp 0x08048c47 <+696>:pop %ebx 0x08048c48 <+697>:pop %esi 0x08048c49 <+698>:mov %ebp,%esp 0x08048c4b <+700>:pop %ebp 0x08048c4c <+701>:retEnd of assembler dump.

出现coredump可能是因为这一条指令

0x08048bce <+575>:call *%esi

看一下esi的值:

(gdb) i r esiesi0x00

可见esi为0,确实是由于那一条指令引起的.

没有什么可凭仗,只有他的好身体,没有地方可去,

《coredump问题原理探究》Linux x86版7.6节 Map coredump例子

相关文章:

你感兴趣的文章:

标签云: