]> git.kaiwu.me - haproxy.git/commitdiff
BUILD: sym: Use dl_iterate_phdr() for more OSes.
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 14 Oct 2026 11:29:58 +0000 (13:29 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 15 Oct 2026 15:31:28 +0000 (17:31 +0200)
dl_iterate_phdr() is also present on NetBSD, OpenBSD, and Solaris >=
11 (and thus illumos), so use it in there too.

include/haproxy/compat.h

index 10fc58bacd5cbf4ba61a04a8214e7a0868826644..2b022bbaa25d63a64248468201f42d9cb8807413 100644 (file)
@@ -287,8 +287,26 @@ typedef struct { } empty_t;
 #endif
 #endif
 
-/* dl_iterate_phdr() is available in FreeBSD 7.0+ and glibc 2.3+. */
-#if defined(__FreeBSD__) || \
+/* The compiler does not tell the OS version on Solaris, and dl_iterate_phdr()
+ * is missing from Solaris 10, but <err.h> appeared with Solaris 11 and is
+ * used there as the witness of a system new enough for it. Note that the
+ * __has_include() test must stay nested, as a single expression is a syntax
+ * error on the compilers that lack the builtin.
+ */
+#if defined(__sun) && defined(__has_include)
+#if __has_include(<err.h>)
+#define HA_SOLARIS_11
+#endif
+#endif
+
+/* dl_iterate_phdr() first appeared in glibc 2.2.4, FreeBSD 7.0, NetBSD 6.0
+ * and OpenBSD 3.7; the Solaris gate got it in early 2010 (PSARC 2010/015),
+ * before the illumos fork, so every Solaris 11 and illumos release has it.
+ * The glibc test below still requires 2.3 as the patch level of 2.2 is not
+ * visible to the preprocessor.
+ */
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
+    defined(HA_SOLARIS_11) || \
     (defined(USE_DL) && defined(__GNU_LIBRARY__) && \
      (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)))
 #define HA_HAVE_DL_ITERATE_PHDR