From: Willy Tarreau Date: Fri, 28 Jan 2022 08:42:29 +0000 (+0100) Subject: BUILD: tools: fix warning about incorrect cast with dladdr1() X-Git-Tag: v2.6-dev1~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f3d5c4b032274e4b5e1879a616e93890043349f6;p=thirdparty%2Fhaproxy.git BUILD: tools: fix warning about incorrect cast with dladdr1() dladdr1() is used on glibc and takes a void**, but we pass it a const ElfW(Sym)** and some compilers complain that we're aliasing. Let's just set a may_alias attribute on the local variable to address this. There's no need to backport this unless warnings are reported on older distros or uncommon compilers. --- diff --git a/src/tools.c b/src/tools.c index aa90341b21..eca7aa8e2c 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4814,7 +4814,7 @@ static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size) { int ret; #if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) // most detailed one - const ElfW(Sym) *sym; + const ElfW(Sym) *sym __attribute__((may_alias)); ret = dladdr1(addr, dli, (void **)&sym, RTLD_DL_SYMENT); if (ret)