Analyze Statically Linked Binaries on Linux* Targets
To profile a statically linked binary file, temporary stop stripping the binary file during compilation and make sure the binary file exports the following symbols from system libraries:
- _init()in the main executable: if you profile a tree of processes, consider using the option.
- libc.so:
- A target exportssetenv,getenv(), and__errno_location()symbols unconditionally.
- If a target employsrecv()API, it exportsrecv()andpoll().
- If a target employssleep()orusleep()APIs, it exportssleep()orusleep()respectively, andnanosleep()symbol.
- libpthread.so:
- If a target employspthread_create()API, it exports the following symbols:
- pthread_create()
- pthread_key_create()
- pthread_setspecific()
- pthread_getspecific()
- pthread_self()
- pthread_getattr_np()
- pthread_attr_destroy()
- pthread_attr_setstack()
- pthread_attr_getstack()
- pthread_attr_getstacksize()
- pthread_attr_setstacksize()
- If a target employspthread_cancel()API, it exports the following symbols:
- pthread_cancel()
- _pthread_cleanup_push()
- _pthread_cleanup_pop()
- If a target employs_pthread_cleanup_push()or_pthread_cleanup_pop()API, it exports the following symbols:
- _pthread_cleanup_push()
- _pthread_cleanup_pop()
- If a target employspthread_mutex_lock()API, it exportspthread_mutex_lock()andpthread_mutex_trylock()symbol.
- If a target employspthread_spin_lock()API, it exportspthread_spin_lock()andpthread_spin_trylock()symbol.
- libdl.so:If a target employs any ofdlopen(),dlsym(), ordlclose()APIs, it exports all three of them simultaneously.
If the binary file does not export some of the symbols above, use the
-u
linker switch (for example, specify
-Wl,-u__errno_location
if you use compiler for linking) to include symbols into the binary file at the linking stage of compilation.