[CPP] Small change to setup.c: call `.__init` section


The .__init section is ignored, which is unfortunate because it allows running static initialization functions. For example, this enables the C attribute __attribute__((constructor)), and it also enables some of the missing C++ functionality.

There's a simple fix, which is to call the .__init section as a function the first time the C API handler is invoked. I've implemented this in setup.c, although there are other variations of how it could be implemented instead.

It would also be very nice to add these linker map lines (extab and exidx), which allow C++ to use exceptions. Without this change, compiling on C++ throws linker errors.

1 Like

Interesting. I'll run this by the appropriate folks, but it seems reasonable to me. Thanks for the suggestions.

1 Like