進程的記憶體位址

來源:互聯網
上載者:User

/* * 進程地址空間 驗證 * * bss: block started by symbol 存放程式中未初始化的全域變數 * data segment: 資料區段,存放已初始化的全域變數 * code segment: 程式碼片段,存放程式執行代碼的一塊記憶體地區 * heap: 堆,存放動態分配的記憶體段,大小不固定,動態擴張或縮減 * stack: 棧,存放局部變數 */int g_u_a1;int g_a2 = 1;static int g_s_u_b1;static int g_s_b2 = 1;int main(){    static int s_u_c1;    static int s_c2 = 1;    int u_d1;    int d2 = 1;    printf("global uninit addr: %x, init addr: %x\n", &g_u_a1, &g_a2);    printf("global uninit static addr: %x, init static addr: %x\n", &g_s_u_b1, &g_s_b2);    printf("local uninit static addr: %x, init static addr: %x\n", &s_u_c1, &s_c2);    printf("local uninit addr: %x, init addr: %x\n", &u_d1, &d2);    return 0;}

output:

global uninit addr: 804a030, init addr: 804a014global uninit static addr: 804a028, init static addr: 804a018local uninit static addr: 804a02c, init static addr: 804a01clocal uninit addr: bfa3815c, init addr: bfa38158

未初始化全域static,未初始化區部static 變數在bss中

初始化全域static,初始化區部static 變數在資料區段中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.