Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By igrr
#3041
jcmvbkbc wrote:Ok, there may be straighter ways of doing that, but the easiest that I've found is that: add the following code to your user_main:
Code: Select allextern void (**__init_array_start)(void);
extern void (**__init_array_end)(void);

static void do_global_ctors(void)
{
        void (**p)(void);
        for (p = __init_array_start; p != __init_array_end; ++p)
                (*p)();
}



This does not seem to work. I think you have to take addresses of symbols defined in the linker script instead of using their values. The following works for me:

Code: Select allextern void (*__init_array_start)(void);
extern void (*__init_array_end)(void);

static void do_global_ctors(void)
{
    void (**p)(void);
    for (p = &__init_array_start; p != &__init_array_end; ++p)
            (*p)();
}
User avatar
By igrr
#3051 @jcmvbkbc
Could you please guide me where newlib build configuration is stored in crosstool-NG? I want to add MALLOC_PROVIDED and ABORT_PROVIDED defines at build time, because default implementations don't work on esp8266. Not sure if this change can/should be done in your crosstool-NG repository, but at least I find this option necessary for my local build.
I tried exporting CPPFLAGS="-DMALLOC_PROVIDED -DABORT_PROVIDED" to the build environment but this didn't work for some reason.
Another option would probably be to patch newlib sources to mark abort, malloc, free symbols as weak, I guess.
User avatar
By jcmvbkbc
#3054
igrr wrote:@jcmvbkbc
Could you please guide me where newlib build configuration is stored in crosstool-NG?

AFAICS the only 'configuration' for the newlib is taken from the .config, where it can be edited by the ./ct-ng menuconfig, and then passed to newlib configure script as switches.
Additional switches may be provided through CT_LIBC_NEWLIB_EXTRA_CONFIG_ARRAY parameter ('Extra config for newlib' in menuconfig).