#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
原文地址:https://www.cnblogs.com/weiyouqing/p/12568398.html
时间: 2024-10-04 04:03:27