elf: Ignore LD_LIBRARY_PATH and debug env var for setuid for static
[glibc.git] / sysdeps / aarch64 / tst-auditmod26.c
blobb87777bdac9415c5c41b29c0413506c0bf16f3ad
1 /* Check LD_AUDIT for aarch64 specific ABI.
2 Copyright (C) 2022-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 <assert.h>
20 #include <link.h>
21 #include <string.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include "tst-audit26mod.h"
26 #define TEST_NAME "tst-audit26"
28 #define AUDIT26_COOKIE 0
30 unsigned int
31 la_version (unsigned int v)
33 return v;
36 unsigned int
37 la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
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;
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)
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_audit26_func") == 0)
61 assert (regs->lr_xreg[0] == ARG1);
62 assert (regs->lr_xreg[1] == ARG2);
63 assert (regs->lr_xreg[2] == ARG3);
65 else
66 abort ();
68 assert (regs->lr_vpcs == 0);
70 /* Clobber 'x8'. */
71 asm volatile ("mov x8, -1" : : : "x8");
73 *framesizep = 1024;
75 return sym->st_value;
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)
84 printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u\n",
85 symname, (long int) sym->st_value, ndx);
87 if (strcmp (symname, "tst_audit26_func") == 0)
89 assert (inregs->lr_xreg[0] == ARG1);
90 assert (inregs->lr_xreg[1] == ARG2);
91 assert (inregs->lr_xreg[2] == ARG3);
93 else
94 abort ();
96 assert (inregs->lr_vpcs == 0);
97 assert (outregs->lrv_vpcs == 0);
99 /* Clobber 'x8'. */
100 asm volatile ("mov x8, -1" : : : "x8");
102 return 0;