diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp index bc4182496..22922b942 100644 --- a/libc/bionic/getauxval.cpp +++ b/libc/bionic/getauxval.cpp @@ -31,6 +31,7 @@ #include #include #include +#include __LIBC_HIDDEN__ ElfW(auxv_t)* __libc_auxv = NULL; @@ -40,5 +41,6 @@ extern "C" unsigned long int getauxval(unsigned long int type) { return v->a_un.a_val; } } + errno = ENOENT; return 0; } diff --git a/tests/getauxval_test.cpp b/tests/getauxval_test.cpp index b33115007..6ce00f14a 100644 --- a/tests/getauxval_test.cpp +++ b/tests/getauxval_test.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include @@ -53,7 +54,9 @@ TEST(getauxval, expected_values) { TEST(getauxval, unexpected_values) { #if defined(GETAUXVAL_CAN_COMPILE) + errno = 0; ASSERT_EQ((unsigned long int) 0, getauxval(0xdeadbeef)); + ASSERT_EQ(ENOENT, errno); #else GTEST_LOG_(INFO) << "This test does nothing.\n"; #endif