为什么我的arm-none-eabi输出为空?

时间:2015-02-08 23:18:57

标签: gcc arm codeblocks elf stm32

我正在尝试使用arm-none-eabi-gcc 2014 Q3编译和链接STM32F030F4的代码:

arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.4 20140725 (release) [ARM/embedded-4_8-branch revision 213147]

代码由STM32CubeMX 4.6.0生成,并导入Code :: Blocks项目。这是一个示例编译器命令:

arm-none-eabi-gcc -mthumb -mlittle-endian -Wall -mcpu=cortex-m0 -ffunction-sections -fdata-sections -fno-exceptions --specs=rdimon.specs -DSTM32F030x6 -g -I../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../Drivers/CMSIS/Include -I../Drivers/STM32F0xx_HAL_Driver/Inc -I../Inc -c ../Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.c -o obj/Debug/Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.o

-DSTM32F030x6没问题,因为它也用于STM32F0F4设备。所有其他源文件都使用相同的标志进行编译。 arm-none-eabi-size报告system_stm32f0xx.o的大小为非零,因此可以找到一些内容。

这是链接器命令,省略了许多obj文件但包含了所有标志:

arm-none-eabi-g++ -L"../TrueSTUDIO/test Configuration" -o bin/Debug/test.elf
obj/Debug/Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc/startup_stm32f030x6.o
obj/Debug/Drivers/CMSIS/Device/ST/STM32F0xx/Source/Templates/system_stm32f0xx.o
...
<many other object files ommitted>
...
-TSTM32F030F4_FLASH.ld -mcpu=cortex-m0 -mthumb -Wl,--gc-sections  -lrdimon

编译器和链接器都不报告任何错误。 确实生成了请求的elf文件,但报告为空:

arm-none-eabi-size bin/Debug/test.elf
   text    data     bss     dec     hex filename
      0       0       0       0       0 bin/Debug/test.elf

我不知道为什么,因为我的main确实做了一些事情:

int main(void)
{
  HAL_Init();
  SystemClock_Config();
  GPIO_InitTypeDef init;
  init.Mode = GPIO_MODE_OUTPUT_PP;
  init.Pin = GPIO_PIN_1;
  HAL_GPIO_Init(GPIOB, &init);
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);

  while (1)
  {

  }

}

在这里找到一个空精灵的原因是什么?我已成功将此工具链用于STM32F4项目。我第一次使用了cortex-M0,所以我可能会错过一些重要的旗帜,或者包括一个“破坏性的旗帜”。


根据要求:链接描述文件

ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = 0x20000FFF;    /* end of RAM */

/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200;      /* required amount of heap  */
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 16K
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 4K
}

/* Define output sections */
SECTIONS
{
  /* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

  /* The program code and other data goes into FLASH */
  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)

    KEEP (*(.init))
    KEEP (*(.fini))

    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH

  /* Constant data goes into FLASH */
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >FLASH

  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  .ARM : {
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
  } >FLASH

  .preinit_array     :
  {
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
  } >FLASH
  .init_array :
  {
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
  } >FLASH
  .fini_array :
  {
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array*))
    PROVIDE_HIDDEN (__fini_array_end = .);
  } >FLASH

  /* used by the startup to initialize data */
  _sidata = LOADADDR(.data);

  /* Initialized data sections goes into RAM, load LMA copy after code */
  .data : 
  {
    . = ALIGN(4);
    _sdata = .;        /* create a global symbol at data start */
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */

    . = ALIGN(4);
    _edata = .;        /* define a global symbol at data end */
  } >RAM AT> FLASH


  /* Uninitialized data section */
  . = ALIGN(4);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss secion */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >RAM

  /* User_heap_stack section, used to check that there is enough RAM left */
  ._user_heap_stack :
  {
    . = ALIGN(4);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    . = . + _Min_Stack_Size;
    . = ALIGN(4);
  } >RAM



  /* Remove information from the standard libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
  }

  .ARM.attributes 0 : { *(.ARM.attributes) }
}

解决

原来是文件系统错误或其他一些错误 - 链接器只能看到一个空文件。不过,在我的编辑器中它是正确的,并从编辑器中保存。我不知道这是怎么发生的,但NotLikeThat的评论指出了我正确的方向。

0 个答案:

没有答案