1 /* Check LD_AUDIT for aarch64 specific ABI.
2 Copyright (C) 2022-2024 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/>. */
25 #include "tst-audit27mod.h"
27 #define TEST_NAME "tst-audit27"
29 #define AUDIT27_COOKIE 0
32 la_version (unsigned int v
)
38 la_objopen (struct link_map
*map
, Lmid_t lmid
, uintptr_t *cookie
)
40 const char *p
= strrchr (map
->l_name
, '/');
41 const char *l_name
= p
== NULL
? map
->l_name
: p
+ 1;
43 if (strncmp (l_name
, TEST_NAME
, strlen (TEST_NAME
)) == 0)
46 printf ("objopen: %ld, %s [%ld]\n", lmid
, l_name
, ck
);
47 return ck
== -1 ? 0 : LA_FLG_BINDFROM
| LA_FLG_BINDTO
;
51 la_aarch64_gnu_pltenter (ElfW(Sym
) *sym
, unsigned int ndx
, uintptr_t *refcook
,
52 uintptr_t *defcook
, La_aarch64_regs
*regs
,
53 unsigned int *flags
, const char *symname
,
56 printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
57 symname
, (long int) sym
->st_value
, ndx
, *flags
);
59 if (strcmp (symname
, "tst_audit27_func_float") == 0)
61 assert (regs
->lr_vreg
[0].s
== FUNC_FLOAT_ARG0
);
62 assert (regs
->lr_vreg
[1].s
== FUNC_FLOAT_ARG1
);
63 assert (regs
->lr_vreg
[2].s
== FUNC_FLOAT_ARG2
);
64 assert (regs
->lr_vreg
[3].s
== FUNC_FLOAT_ARG3
);
65 assert (regs
->lr_vreg
[4].s
== FUNC_FLOAT_ARG4
);
66 assert (regs
->lr_vreg
[5].s
== FUNC_FLOAT_ARG5
);
67 assert (regs
->lr_vreg
[6].s
== FUNC_FLOAT_ARG6
);
68 assert (regs
->lr_vreg
[7].s
== FUNC_FLOAT_ARG7
);
70 else if (strcmp (symname
, "tst_audit27_func_double") == 0)
72 assert (regs
->lr_vreg
[0].d
== FUNC_DOUBLE_ARG0
);
73 assert (regs
->lr_vreg
[1].d
== FUNC_DOUBLE_ARG1
);
74 assert (regs
->lr_vreg
[2].d
== FUNC_DOUBLE_ARG2
);
75 assert (regs
->lr_vreg
[3].d
== FUNC_DOUBLE_ARG3
);
76 assert (regs
->lr_vreg
[4].d
== FUNC_DOUBLE_ARG4
);
77 assert (regs
->lr_vreg
[5].d
== FUNC_DOUBLE_ARG5
);
78 assert (regs
->lr_vreg
[6].d
== FUNC_DOUBLE_ARG6
);
79 assert (regs
->lr_vreg
[7].d
== FUNC_DOUBLE_ARG7
);
81 else if (strcmp (symname
, "tst_audit27_func_ldouble") == 0)
83 assert (regs
->lr_vreg
[0].q
== FUNC_LDOUBLE_ARG0
);
84 assert (regs
->lr_vreg
[1].q
== FUNC_LDOUBLE_ARG1
);
85 assert (regs
->lr_vreg
[2].q
== FUNC_LDOUBLE_ARG2
);
86 assert (regs
->lr_vreg
[3].q
== FUNC_LDOUBLE_ARG3
);
87 assert (regs
->lr_vreg
[4].q
== FUNC_LDOUBLE_ARG4
);
88 assert (regs
->lr_vreg
[5].q
== FUNC_LDOUBLE_ARG5
);
89 assert (regs
->lr_vreg
[6].q
== FUNC_LDOUBLE_ARG6
);
90 assert (regs
->lr_vreg
[7].q
== FUNC_LDOUBLE_ARG7
);
95 assert (regs
->lr_vpcs
== 0);
97 /* Clobber the q registers on exit. */
99 asm volatile ("dup v0.8b, %w0" : : "r" (v
) : "v0");
100 asm volatile ("dup v1.8b, %w0" : : "r" (v
) : "v1");
101 asm volatile ("dup v2.8b, %w0" : : "r" (v
) : "v2");
102 asm volatile ("dup v3.8b, %w0" : : "r" (v
) : "v3");
103 asm volatile ("dup v4.8b, %w0" : : "r" (v
) : "v4");
104 asm volatile ("dup v5.8b, %w0" : : "r" (v
) : "v5");
105 asm volatile ("dup v6.8b, %w0" : : "r" (v
) : "v6");
106 asm volatile ("dup v7.8b, %w0" : : "r" (v
) : "v7");
110 return sym
->st_value
;
114 la_aarch64_gnu_pltexit (ElfW(Sym
) *sym
, unsigned int ndx
, uintptr_t *refcook
,
116 const struct La_aarch64_regs
*inregs
,
117 struct La_aarch64_retval
*outregs
,
120 printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u\n",
121 symname
, (long int) sym
->st_value
, ndx
);
123 if (strcmp (symname
, "tst_audit27_func_float") == 0)
125 assert (inregs
->lr_vreg
[0].s
== FUNC_FLOAT_ARG0
);
126 assert (inregs
->lr_vreg
[1].s
== FUNC_FLOAT_ARG1
);
127 assert (inregs
->lr_vreg
[2].s
== FUNC_FLOAT_ARG2
);
128 assert (inregs
->lr_vreg
[3].s
== FUNC_FLOAT_ARG3
);
129 assert (inregs
->lr_vreg
[4].s
== FUNC_FLOAT_ARG4
);
130 assert (inregs
->lr_vreg
[5].s
== FUNC_FLOAT_ARG5
);
131 assert (inregs
->lr_vreg
[6].s
== FUNC_FLOAT_ARG6
);
132 assert (inregs
->lr_vreg
[7].s
== FUNC_FLOAT_ARG7
);
134 assert (outregs
->lrv_vreg
[0].s
== FUNC_FLOAT_RET
);
136 else if (strcmp (symname
, "tst_audit27_func_double") == 0)
138 assert (inregs
->lr_vreg
[0].d
== FUNC_DOUBLE_ARG0
);
139 assert (inregs
->lr_vreg
[1].d
== FUNC_DOUBLE_ARG1
);
140 assert (inregs
->lr_vreg
[2].d
== FUNC_DOUBLE_ARG2
);
141 assert (inregs
->lr_vreg
[3].d
== FUNC_DOUBLE_ARG3
);
142 assert (inregs
->lr_vreg
[4].d
== FUNC_DOUBLE_ARG4
);
143 assert (inregs
->lr_vreg
[5].d
== FUNC_DOUBLE_ARG5
);
144 assert (inregs
->lr_vreg
[6].d
== FUNC_DOUBLE_ARG6
);
145 assert (inregs
->lr_vreg
[7].d
== FUNC_DOUBLE_ARG7
);
147 assert (outregs
->lrv_vreg
[0].d
== FUNC_DOUBLE_RET
);
149 else if (strcmp (symname
, "tst_audit27_func_ldouble") == 0)
151 assert (inregs
->lr_vreg
[0].q
== FUNC_LDOUBLE_ARG0
);
152 assert (inregs
->lr_vreg
[1].q
== FUNC_LDOUBLE_ARG1
);
153 assert (inregs
->lr_vreg
[2].q
== FUNC_LDOUBLE_ARG2
);
154 assert (inregs
->lr_vreg
[3].q
== FUNC_LDOUBLE_ARG3
);
155 assert (inregs
->lr_vreg
[4].q
== FUNC_LDOUBLE_ARG4
);
156 assert (inregs
->lr_vreg
[5].q
== FUNC_LDOUBLE_ARG5
);
157 assert (inregs
->lr_vreg
[6].q
== FUNC_LDOUBLE_ARG6
);
158 assert (inregs
->lr_vreg
[7].q
== FUNC_LDOUBLE_ARG7
);
160 assert (outregs
->lrv_vreg
[0].q
== FUNC_LDOUBLE_RET
);
165 assert (inregs
->lr_vpcs
== 0);
166 assert (outregs
->lrv_vpcs
== 0);
168 /* Clobber the q registers on exit. */
170 asm volatile ("dup v0.8b, %w0" : : "r" (v
) : "v0");
171 asm volatile ("dup v1.8b, %w0" : : "r" (v
) : "v1");
172 asm volatile ("dup v2.8b, %w0" : : "r" (v
) : "v2");
173 asm volatile ("dup v3.8b, %w0" : : "r" (v
) : "v3");
174 asm volatile ("dup v4.8b, %w0" : : "r" (v
) : "v4");
175 asm volatile ("dup v5.8b, %w0" : : "r" (v
) : "v5");
176 asm volatile ("dup v6.8b, %w0" : : "r" (v
) : "v6");
177 asm volatile ("dup v7.8b, %w0" : : "r" (v
) : "v7");