.so: need to figure out what functions are executed at boot

In Auto-Run Functions When Loading Shared Libraries :

To make the function execute when the shared library is loaded or unloaded, you can mark the constructor and destructor function using the GCC-specific attribute syntax:

__attribute__((constructor)) void init(void) { ... }
__attribute__((destructor))  void fini(void) { ... }

      

In How does __attribute __ ((constructor)) work? also mentions .init/.fini

.

Now I have a module .so

(shared object library, no source) and I want to know what functions are executed when the library is loaded / unloaded. I tried nm

but it looks like these attributes are not showing in the output.

So how do you know what functions are automatically executed when you load or unload a shared library?

+3


source to share


1 answer


I still don't have an answer in general, but this is what I found:

The library has sections .init_array

and .fini_array

. (There's no .init

or .ctors

, but YMMV.)

; Segment type: Pure data
            AREA .init_array, DATA
            DCD sub_F5C+1
            DCB    0
            DCB    0
            DCB    0
            DCB    0
.init_array   ends

      



So it looks like it sub_F5C()

is the only function called on initialization. 4 zero bytes at the end is really one zero dword; +1 is the ARM function to select the instruction set.

More about .init_array

and other special sections

0


source







All Articles