From bd2ccedcc51d622598644179788d7dca37e8f6d3 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 17 Aug 2021 08:44:25 +0100 Subject: [PATCH] BUILD: tools: get the absolute path of the current binary on NetBSD. NetBSD stores the absolute path into the auxiliary vector as well. --- src/tools.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools.c b/src/tools.c index bd6bf4edc..545fd9e8d 100644 --- a/src/tools.c +++ b/src/tools.c @@ -16,6 +16,11 @@ #include #endif +#if defined(__NetBSD__) +#include +#include +#endif + #include #include #include @@ -4761,6 +4766,14 @@ const char *get_exec_path() if (execfn && execfn != ENOENT) ret = (const char *)execfn; +#elif defined(__NetBSD__) + AuxInfo *auxv; + for (auxv = _dlauxinfo(); auxv->a_type != AT_NULL; ++auxv) { + if (auxv->a_type == AT_SUN_EXECNAME) { + ret = (const char *)auxv->a_v; + break; + } + } #endif return ret; }