BUG/MEDIUM: tools: avoid calling dlsym() in static builds

Since 2.4 with commit 64192392c ("MINOR: tools: add functions to retrieve
the address of a symbol"), we can resolve symbols. However some old glibc
crash in dlsym() when the program is statically built.

Fortunately even on these old libs we can detect lack of support by
calling dlopen(NULL). Normally it returns a handle to the current
program, but on a static build it returns NULL. This is sufficient to
refrain from calling dlsym() (which will be of very limited use anyway),
so we check this once at boot and use the result when needed.

This may be backported to 2.4. On stable versions, be careful to place
the init code inside an if/endif guard that checks for DL support.

(cherry picked from commit 288dc1d8eeb3340068792698e98960c59faa6c99)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 7566c51e166fc0091c595605785da0ebe5cecc20)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit d577d9817b1208d237b0fd9fe8f956ebd71e9227)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
1 file changed