MINOR: compat: detect support for dl_iterate_phdr()
We'll use this glibc function to dump loaded libs. It's been
available since glibc-2.2.4, and as it requires dlpi headers defined
in link.h, it implicitly relies on dlfcn, thus we condition it to
USE_DL. Other operating systems or libc might have different
dependencies so let's stick to the bare minimum for now.
(cherry picked from commit 3f3a56c9b07175f342f30c6271df24f783c892c6)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 005413467084851ed73780fe4f0a554c699150ac)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/include/haproxy/compat.h b/include/haproxy/compat.h
index 8e5d09c..547dd47 100644
--- a/include/haproxy/compat.h
+++ b/include/haproxy/compat.h
@@ -267,6 +267,11 @@
#endif
#endif
+/* dl_iterate_phdr() is available in GLIBC 2.2.4 and up. Let's round up to 2.3.x */
+#if defined(USE_DL) && defined(__GNU_LIBRARY__) && (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
+#define HA_HAVE_DL_ITERATE_PHDR
+#endif
+
/* malloc_trim() can be very convenient to reclaim unused memory especially
* from huge pattern files. It's available (and really usable) in glibc 2.8 and
* above.