1 /* Test that variant PCS calls don't clobber registers with lazy binding.
2 Copyright (C) 2020-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 <support/check.h>
32 /* Gives the registers in the caller and callee around a variant PCS call.
33 Most registers are initialized from BEFORE in the caller so they can
34 have values that likely show clobbers. Register state extensions such
35 as SVE is not covered here, only the base registers. */
36 void vpcs_call_regs (struct regs
*after
, struct regs
*before
);
41 struct regs before
, after
;
44 unsigned char *p
= (unsigned char *)&before
;
45 for (int i
= 0; i
< sizeof before
; i
++)
48 vpcs_call_regs (&after
, &before
);
50 for (int i
= 0; i
< 32; i
++)
51 if (before
.x
[i
] != after
.x
[i
])
53 if (i
== 16 || i
== 17)
54 /* Variant PCS allows clobbering x16 and x17. */
57 printf ("x%d: before: 0x%016llx after: 0x%016llx\n",
59 (unsigned long long)before
.x
[i
],
60 (unsigned long long)after
.x
[i
]);
62 for (int i
= 0; i
< 64; i
++)
63 if (before
.v
.u
[i
] != after
.v
.u
[i
])
66 printf ("v%d: before: 0x%016llx %016llx after: 0x%016llx %016llx\n",
68 (unsigned long long)before
.v
.u
[2*(i
/2)+1],
69 (unsigned long long)before
.v
.u
[2*(i
/2)],
70 (unsigned long long)after
.v
.u
[2*(i
/2)+1],
71 (unsigned long long)after
.v
.u
[2*(i
/2)]);
74 FAIL_EXIT1 ("The variant PCS call clobbered %d registers.\n", err
);
78 #include <support/test-driver.c>