From d477b1f0f4ce97eb1da28c7ba2539e1bd533ce0d Mon Sep 17 00:00:00 2001 From: Julien Lecoeur Date: Wed, 28 Jun 2017 16:23:01 +0200 Subject: [PATCH] Fix -Werror=stringop-overflow on gcc 7 This prevents the compiler from optimising pdump. The error was: Firmware/src/drivers/boards/common/board_crashdump.c:41:2: error: 'memset' writing 3240 bytes into a region of size 4 overflows the destination [-Werror=stringop-overflow=] memset(pdump, 0, sizeof(fullcontext_s)); --- src/drivers/boards/common/board_crashdump.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/drivers/boards/common/board_crashdump.c b/src/drivers/boards/common/board_crashdump.c index ac238e7b5f..a620d306b3 100644 --- a/src/drivers/boards/common/board_crashdump.c +++ b/src/drivers/boards/common/board_crashdump.c @@ -16,6 +16,11 @@ static void copy_reverse(stack_word_t *dest, stack_word_t *src, int size) } } +static uint32_t *__attribute__((noinline)) __sdata_addr(void) +{ + return &_sdata; +} + __EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint8_t *filename, int lineno) { /* We need a chunk of ram to save the complete context in. @@ -25,7 +30,7 @@ __EXPORT void board_crashdump(uintptr_t currentsp, FAR void *tcb, FAR const uint * Unfortunately this is hard to test. See dead below */ - fullcontext_s *pdump = (fullcontext_s *)&_sdata; + fullcontext_s *pdump = (fullcontext_s *)__sdata_addr(); (void)enter_critical_section();