Merge pull request #11874 from fkjagodzinski/armc6_build-enable_lto_for_release

ARMC6: Add a build profile extension with the link-time optimizer enabled
pull/12377/head
Martin Kojtal 2020-02-05 14:42:16 +00:00 committed by GitHub
commit 32675cc6ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 66 additions and 21 deletions

View File

@ -27,6 +27,7 @@
#include "region_defs.h"
#include "tfm_nspm.h"
#include "tfm_memory_utils.h"
#include "platform/mbed_toolchain.h"
/*
* IPC partitions.
@ -580,7 +581,7 @@ void tfm_spm_init(void)
tfm_thrd_start_scheduler(&this_thrd);
}
void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb)
MBED_USED void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb)
{
#if TFM_LVL == 2
struct spm_partition_desc_t *p_next_partition;

View File

@ -19,6 +19,7 @@
#include <stdbool.h>
#include "tfm_svcalls.h"
#endif
#include "platform/mbed_toolchain.h"
/* This SVC handler is called when a secure partition requests access to a
* buffer area
@ -135,7 +136,7 @@ __attribute__((naked)) void SVC_Handler(void)
#error "Unsupported ARM Architecture."
#endif
uint32_t SVCHandler_main(uint32_t *svc_args, uint32_t lr)
MBED_USED uint32_t SVCHandler_main(uint32_t *svc_args, uint32_t lr)
{
uint8_t svc_number;
/*

View File

@ -347,6 +347,16 @@ extern "C" void *SUB_REALLOC(void *ptr, size_t size)
memcpy(new_ptr, (void *)ptr, copy_size);
free(ptr);
}
{
volatile uint8_t dummy = 0;
if (dummy != 0) { // always false
// this code will never be executed
// it's just to tell the compiler/linker to preserve SUB_REALLOC symbol
// when LTO enabled
SUPER_REALLOC(NULL, 0);
}
}
#else // #if MBED_HEAP_STATS_ENABLED
new_ptr = SUPER_REALLOC(ptr, size);
#endif // #if MBED_HEAP_STATS_ENABLED
@ -369,6 +379,16 @@ extern "C" void *SUB_CALLOC(size_t nmemb, size_t size)
if (ptr != NULL) {
memset(ptr, 0, nmemb * size);
}
{
volatile uint8_t dummy = 0;
if (dummy != 0) { // always false
// this code will never be executed
// it's just to tell the compiler/linker to preserve SUB_CALLOC symbol
// when LTO enabled
SUPER_CALLOC(NULL, 0);
}
}
#else // #if MBED_HEAP_STATS_ENABLED
ptr = SUPER_CALLOC(nmemb, size);
#endif // #if MBED_HEAP_STATS_ENABLED

View File

@ -1141,7 +1141,7 @@ extern "C" __value_in_regs struct __argc_argv $Sub$$__rt_lib_init(unsigned heapb
}
#endif
extern "C" __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3)
MBED_USED extern "C" __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3)
{
return _mbed_user_setup_stackheap(R0, R1, R2, R3);
}

View File

@ -62,7 +62,9 @@ extern void SramInit(void);
#if defined( __ICCARM__)
__root
#endif /* __ICCARM__ */
#else
__attribute__((used))
#endif
const uint32_t SECTION_PLACE(blank_checksum[],".checksum") =
{
BLANKX60,BLANKX600
@ -139,6 +141,11 @@ WEAK_FUNCTION( DMA_SIP7_Int_Handler )
/*----------------------------------------------------------------------------
Exception / Interrupt Vector table
*----------------------------------------------------------------------------*/
#if defined( __ICCARM__)
__root
#else
__attribute__((used))
#endif
const pFunc SECTION_PLACE(IVT_NAME[104],VECTOR_SECTION) =
{
(pFunc) INITIAL_SP, /* Initial Stack Pointer */

View File

@ -60,8 +60,10 @@ extern void SramInit(void);
Checksum options
*----------------------------------------------------------------------------*/
#if defined(__ICCARM__)
#if defined( __ICCARM__)
__root
#else
__attribute__((used))
#endif
const uint32_t SECTION_PLACE(blank_checksum[],".checksum") =
{
@ -144,6 +146,11 @@ WEAK_FUNCTION( Root_Clk_Err_Handler )
/*----------------------------------------------------------------------------
Exception / Interrupt Vector table
*----------------------------------------------------------------------------*/
#if defined( __ICCARM__)
__root
#else
__attribute__((used))
#endif
const pFunc SECTION_PLACE(IVT_NAME[104],VECTOR_SECTION) = {
(pFunc) INITIAL_SP, /* Initial Stack Pointer */
ADUCM4050_VECTORS

View File

@ -207,7 +207,7 @@ WEAK_ALIAS_FUNC(TRNG_IRQHandler, Default_Handler) // 101:
/* Vector table */
#if defined(__ARMCC_VERSION)
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
const uint32_t __vector_table[] @ ".intvec" = {

View File

@ -155,7 +155,7 @@ WEAK_ALIAS_FUNC(OPA_IRQHandler, Default_Handler) // 62: OPA Interrupt
/* Vector table */
#if defined(__ARMCC_VERSION)
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
extern uint32_t CSTACK$$Limit;

View File

@ -193,7 +193,7 @@ WEAK_ALIAS_FUNC(TRNG_IRQHandler, Default_Handler) // 101:
/* Vector table */
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
extern uint32_t CSTACK$$Limit;

View File

@ -152,7 +152,7 @@ WEAK_ALIAS_FUNC(TK_IRQHandler, Default_Handler) // 63:
/* Vector table */
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
extern uint32_t CSTACK$$Limit;

View File

@ -24,11 +24,13 @@
#if defined(__CC_ARM)
#define WEAK __attribute__ ((weak))
#define ALIAS(f) __attribute__ ((weak, alias(#f)))
#define USED __attribute__ ((used))
#define WEAK_ALIAS_FUNC(FUN, FUN_ALIAS) \
void FUN(void) __attribute__ ((weak, alias(#FUN_ALIAS)));
#elif defined(__ICCARM__)
#define USED __root
//#define STRINGIFY(x) #x
//#define _STRINGIFY(x) STRINGIFY(x)
#define WEAK_ALIAS_FUNC(FUN, FUN_ALIAS) \
@ -42,6 +44,7 @@ _Pragma(_STRINGIFY(_WEAK_ALIAS_FUNC(FUN, FUN_ALIAS)))
#elif defined(__GNUC__)
#define WEAK __attribute__ ((weak))
#define ALIAS(f) __attribute__ ((weak, alias(#f)))
#define USED __attribute__ ((used))
#define WEAK_ALIAS_FUNC(FUN, FUN_ALIAS) \
void FUN(void) __attribute__ ((weak, alias(#FUN_ALIAS)));
@ -77,7 +80,7 @@ void Default_Handler(void);
void Reset_Handler(void);
void Reset_Handler_1(void);
void Reset_Handler_2(void);
void Reset_Handler_Cascade(void *sp, void *pc);
USED void Reset_Handler_Cascade(void *sp, void *pc);
/* Cortex-M4 core handlers */
WEAK_ALIAS_FUNC(NMI_Handler, Default_Handler)
@ -190,7 +193,7 @@ WEAK_ALIAS_FUNC(ETMC_IRQHandler, Default_Handler) // 95:
/* Vector table */
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
extern uint32_t CSTACK$$Limit;

View File

@ -114,7 +114,7 @@ WEAK_ALIAS_FUNC(RTC_IRQHandler, Default_Handler) // Real time clock i
/* Vector table */
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
extern uint32_t CSTACK$$Limit;

View File

@ -232,7 +232,7 @@ WEAK_ALIAS_FUNC(CRC_IRQHandler, Default_Handler) // 141: CRC
/* Vector table */
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
__attribute__ ((section("RESET")))
__attribute__ ((section("RESET"), used))
const uint32_t __vector_handlers[] = {
#elif defined(__ICCARM__)
extern uint32_t CSTACK$$Limit;

View File

@ -17,7 +17,7 @@
******************************************************************************/
#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
__attribute__((section(".boot_hdr.conf")))
__attribute__((section(".boot_hdr.conf"), used))
#elif defined(__ICCARM__)
#pragma location = ".boot_hdr.conf"
#endif

View File

@ -14,7 +14,7 @@
#if defined(XIP_BOOT_HEADER_ENABLE) && (XIP_BOOT_HEADER_ENABLE == 1)
#if defined(__CC_ARM) || defined(__ARMCC_VERSION) || defined(__GNUC__)
__attribute__((section(".boot_hdr.ivt")))
__attribute__((section(".boot_hdr.ivt"), used))
#elif defined(__ICCARM__)
#pragma location=".boot_hdr.ivt"
#endif

View File

@ -289,12 +289,12 @@ int rtc_isenabled(void)
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
static void RTC_IRQHandler(void);
static void _RTC_IRQHandler(void);
static void (*irq_handler)(void);
volatile uint8_t lp_Fired = 0;
static void RTC_IRQHandler(void)
static void _RTC_IRQHandler(void)
{
/* Update HAL state */
RtcHandle.Instance = RTC;
@ -428,7 +428,7 @@ void rtc_set_wake_up_timer(timestamp_t timestamp)
}
#endif /* RTC_WUTR_WUTOCLR */
NVIC_SetVector(RTC_WKUP_IRQn, (uint32_t)RTC_IRQHandler);
NVIC_SetVector(RTC_WKUP_IRQn, (uint32_t)_RTC_IRQHandler);
irq_handler = (void (*)(void))lp_ticker_irq_handler;
NVIC_EnableIRQ(RTC_WKUP_IRQn);
core_util_critical_section_exit();
@ -437,7 +437,7 @@ void rtc_set_wake_up_timer(timestamp_t timestamp)
void rtc_fire_interrupt(void)
{
lp_Fired = 1;
NVIC_SetVector(RTC_WKUP_IRQn, (uint32_t)RTC_IRQHandler);
NVIC_SetVector(RTC_WKUP_IRQn, (uint32_t)_RTC_IRQHandler);
irq_handler = (void (*)(void))lp_ticker_irq_handler;
NVIC_SetPendingIRQ(RTC_WKUP_IRQn);
NVIC_EnableIRQ(RTC_WKUP_IRQn);

View File

@ -336,7 +336,7 @@ void CC3220SF_LAUNCHXL_initGeneral(void)
}
#if defined TOOLCHAIN_ARM
__attribute__((section("signature_section")))
__attribute__((section("signature_section"), used))
#elif defined TOOLCHAIN_IAR
#pragma default_variable_attributes = @ ".dbghdr"
#elif defined TOOLCHAIN_GCC_ARM

View File

@ -156,7 +156,7 @@ WEAK_ALIAS_FUNC(EUSCIB3_SPI_IRQHandler, Default_Handler)
// to ensure that it ends up at physical address 0x0000.0000 or at the start of the
// program if located at a start address other than 0.
#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
void (* const interruptVectors[])(void) __attribute__((section("RESET"))) = {
void (* const interruptVectors[])(void) __attribute__((section("RESET"), used)) = {
(pFunc) &Image$$ARM_LIB_STACK$$ZI$$Limit, // The initial stack pointer
#elif defined(__ICCARM__)
void (* const __vector_table[])(void) @ ".intvec" = {

View File

@ -0,0 +1,6 @@
{
"ARMC6": {
"common": ["-flto"],
"ld": ["--lto", "--lto_level=Oz"]
}
}