进程地址空间(二)

系统 1662 0
#include   < iostream >
#include   < iomanip >
#include   < stdlib . h >
using   namespace   std;

#define   WIDTH   40

int   BSS_global_uninit_a;
int   BSS_global_uninit_b;

int   static   BSS_global_uninit_static_a;  
int   static   BSS_global_uninit_static_b;

int   DS_global_init_a   =   1 ;
int   DS_global_init_b   =   1 ;

int   DS_global_init_static_a   =   1 ;  
int   DS_global_init_static_b   =   1 ;  

int   const   TEXT_global_init_const_a   =   1 ;
int   const   TEXT_global_init_const_b   =   1 ;

int   const   static   TEXT_global_init_const_static_a   =   1 ;
int   const   static   TEXT_global_init_const_static_b   =   1 ;

void   fun( int   stack_fun_para)
{
    int   stack_fun_a   =   1 ;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &stack_fun_para "   < <   & stack_fun_para   < <   endl;      
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &stack_fun_a "   < <   & stack_fun_a   < <   endl;      
}

int   main()
{
    int   stack_a   =   1 ;
    int   stack_b   =   1 ;
   
    int   static   DS_main_static_a   =   1 ;  
    int   static   DS_main_static_b   =   1 ;

    int   * heap_a   =   ( int * )malloc( 4 );
    int   * heap_b   =   ( int * )malloc( 4 );

    cout   < <   " **********STACK************* "   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &stack_a "   < <   & stack_a   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &stack_b "   < <   & stack_b   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &heap_a "   < <   & heap_a   < <   endl;    
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &heap_b "   < <   & heap_b   < <   endl;    
    fun( 1 );

    cout   < <   " **********HEAP************* "   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " heap_a "   < <   heap_a   < <   endl;    
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " heap_b "   < <   heap_b   < <   endl;    

    cout   < <   " **********BSS************* "   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &BSS_global_uninit_static_a "   < <   & BSS_global_uninit_static_a   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &BSS_global_uninit_static_b "   < <   & BSS_global_uninit_static_b   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &BSS_global_uninit_a "   < <   & BSS_global_uninit_a   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &BSS_global_uninit_b "   < <   & BSS_global_uninit_b < <   endl;          

    cout   < <   " **********DS************* "   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &DS_global_init_a "   < <   & DS_global_init_a < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &DS_global_init_b "   < <   & DS_global_init_b   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &DS_global_init_static_a "   < <   & DS_global_init_static_a   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &DS_global_init_static_b "   < <   & DS_global_init_static_b   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &DS_main_static_a "   < <   & DS_main_static_a   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &DS_main_static_b "   < <   & DS_main_static_b   < <   endl;

    cout   < <   " **********TEXT*********** "   < <   endl;
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &TEXT_global_init_const_a "   < <   & TEXT_global_init_const_a   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &TEXT_global_init_const_b "   < <   & TEXT_global_init_const_b < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &TEXT_global_init_const_static_a "   < <   & TEXT_global_init_const_static_a   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &TEXT_global_init_const_static_b "   < <   & TEXT_global_init_const_static_b   < <   endl;          
    cout   < <   std : : left   < <   setw(WIDTH)   < <   " &string "   < <   & ( " hello " )   < <   endl;

    return   0 ;
}

 

 

 

root@ubuntu:~# ./a.out
**********STACK*************
&stack_a                                0xbfda54ec
&stack_b                                0xbfda54e8
&heap_a                                 0xbfda54e4
&heap_b                                 0xbfda54e0
&stack_fun_para                         0xbfda5470
&stack_fun_a                            0xbfda545c
**********HEAP*************
heap_a                                  0x93ad008
heap_b                                  0x93ad018
**********BSS*************
&BSS_global_uninit_static_a             0x804b100
&BSS_global_uninit_static_b             0x804b104
&BSS_global_uninit_a                    0x804b0f4
&BSS_global_uninit_b                    0x804b0f8
**********DS*************
&DS_global_init_a                       0x804b03c
&DS_global_init_b                       0x804b040
&DS_global_init_static_a                0x804b044
&DS_global_init_static_b                0x804b048
&DS_main_static_a                       0x804b04c
&DS_main_static_b                       0x804b050
**********TEXT***********
&TEXT_global_init_const_a               0x804967c
&TEXT_global_init_const_b               0x8049680
&TEXT_global_init_const_static_a        0x8049684
&TEXT_global_init_const_static_b        0x8049688
&string  


进程地址空间(二)


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论