set errno to ENOENT in getauxval per glibc 2.19
Bionic's getauxval(...) implementation returns zero when entries are
missing. Zero can be a valid value, so there is no unambiguous way of
detecting an error. Since glibc 2.19, errno is set to ENOENT when an
entry is missing to make it possible to detect this. Bionic should match
this behavior as code in the Linux ecosystem will start relying on it to
check for the presence of newly added entries.
Change-Id: Ic1efe29bc45fc87489274c96c4d2193f3a7b8854
Signed-off-by: Daniel Micay <danielmicay@gmail.com>
diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp
index bc41824..22922b9 100644
--- a/libc/bionic/getauxval.cpp
+++ b/libc/bionic/getauxval.cpp
@@ -31,6 +31,7 @@
#include <sys/auxv.h>
#include <private/bionic_auxv.h>
#include <elf.h>
+#include <errno.h>
__LIBC_HIDDEN__ ElfW(auxv_t)* __libc_auxv = NULL;
@@ -40,5 +41,6 @@
return v->a_un.a_val;
}
}
+ errno = ENOENT;
return 0;
}