如何知道应用程序的启动点

时间:2016-08-10 22:29:09

标签: c linker embedded startup

我正在使用Atmel studio 7.0。

当我尝试使用freeRTOS的代码时,我来到这个函数。

/*
* Low-level initialization routine called during startup, before the main
* function.
* This version comes in replacement to the default one provided by the Newlib
 * add-ons library.
 * Newlib add-ons' _init_startup only calls init_exceptions, but Newlib add-ons'
 * exception vectors are not compatible with the SCALL management in the current
 * FreeRTOS port. More low-level initializations are besides added here.
 */
 int _init_startup(void);
 int _init_startup(void)
 {
   /* Import the Exception Vector Base Address. */
   extern void _evba;

    #if configHEAP_INIT
     extern void __heap_start__;
     extern void __heap_end__;
     portBASE_TYPE *pxMem;
   #endif
   ...

正如您在评论中看到的那样,此函数在main之前被调用,但是我没有调用此函数的函数。

经过一些研究,我说可以在链接器脚本中调用此函数,但事实并非如此,链接器脚本如下所示:

/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-avr32", "elf32-avr32",
      "elf32-avr32")
OUTPUT_ARCH(avr32:uc)
ENTRY(_start)
/* Do we need any of these for elf?
__DYNAMIC = 0;    */ 

我希望在这个文件中找到对_init_startup的调用,但事实并非如此。

总结这里是我的问题:

1-我在哪里可以找到_init_startup

的来电

2-为什么在链接描述文件中我有ENTRY(_start)而不是ENTRY(main)

3-我在哪里可以找到_start

的定义

非常感谢。

1 个答案:

答案 0 :(得分:0)

Didnt与Atmel mcu合作,但我认为它和另一个一样。

1-在哪里可以找到对_init_startup的调用?

  • 你不能,它的绝对地址跳跃。你可以在MCU闪存复位向量中找到它。

2-为什么在链接器脚本中我有ENTRY(_start)而不是ENTRY(main)?

  • 因为代码的第一条指令位于地址_start。 在第一段代码运行之后,它应该有指向main的跳转命令。

3-我在哪里可以找到_start的定义?

  • 它可能是保留的word.try在编译器选项中查找它。