CodexBloom - Programming Q&A Platform

strace shows missing symbols while debugging a shared library on CentOS 7

👀 Views: 1 💬 Answers: 1 📅 Created: 2025-06-03
linux strace debugging shared-library C

I'm having a hard time understanding I'm trying to debug a shared library using `strace` on CentOS 7, but I'm running into issues where it doesn't seem to capture all the function calls, leading to missing symbols in my output... My library is built with `gcc 4.8.5` under a `--shared` flag, and I’ve ensured that the debug symbols are included using the `-g` flag during compilation. However, when I run `strace` on the executable that uses this library, I notice that not all functions are showing up in the trace. Here’s how I’m compiling the library: ```bash gcc -fPIC -shared -g -o libmylib.so mylib.c ``` And here’s the command I use to run `strace`: ```bash strace -e trace=all ./my_executable ``` I expected to see calls to functions like `initialize()` and `process_data()`, but they don't appear in the output. All I see are system calls and some standard library calls. I’ve also tried using the `LD_PRELOAD` environment variable to force the library to load: ```bash LD_PRELOAD=./libmylib.so ./my_executable ``` Despite these steps, the functions still aren’t traced. I even confirmed that the library is being loaded by checking the output of `ldd ./my_executable`. Am I missing something in the `strace` command, or could there be something wrong with how the symbols are being exported in my library? Any help would be appreciated! I'm working on a service that needs to handle this. Any help would be greatly appreciated! I'm coming from a different tech stack and learning C. Any pointers in the right direction?