1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

Merge pull request #16789 from kaspar030/fix_lto_linking

make: add -ffunction-sections -fdata-sections to LINKFLAGS if LTO=1
This commit is contained in:
Francisco 2022-02-15 19:48:46 +01:00 committed by GitHub
commit 9314a591cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -54,7 +54,7 @@ endif
ifeq ($(LTO),1)
$(warning Building with Link-Time-Optimizations is currently an experimental feature. Expect broken binaries.)
LTOFLAGS = -flto
LINKFLAGS += $(LTOFLAGS)
LINKFLAGS += $(LTOFLAGS) -ffunction-sections -fdata-sections
endif
# Forbid common symbols to prevent accidental aliasing.

View File

@ -26,7 +26,7 @@ extern void *__real_realloc(void *ptr, size_t size);
static mutex_t _lock;
void *__wrap_malloc(size_t size)
void __attribute__((used)) *__wrap_malloc(size_t size)
{
assert(!irq_is_in());
mutex_lock(&_lock);
@ -35,7 +35,7 @@ void *__wrap_malloc(size_t size)
return ptr;
}
void __wrap_free(void *ptr)
void __attribute__((used)) __wrap_free(void *ptr)
{
assert(!irq_is_in());
mutex_lock(&_lock);
@ -43,7 +43,7 @@ void __wrap_free(void *ptr)
mutex_unlock(&_lock);
}
void *__wrap_calloc(size_t nmemb, size_t size)
void * __attribute__((used)) __wrap_calloc(size_t nmemb, size_t size)
{
/* some c libs don't perform proper overflow check (e.g. newlib < 4.0.0). Hence, we
* just implement calloc on top of malloc ourselves. In addition to ensuring proper
@ -61,7 +61,7 @@ void *__wrap_calloc(size_t nmemb, size_t size)
return res;
}
void *__wrap_realloc(void *ptr, size_t size)
void * __attribute__((used))__wrap_realloc(void *ptr, size_t size)
{
assert(!irq_is_in());
mutex_lock(&_lock);