Hi Dmitry, first, sorry for the long delay but these days I've been drained in a bunch of meetings and reviews that took more time than I expected!
On Wed, Feb 28, 2024 at 11:06:00PM +0300, Dmitry Sivachenko wrote: > Hello! > > Recently FreeBSD has moved some things out from libc to libsys (see e.g > https://www.mail-archive.com/dev-commits-src-all@freebsd.org/msg50353.html) > So haproxy stopped compiling with "ld: error: undefined symbol: > __elf_aux_vector" error. > > Brooks Davis suggested the attached patch to fix that. > > Please consider including it into the tree. What's the oldest FreeBSD version that will build with this ? Shouldn't we just guard it by version ? This patch is pretty well isolated and in a place already full of ifdefs, so it would cost basically nothing to add a test for the FreeBSD version in addition to defined(): > --- src/tools.c.orig > +++ src/tools.c > @@ -17,9 +17,7 @@ > #endif > > #if defined(__FreeBSD__) > -#include <elf.h> > -#include <dlfcn.h> > -extern void *__elf_aux_vector; > +#include <sys/auxv.h> > #endif > > #if defined(__NetBSD__) > @@ -5018,13 +5016,11 @@ > if (execfn && execfn != ENOENT) > ret = (const char *)execfn; > #elif defined(__FreeBSD__) > - Elf_Auxinfo *auxv; > - for (auxv = __elf_aux_vector; auxv->a_type != AT_NULL; ++auxv) { > - if (auxv->a_type == AT_EXECPATH) { > - ret = (const char *)auxv->a_un.a_ptr; > - break; > - } > - } > + static char execpath[MAXPATHLEN]; > + if (execpath[0] == '\0') > + elf_aux_info(AT_EXECPATH, execpath, MAXPATHLEN); > + if (execpath[0] != '\0') > + ret = execpath; > #elif defined(__NetBSD__) > AuxInfo *auxv; > for (auxv = _dlauxinfo(); auxv->a_type != AT_NULL; ++auxv) { Note that I tested it on a 13.1 and it builds there, I'm just concerned about older ones (e.g. I don't have a v12 here). Thanks! Willy