elf: Ignore loader debug env vars for setuid
[glibc.git] / sysdeps / aarch64 / tst-ifunc-arg-2.c
blobe671f513d469da26c3bf9595bb03432f9773d3ac
1 /* Test R_*_IRELATIVE 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/>. */
19 #include <stdint.h>
20 #include <sys/auxv.h>
21 #include <sys/ifunc.h>
22 #include <support/check.h>
24 static int
25 one (void)
27 return 1;
30 static uint64_t saved_arg1;
31 static __ifunc_arg_t saved_arg2;
33 /* local ifunc symbol. */
34 int
35 __attribute__ ((visibility ("hidden")))
36 foo (void);
38 static void *
39 __attribute__ ((used))
40 foo_ifunc (uint64_t, const __ifunc_arg_t *) __asm__ ("foo");
41 __asm__(".type foo, %gnu_indirect_function");
43 static void *
44 __attribute__ ((used))
45 inhibit_stack_protector
46 foo_ifunc (uint64_t arg1, const __ifunc_arg_t *arg2)
48 saved_arg1 = arg1;
49 if (arg1 & _IFUNC_ARG_HWCAP)
50 saved_arg2 = *arg2;
51 return (void *) one;
54 static int
55 do_test (void)
57 TEST_VERIFY (foo () == 1);
58 TEST_VERIFY (saved_arg1 & _IFUNC_ARG_HWCAP);
59 TEST_COMPARE ((uint32_t)saved_arg1, (uint32_t)getauxval (AT_HWCAP));
60 TEST_COMPARE (saved_arg2._size, sizeof (__ifunc_arg_t));
61 TEST_COMPARE (saved_arg2._hwcap, getauxval (AT_HWCAP));
62 TEST_COMPARE (saved_arg2._hwcap2, getauxval (AT_HWCAP2));
63 return 0;
66 #include <support/test-driver.c>