From f3d5c4b032274e4b5e1879a616e93890043349f6 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 28 Jan 2022 09:42:29 +0100 Subject: [PATCH] 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. --- src/tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools.c b/src/tools.c index aa90341b2..eca7aa8e2 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)