text: /*!
   * @file
   * @brief
   */
  
  #include <stdint.h>
  
  extern uint32_t _data_rom;
  extern uint32_t _data_begin;
  extern uint32_t _data_end;
  extern uint32_t _bss_begin;
  extern uint32_t _bss_end;
  extern uint32_t _stack_top;
  
  extern void main(void);
  
  void reset_handler(void)
  {
    uint32_t* source = &_data_rom;
  
    for(uint32_t* destination = &_data_begin; destination < &_data_end;) {
      *(destination++) = *(source++);
    }
  
    for(uint32_t* destination = &_bss_begin; destination < &_bss_end;) {
      *(destination++) = 0;
    }
  
    main();
  }
  
  void default_handler(void)
  {
    while(1) {
    }
  }
  
  // Cortex-M4
  void NMI_Handler(void) __attribute__((weak, alias("default_handler")));
  void HardFault_Handler(void) __attribute__((weak, alias("default_handler")));
  void MemManage_Handler(void) __attribute__((weak, alias("default_handler")));
  void BusFault_Handler(void) __attribute__((weak, alias("default_handler")));
  void UsageFault_Handler(void) __attribute__((weak, alias("default_handler")));
  void SVC_Handler(void) __attribute__((weak, alias("default_handler")));
  void DebugMon_Handler(void) __attribute__((weak, alias("default_handler")));
  void PendSV_Handler(void) __attribute__((weak, alias("default_handler")));
  void SysTick_Handler(void) __attribute__((weak, alias("default_handler")));
  
  // Peripherals
  void WWDG_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void PVD_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TAMPER_STAMP_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void RTC_WKUP_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void FLASH_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void RCC_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI0_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI1_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI2_TS_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI4_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel1_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel2_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel4_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel5_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel6_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA1_Channel7_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void ADC1_2_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USB_HP_CAN1_TX_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USB_LP_CAN1_RX0_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void CAN1_RX1_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void CAN1_SCE_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI9_5_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM1_BRK_TIM15_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM1_UP_TIM16_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM1_TRG_COM_TIM17_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM1_CC_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM2_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM4_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void I2C1_EV_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void I2C1_ER_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void I2C2_EV_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void I2C2_ER_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void SPI1_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void SPI2_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USART1_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USART2_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USART3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void EXTI15_10_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void RTC_Alarm_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USBWakeUp_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM8_BRK_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM8_UP_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM8_TRG_COM_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM8_CC_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void ADC3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void SPI3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void UART4_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void UART5_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM6_DAC_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void TIM7_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA2_Channel1_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA2_Channel2_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA2_Channel3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA2_Channel4_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void DMA2_Channel5_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void ADC4_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void COMP1_2_3_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void COMP4_5_6_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void COMP7_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USB_HP_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USB_LP_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void USBWakeUp_RMP_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  void FPU_IRQHandler(void) __attribute__((weak, alias("default_handler")));
  
  typedef void (*vector_t)(void);
  
  const vector_t vector_table[] __attribute__((section(".vectors"), used)) = {
    // Cortex-M4
    (vector_t)(uintptr_t)&_stack_top,
    reset_handler,
    NMI_Handler,
    HardFault_Handler,
    MemManage_Handler,
    BusFault_Handler,
    UsageFault_Handler,
    0,
    0,
    0,
    0,
    SVC_Handler,
    DebugMon_Handler,
    0,
    PendSV_Handler,
    SysTick_Handler,
  
    // Peripherals
    WWDG_IRQHandler,
    PVD_IRQHandler,
    TAMPER_STAMP_IRQHandler,
    RTC_WKUP_IRQHandler,
    FLASH_IRQHandler,
    RCC_IRQHandler,
    EXTI0_IRQHandler,
    EXTI1_IRQHandler,
    EXTI2_TS_IRQHandler,
    EXTI3_IRQHandler,
    EXTI4_IRQHandler,
    DMA1_Channel1_IRQHandler,
    DMA1_Channel2_IRQHandler,
    DMA1_Channel3_IRQHandler,
    DMA1_Channel4_IRQHandler,
    DMA1_Channel5_IRQHandler,
    DMA1_Channel6_IRQHandler,
    DMA1_Channel7_IRQHandler,
    ADC1_2_IRQHandler,
    USB_HP_CAN1_TX_IRQHandler,
    USB_LP_CAN1_RX0_IRQHandler,
    CAN1_RX1_IRQHandler,
    CAN1_SCE_IRQHandler,
    EXTI9_5_IRQHandler,
    TIM1_BRK_TIM15_IRQHandler,
    TIM1_UP_TIM16_IRQHandler,
    TIM1_TRG_COM_TIM17_IRQHandler,
    TIM1_CC_IRQHandler,
    TIM2_IRQHandler,
    TIM3_IRQHandler,
    TIM4_IRQHandler,
    I2C1_EV_IRQHandler,
    I2C1_ER_IRQHandler,
    I2C2_EV_IRQHandler,
    I2C2_ER_IRQHandler,
    SPI1_IRQHandler,
    SPI2_IRQHandler,
    USART1_IRQHandler,
    USART2_IRQHandler,
    USART3_IRQHandler,
    EXTI15_10_IRQHandler,
    RTC_Alarm_IRQHandler,
    USBWakeUp_IRQHandler,
    TIM8_BRK_IRQHandler,
    TIM8_UP_IRQHandler,
    TIM8_TRG_COM_IRQHandler,
    TIM8_CC_IRQHandler,
    ADC3_IRQHandler,
    SPI3_IRQHandler,
    UART4_IRQHandler,
    UART5_IRQHandler,
    TIM6_DAC_IRQHandler,
    TIM7_IRQHandler,
    DMA2_Channel1_IRQHandler,
    DMA2_Channel2_IRQHandler,
    DMA2_Channel3_IRQHandler,
    DMA2_Channel4_IRQHandler,
    DMA2_Channel5_IRQHandler,
    ADC4_IRQHandler,
    COMP1_2_3_IRQHandler,
    COMP4_5_6_IRQHandler,
    COMP7_IRQHandler,
    USB_HP_IRQHandler,
    USB_LP_IRQHandler,
    USBWakeUp_RMP_IRQHandler,
    FPU_IRQHandler
  };
  