zoukankan      html  css  js  c++  java
  • C之bss、data存储位置区分,使用objdump -t反汇编查看变量所处存储位置

    #include <stdio.h>
    #include <stdlib.h>
    
    int wei;               //未初始化的全局变量,bss区
    int you = 0;            //初始化为0的全局变量,bss区
    int qing = 1;            //初始化非0的全局变量,data区
    int main()
    {    
        static int ai;         //未初始化的静态局部变量,bss区
        static int ni = 0;      //初始化为0的静态局部变量,bss区
        static int everyday = 2;   //初始化为非0的静态局部变量,data区
        int forever;          //栈(stacks)
        
        return 0;
    }
    将main.c编译为汇编语言:gcc main.c -o main.o 

    objdump -t main.o | grep ".data"
    0000000000600800 l d .data 0000000000000000 .data 0000000000600808 l O .data 0000000000000004 everyday.2553 0000000000600800 w .data 0000000000000000 data_start 0000000000600800 g .data 0000000000000000 __data_start 0000000000600804 g O .data 0000000000000004 qing
    objdump -t main.o | grep ".bss" 
    0000000000600810 l    d  .bss   0000000000000000              .bss
    0000000000600810 l     O .bss   0000000000000001              completed.6364
    0000000000600818 l     O .bss   0000000000000008              dtor_idx.6366
    0000000000600824 l     O .bss   0000000000000004              ni.2552
    0000000000600828 l     O .bss   0000000000000004              ai.2551
    0000000000600820 g     O .bss   0000000000000004              you
    000000000060082c g     O .bss   0000000000000004              wei
  • 相关阅读:
    Kivy Event 在哪里?
    kivy file import
    spark windows环境下spark安装和运行(2)
    spark windows环境下spark安装和运行(1)
    Spring Boot配置多个DataSource
    java jdbc 元数据使用
    asp.net core 3.x 授权默认流程
    asp.net core 3.x 授权中的概念
    IdentityServer4 源码分析
    rabbitmq 安装问题
  • 原文地址:https://www.cnblogs.com/weiyouqing/p/12568398.html
Copyright © 2011-2022 走看看