3

源 C 代码:

static int b;

目标文件中对应的.bss段反汇编代码:

Disassembly of section .bss:

00000000 <b>:
   0:   00 00                   add    %al,(%eax)
   2:   00 00                   add    %al,(%eax)

基于节标题的信息:

  3 .bss          00000004  00000000  00000000  00000068  2**2
                  ALLOC

很明显,.bss 存在并占用了一定的空间(与 hex dump 匹配)!

我想问两件事,

1.当我使用 readelf 转储 .bss 部分时:

readelf -x .bss section_test.o
Section '.bss' has no data to dump.

我只是不明白。它肯定有一些数据,对吧?

2.如何理解.bss部分的那些代码?我的意思是,我完全将它们单独理解为装配体,但我只是对它们为什么在这里感到有点困惑?

谢谢。

额外信息:MacOS 使用 Docker(Ubuntu)、AT&T 语法、x86_64 Arch(物理),但在编译和链接阶段使用 elf_i386(32 位)arch。

4

0 回答 0