*
*/
-#ifdef __ELF__
+#if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
#define _GNU_SOURCE
#include <dlfcn.h>
#include <link.h>
return ret;
}
-#ifdef __ELF__
+#if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
/* calls dladdr() or dladdr1() on <addr> and <dli>. If dladdr1 is available,
* also returns the symbol size in <size>, otherwise returns 0 there.
*/
* The file name (lib or executable) is limited to what lies between the last
* '/' and the first following '.'. An optional prefix <pfx> is prepended before
* the output if not null. The file is not dumped when it's the same as the one
- * that contains the "main" symbol, or when __ELF__ is not set.
+ * that contains the "main" symbol, or when __ELF__ && USE_DL are not set.
*
* The symbol's base address is returned, or NULL when unresolved, in order to
* allow the caller to match it against known ones.
#endif
};
-#ifdef __ELF__
+#if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
Dl_info dli, dli_main;
size_t size;
const char *fname, *p;
}
}
-#ifdef __ELF__
+#if (defined(__ELF__) && !defined(__linux__)) || defined(USE_DL)
/* Now let's try to be smarter */
if (!dladdr_and_size(addr, &dli, &size))
goto unknown;
chunk_appendf(buf, "+%#lx", (long)(addr - dli.dli_fbase));
return NULL;
}
-#endif /* __ELF__ */
+#endif /* __ELF__ && !__linux__ || USE_DL */
unknown:
/* unresolved symbol from the main file, report relative offset to main */
if ((void*)addr < (void*)main)