免费教程_免费网赚教程_破解版软件-寂涯网络学习基地

当前位置: 主页 > 系统综合 > 各类编程 > 深入跟踪 Hello World 执行(9)

深入跟踪 Hello World 执行(9)

时间:2012-04-08 14:21来源:未知 整理:寂涯网络 点击:


230 # endif
231
232       /** One less thread.    Decrement the counter.    If it is zero we
233       terminate the entire process.      */
234       result = 0;
235 # ifdef SHARED
236        unsigned int *ptr =  libc_pthread_functions.ptr_nthreads;
237        PTR_DEMANGLE (ptr);
238 # else
239        extern unsigned int  nptl_nthreads  attribute ((weak));
240        unsigned int *const ptr = &  nptl_nthreads;
241 # endif
242
243        if (! atomic_decrement_and_test (ptr))
244     /** Not much left to do but to exit the thread, not the process.          */
245
246     }
247 #else

exit_thread (0);
248   /** Nothing fancy, just call the function.       */
249    result = main (argc, argv,  environ MAIN_AUXVEC_PARAM);
250 #endif
251
252   exit (result);
253 }
多个输入参数,然后开始对程序进行初始化工作,如初始化线程、安装 SSP 防护、注册
析构函数等,包括对程序结束的撤销系统资源等等。那么现在我们可以解答文件开始的问题,
main 是从__libc_satart_main 函数调用的。
我们看到 libc_start_main 传入了 7 个参数,其中有 init 和 finit,在 IDA 反汇编时
时 libc_csu_init 和__libc_csu_finit.这两个函数一个是函数开始处理和一个是函数退
出处理,就是在 main 前后,我们可以看一下这两个函数都作了什么,首先我们看一下
  libc_csu_init IDA 反汇编;
.text:08048400
.text:08048400 ; Attributes: bp-based frame
.text:08048400
.text:08048400                  public  libc_csu_init
.text:08048400  libc_csu_init proc near                  ; DATA XREF: _start+10 o
.text:08048400
.text:08048400 arg_0            = dword ptr   8
.text:08048400 arg_4             = dword ptr    0Ch
.text:08048400 arg_8             = dword ptr    10h
.text:08048400
.text:08048400                  push     ebp
.text:08048401                  mov      ebp, esp
.text:08048403                  push     edi
.text:08048404                  push     esi
.text:08048405                  push     ebx
.text:08048406                  call

  i686_get_pc_thunk_bx
.text:0804840B                  add      ebx, 1BE9h
.text:08048411                  sub      esp, 0Ch
.text:08048414                  call     _init_proc
.text:08048419                  lea      edi, (__CTOR_LIST   - 8049FF4h)[ebx]
.text:0804841F                  lea      eax, (__CTOR_LIST   - 8049FF4h)[ebx]
.text:08048425                  sub      edi, eax
 
.text:08048427
   
sar
 
edi, 2
.text:0804842A   test edi, edi
.text:0804842C   jz short loc_8048452
.text:0804842E   xor esi, esi
.text:08048430      
.text:08048430 loc_8048430:    
  libc_csu_init+50 j    
.text:08048430   mov eax, [ebp+arg_8]
.text:08048433   mov [esp+8], eax
.text:08048437   mov eax, [ebp+arg_4]
.text:0804843A   mov [esp+4], eax
.text:0804843E   mov eax, [ebp+arg_0]
         
 

本页地址 http://www.jybase.net/biancheng/20120408819.html

百度搜索更多

谷歌搜索更多

顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------

评价:
昵称: 验证码:点击我更换图片
推荐内容
赞助商
赞助商


关于本站免责声明视频更新google百度地图视频地图RRS订阅

如有什么问题请在本站留言,或发邮件到 hxt167#foxmail.com