|
Packit |
6c4009 |
/* Test case for i386 preserved registers in dynamic linker.
|
|
Packit |
6c4009 |
Copyright (C) 2015-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <dlfcn.h>
|
|
Packit |
6c4009 |
#include <stdint.h>
|
|
Packit |
6c4009 |
#include <stdio.h>
|
|
Packit |
6c4009 |
#include <stdlib.h>
|
|
Packit |
6c4009 |
#include <stddef.h>
|
|
Packit |
6c4009 |
#include <string.h>
|
|
Packit |
6c4009 |
#include <unistd.h>
|
|
Packit |
6c4009 |
#include <link.h>
|
|
Packit |
6c4009 |
#include <bits/wordsize.h>
|
|
Packit |
6c4009 |
#include <gnu/lib-names.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
unsigned int
|
|
Packit |
6c4009 |
la_version (unsigned int v)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
setlinebuf (stdout);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
printf ("version: %u\n", v);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
char buf[20];
|
|
Packit |
6c4009 |
sprintf (buf, "%u", v);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return v;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
void
|
|
Packit |
6c4009 |
la_activity (uintptr_t *cookie, unsigned int flag)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
const char *flagstr;
|
|
Packit |
6c4009 |
switch (flag)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
case LA_ACT_CONSISTENT:
|
|
Packit |
6c4009 |
flagstr = "consistent";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_ACT_ADD:
|
|
Packit |
6c4009 |
flagstr = "add";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_ACT_DELETE:
|
|
Packit |
6c4009 |
flagstr = "delete";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
default:
|
|
Packit |
6c4009 |
printf ("activity: unknown activity %u\n", flag);
|
|
Packit |
6c4009 |
return;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
printf ("activity: %s\n", flagstr);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
char *
|
|
Packit |
6c4009 |
la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
const char *flagstr;
|
|
Packit |
6c4009 |
switch (flag)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
case LA_SER_ORIG:
|
|
Packit |
6c4009 |
flagstr = "LA_SET_ORIG";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_SER_LIBPATH:
|
|
Packit |
6c4009 |
flagstr = "LA_SER_LIBPATH";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_SER_RUNPATH:
|
|
Packit |
6c4009 |
flagstr = "LA_SER_RUNPATH";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_SER_CONFIG:
|
|
Packit |
6c4009 |
flagstr = "LA_SER_CONFIG";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_SER_DEFAULT:
|
|
Packit |
6c4009 |
flagstr = "LA_SER_DEFAULT";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
case LA_SER_SECURE:
|
|
Packit |
6c4009 |
flagstr = "LA_SER_SECURE";
|
|
Packit |
6c4009 |
break;
|
|
Packit |
6c4009 |
default:
|
|
Packit |
6c4009 |
printf ("objsearch: %s, unknown flag %d\n", name, flag);
|
|
Packit |
6c4009 |
return (char *) name;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
printf ("objsearch: %s, %s\n", name, flagstr);
|
|
Packit |
6c4009 |
return (char *) name;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
unsigned int
|
|
Packit |
6c4009 |
la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("objopen: %ld, %s\n", lmid, l->l_name);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return 3;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
void
|
|
Packit |
6c4009 |
la_preinit (uintptr_t *cookie)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("preinit\n");
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
unsigned int
|
|
Packit |
6c4009 |
la_objclose (uintptr_t *cookie)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("objclose\n");
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
uintptr_t
|
|
Packit |
6c4009 |
la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit |
6c4009 |
uintptr_t *defcook, unsigned int *flags, const char *symname)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("symbind32: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
|
|
Packit |
6c4009 |
symname, (long int) sym->st_value, ndx, *flags);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return sym->st_value;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include "tst-audit.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ElfW(Addr)
|
|
Packit |
6c4009 |
pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit |
6c4009 |
uintptr_t *defcook, La_regs *regs, unsigned int *flags,
|
|
Packit |
6c4009 |
const char *symname, long int *framesizep)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
|
|
Packit |
6c4009 |
symname, (long int) sym->st_value, ndx, *flags);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (strcmp (symname, "audit1_test") == 0
|
|
Packit |
6c4009 |
|| strcmp (symname, "audit2_test") == 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (regs->lr_eax != 1
|
|
Packit |
6c4009 |
|| regs->lr_edx != 2
|
|
Packit |
6c4009 |
|| regs->lr_ecx != 3)
|
|
Packit |
6c4009 |
abort ();
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
*framesizep = 200;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return sym->st_value;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
unsigned int
|
|
Packit |
6c4009 |
pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit |
6c4009 |
uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
|
|
Packit |
6c4009 |
const char *symname)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
|
|
Packit |
6c4009 |
symname, (long int) sym->st_value, ndx,
|
|
Packit |
6c4009 |
(ptrdiff_t) outregs->int_retval);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (strcmp (symname, "audit1_test") == 0
|
|
Packit |
6c4009 |
|| strcmp (symname, "audit2_test") == 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (inregs->lr_eax != 1
|
|
Packit |
6c4009 |
|| inregs->lr_edx != 2
|
|
Packit |
6c4009 |
|| inregs->lr_ecx != 3)
|
|
Packit |
6c4009 |
abort ();
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (strcmp (symname, "audit1_test") == 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
long long x = ((unsigned long long) outregs->lrv_eax
|
|
Packit |
6c4009 |
| (unsigned long long) outregs->lrv_edx << 32);
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
if (x != 30)
|
|
Packit |
6c4009 |
abort ();
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
else if (strcmp (symname, "audit2_test") == 0)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
if (outregs->lrv_st0 != 30)
|
|
Packit |
6c4009 |
abort ();
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|