From 2c01e2789a71c43afe817aefc750cf24a939df5d Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Mon, 9 Aug 2021 20:52:26 +0200 Subject: [PATCH] make vdso work again --- base/glibc-compatibility/musl/getauxval.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base/glibc-compatibility/musl/getauxval.c b/base/glibc-compatibility/musl/getauxval.c index a429273fa1a..61a47449db3 100644 --- a/base/glibc-compatibility/musl/getauxval.c +++ b/base/glibc-compatibility/musl/getauxval.c @@ -17,7 +17,11 @@ static size_t __find_auxv(unsigned long type) return (size_t) -1; } -__attribute__((constructor)) static void __auxv_init() +/// __auxv_init should happen BEFORE the first use of getauxval. +/// but getauxval can be used in other init sections (namely in musl/clock_gettime.c::cgt_init), +/// so constructor(0) is needed to prioritize that constructor +/// see also: https://stackoverflow.com/questions/11106875/attribute-constructor-call-order-confusion/11198936 +__attribute__((constructor(0))) static void __auxv_init() { size_t i; for (i = 0; __environ[i]; i++);