I want to use GNU libc's backtrace() and backtrace_symbols_fd() functions in a signal handler. However, the backtrace docs page tells me to make sure that libgcc is loaded already in that case.
But how to make sure that libgcc is loaded?
I could try to call some simple functions from libgcc, but it seems that they could simply be builtin in the compiler already and not trigger loading of libgcc. I also tried to use something like dlopen("/lib/gcc/x86_64-linux-gnu/12/libgcc_s.so", RTLD_NOW); on Debian 12, but this does not work, either (with random other shared lib it does work, though). Linking libgcc statically is apparently also not a good option. The solution should be fairly generic and not tied to, e.g., Ubuntu only.
Besides my searching effort, I haven't found any good solution for this case. Any tips or hints would be highly appreciated.
backtracedoc is in error.backtrace*are part of libc. And,mallocet. al. are part of libc. So, it's self contained. No need to check forlibgcc.*It will already be linked/loaded (if needed, and I don't think these functions directly depend on it). Neithermallocnorbacktracecan be inlibgccbecause they are system-dependent and that's the province of libc and not libgcc.