1 /* Test getauxval from a dynamic library after static dlopen.
2 Copyright (C) 2021-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
22 #include <support/check.h>
23 #include <support/xdlfcn.h>
26 unsigned long getauxval_wrapper (unsigned long type
, int *errnop
);
31 unsigned long outer_random
= getauxval (AT_RANDOM
);
32 if (outer_random
== 0)
33 FAIL_UNSUPPORTED ("getauxval does not support AT_RANDOM");
35 unsigned long missing_auxv_type
;
36 for (missing_auxv_type
= AT_RANDOM
+ 1; ; ++missing_auxv_type
)
39 if (getauxval (missing_auxv_type
) == 0 && errno
!= 0)
41 TEST_COMPARE (errno
, ENOENT
);
45 printf ("info: first missing type: %lu\n", missing_auxv_type
);
47 void *handle
= xdlopen ("tst-auxvalmod.so", RTLD_LAZY
);
48 void *ptr
= xdlsym (handle
, "getauxval_wrapper");
50 __typeof__ (getauxval_wrapper
) *wrapper
= ptr
;
52 unsigned long inner_random
= wrapper (AT_RANDOM
, &inner_errno
);
53 TEST_COMPARE (outer_random
, inner_random
);
56 TEST_COMPARE (wrapper (missing_auxv_type
, &inner_errno
), 0);
57 TEST_COMPARE (inner_errno
, ENOENT
);
59 TEST_COMPARE (getauxval (AT_HWCAP
), wrapper (AT_HWCAP
, &inner_errno
));
60 TEST_COMPARE (getauxval (AT_HWCAP2
), wrapper (AT_HWCAP2
, &inner_errno
));
66 #include <support/test-driver.c>