'主要'在哪里?功能定位?

时间:2017-12-14 17:11:09

标签: c

' main'功能位于?

int main() {
    const char *str = "hello world";
    printf("%s\n", str);
}

我知道这些地点:

  • .text
  • .data
  • .bss
  • stack
  • heap

我认为答案是.bss,因为我知道' main'功能不在其他地方(但我可能是错的)。

1 个答案:

答案 0 :(得分:8)

这显然超出了C标准的范围,因为它没有提及任何"部分"。

ELF系统为例,通常所有代码都在text segment(也称为代码段),componentDidUpdate(){ let context = this; $.getScript(<script source>, function(){ // this is a callback function called upon the script loading is finished }); } 将在文本段中。您可以使用mainreadelf命令查看符号所在的位置。例如,如果您检查objdump的输出,则可以看到汇编和各个部分。

您可以阅读http://wiki.osdev.org/ELFhttp://www.cs.cmu.edu/afs/cs/academic/class/15213-f00/docs/elf.pdf了解更多信息。