]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: tools: fix warning about incorrect cast with dladdr1()
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Jan 2022 08:42:29 +0000 (09:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Jan 2022 18:04:02 +0000 (19:04 +0100)
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

index aa90341b2100322b216e405987978d156ce77bfb..eca7aa8e2c50b4cf9ac377fb64a897d599852956 100644 (file)
@@ -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)