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

The first approach in commit 288dc1d8e ("BUG/MEDIUM: tools: avoid calling
dlsym() in static builds") relied on dlopen() but on certain configs (at
least gcc-4.8+ld-2.27+glibc-2.17) it used to catch situations where it
ought not fail.

Let's have a second try on this using dladdr() instead. The variable was
renamed "build_is_static" as it's exactly what's being detected there.
We could even take it for reporting in -vv though that doesn't seem very
useful. At least the variable was made global to ease inspection via the
debugger, or in case it's useful later.

Now it properly detects a static build even with gcc-4.4+glibc-2.11.1 and
doesn't crash anymore.

(cherry picked from commit 5b3cd9561bdbf7bac7db04bafead76125f1458ae)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 1dbb19401536db79d394a39da5758838e483659d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit cf3050812faf628e1beda1dfbe9cabdb8f06f60a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
2 files changed