1 /* Test STT_GNU_IFUNC resolver with second argument.
2 Copyright (C) 2019-2023 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/>. */
21 #include <sys/ifunc.h>
22 #include <support/check.h>
30 static uint64_t saved_arg1
;
31 static __ifunc_arg_t saved_arg2
;
33 /* extern visible ifunc symbol. */
38 foo_ifunc (uint64_t, const __ifunc_arg_t
*) __asm__ ("foo");
39 __asm__(".type foo, %gnu_indirect_function");
42 inhibit_stack_protector
43 foo_ifunc (uint64_t arg1
, const __ifunc_arg_t
*arg2
)
46 if (arg1
& _IFUNC_ARG_HWCAP
)
54 TEST_VERIFY (foo () == 1);
55 TEST_VERIFY (saved_arg1
& _IFUNC_ARG_HWCAP
);
56 TEST_COMPARE ((uint32_t)saved_arg1
, (uint32_t)getauxval (AT_HWCAP
));
57 TEST_COMPARE (saved_arg2
._size
, sizeof (__ifunc_arg_t
));
58 TEST_COMPARE (saved_arg2
._hwcap
, getauxval (AT_HWCAP
));
59 TEST_COMPARE (saved_arg2
._hwcap2
, getauxval (AT_HWCAP2
));
63 #include <support/test-driver.c>