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.
This commit is contained in:
Willy Tarreau 2022-01-28 09:42:29 +01:00
parent 8f0b4e97e7
commit f3d5c4b032

View 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)