[ccan] autodata problem

Rusty Russell rusty at rustcorp.com.au
Tue Mar 19 10:00:17 EST 2013


picca <picca at synchrotron-soleil.fr> writes:
> Rusty Russell <rusty at rustcorp.com.au> writes:
>
> so I can confirm that I need to add the -ggdb CFLAGS AND replace
> autodata with xautodata to be able to compile my project.

...

> Now do you think that this is a problem with gcc or with your
> implementation of autodata. Should we add an attribute in autodata to
> teach gcc to avoid this too agressive optimisation.

The problem is that autodata *can't* work in general for a shared
library.  autodata is supposed to work even if we don't have function
sections, in which case it searches the binary itself: clearly this
won't work for a shared library.

The more general approach (which only works for gcc) is to use
constructor routines, like so:

void __attribute__((constructor)) register_x(void)
{
        ...
}

This will automatically get called when your shared library is opened.

Cheers,
Rusty.        



More information about the ccan mailing list