ESP-IDF gcc static constructor
Posted: Tue May 10, 2022 7:16 am
Hello.
ESP32 IDF gcc linker remove "static" symbols in module, even if have "constructor" attribute.
(use "Master" branch).
I.E. , i'm built sources in project :
------------ main.c ----------------------
#include <stdio.h>
void f(void) { printf ("test\n"); }
void app_main() {}
//void main() { app_main(); }
------------------------------------------
------------ test.c ----------------------
void f(void);
static void __attribute__ ((constructor (101))) test (void) { f(); }
-------------------------------------------
methods 'f()' and 'test()' do not called.
I'm checked it at xtensa - (ESP32) and risc-v - (ESP32-C3) projects.
How to fix it?
If build this on other platforms (Windows-, linux-, arm-linux- , none-eabi- gcc ), static constructors are called.
ESP32 IDF gcc linker remove "static" symbols in module, even if have "constructor" attribute.
(use "Master" branch).
I.E. , i'm built sources in project :
------------ main.c ----------------------
#include <stdio.h>
void f(void) { printf ("test\n"); }
void app_main() {}
//void main() { app_main(); }
------------------------------------------
------------ test.c ----------------------
void f(void);
static void __attribute__ ((constructor (101))) test (void) { f(); }
-------------------------------------------
methods 'f()' and 'test()' do not called.
I'm checked it at xtensa - (ESP32) and risc-v - (ESP32-C3) projects.
How to fix it?
If build this on other platforms (Windows-, linux-, arm-linux- , none-eabi- gcc ), static constructors are called.