4

我正在浏览 Linux 内核源代码,并在其中一个程序集文件中找到了 _bss_start C 变量,但找不到实际定义和初始化的位置。

看起来 _bss_start 是 bss 段的起始地址,但是它在哪里以及如何使用内核源代码中的值进行初始化,我正在研究 linux 源代码 2.6.25。

我查看了文件 asm-generic/section.h,它的定义如下

 extern char _bss_start[]

但是 _bss_start 是如何定义的,是否使用 DS 寄存器对其进行初始化

4

1 回答 1

7

__bss_start由链接器定义和初始化。它引用图像的.bss 部分,其中包含静态分配的变量。

这是定义这些符号的链接描述文件的精简示例:

.bss : {
    __bss_start = .;      /*< __bss_start references this position in the file */
    *(.bss)               /*< The actual contents of the section */
    *(COMMON)             /*< The actual contents of the section */
    _ebss = . ;           /*< _ebss references this position in the file */
}
于 2013-07-08T13:46:31.973 回答