]>
Commit | Line | Data |
---|---|---|
ce9a68c5 BW |
1 | /* Check LD_AUDIT for aarch64 specific ABI. |
2 | Copyright (C) 2022 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
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/>. */ | |
18 | ||
19 | #include <assert.h> | |
20 | #include <link.h> | |
21 | #include <string.h> | |
22 | #include <stdio.h> | |
23 | #include <stdlib.h> | |
24 | #include "tst-audit26mod.h" | |
25 | ||
26 | #define TEST_NAME "tst-audit26" | |
27 | ||
28 | #define AUDIT26_COOKIE 0 | |
29 | ||
30 | unsigned int | |
31 | la_version (unsigned int v) | |
32 | { | |
33 | return v; | |
34 | } | |
35 | ||
36 | unsigned int | |
37 | la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie) | |
38 | { | |
39 | const char *p = strrchr (map->l_name, '/'); | |
40 | const char *l_name = p == NULL ? map->l_name : p + 1; | |
41 | uintptr_t ck = -1; | |
42 | if (strncmp (l_name, TEST_NAME, strlen (TEST_NAME)) == 0) | |
43 | ck = AUDIT26_COOKIE; | |
44 | *cookie = ck; | |
45 | printf ("objopen: %ld, %s [cookie=%ld]\n", lmid, l_name, ck); | |
46 | return ck == -1 ? 0 : LA_FLG_BINDFROM | LA_FLG_BINDTO; | |
47 | } | |
48 | ||
49 | ElfW(Addr) | |
50 | la_aarch64_gnu_pltenter (ElfW(Sym) *sym __attribute__ ((unused)), | |
51 | unsigned int ndx __attribute__ ((unused)), | |
52 | uintptr_t *refcook, uintptr_t *defcook, | |
53 | La_aarch64_regs *regs, unsigned int *flags, | |
54 | const char *symname, long int *framesizep) | |
55 | { | |
56 | printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n", | |
57 | symname, (long int) sym->st_value, ndx, *flags); | |
58 | ||
59 | if (strcmp (symname, "tst_audit26_func") == 0) | |
60 | { | |
61 | assert (regs->lr_xreg[0] == ARG1); | |
62 | assert (regs->lr_xreg[1] == ARG2); | |
63 | assert (regs->lr_xreg[2] == ARG3); | |
64 | } | |
65 | else | |
66 | abort (); | |
67 | ||
68 | assert (regs->lr_vpcs == 0); | |
69 | ||
70 | /* Clobber 'x8'. */ | |
71 | asm volatile ("mov x8, -1" : : : "x8"); | |
72 | ||
73 | *framesizep = 1024; | |
74 | ||
75 | return sym->st_value; | |
76 | } | |
77 | ||
78 | unsigned int | |
79 | la_aarch64_gnu_pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook, | |
80 | uintptr_t *defcook, | |
81 | const struct La_aarch64_regs *inregs, | |
82 | struct La_aarch64_retval *outregs, const char *symname) | |
83 | { | |
84 | printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u\n", | |
85 | symname, (long int) sym->st_value, ndx); | |
86 | ||
87 | if (strcmp (symname, "tst_audit26_func") == 0) | |
88 | { | |
89 | assert (inregs->lr_xreg[0] == ARG1); | |
90 | assert (inregs->lr_xreg[1] == ARG2); | |
91 | assert (inregs->lr_xreg[2] == ARG3); | |
92 | } | |
93 | else | |
94 | abort (); | |
95 | ||
96 | assert (inregs->lr_vpcs == 0); | |
97 | assert (outregs->lrv_vpcs == 0); | |
98 | ||
99 | /* Clobber 'x8'. */ | |
100 | asm volatile ("mov x8, -1" : : : "x8"); | |
101 | ||
102 | return 0; | |
103 | } |