glibc/sysdeps/s390/tst-dl-runtime.c
Paul Eggert 581c785bf3 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 7061 files FOO.

I then removed trailing white space from math/tgmath.h,
support/tst-support-open-dev-null-range.c, and
sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following
obscure pre-commit check failure diagnostics from Savannah.  I don't
know why I run into these diagnostics whereas others evidently do not.

remote: *** 912-#endif
remote: *** 913:
remote: *** 914-
remote: *** error: lines with trailing whitespace found
...
remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2022-01-01 11:40:24 -08:00

92 lines
2.5 KiB
C

/* Test that lazy binding does not clobber r0.
Copyright (C) 2018-2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#if defined (__s390x__)
static const unsigned long magic_value = 0x0011223344556677UL;
#else
static const unsigned long magic_value = 0x00112233;
#endif
unsigned long r0x2_trampoline (unsigned long);
/* Invoke r0x2, which doubles the value in r0. If we get
value * 2 back, this means nothing clobbers r0, particularly,
_dl_runtime_resolve and _dl_runtime_profile. */
asm (" .type r0x2_trampoline, @function\n"
"r0x2_trampoline:\n"
#if defined (__s390x__)
" lgr %r0,%r2\n"
" stg %r14,112(%r15)\n"
" aghi %r15,-160\n"
" brasl %r14,r0x2@plt\n"
" aghi %r15,160\n"
" lg %r14,112(%r15)\n"
" lgr %r2,%r0\n"
" br %r14\n"
#elif defined (__zarch__)
" lr %r0,%r2\n"
" st %r14,56(%r15)\n"
" ahi %r15,-96\n"
" brasl %r14,r0x2@plt\n"
" ahi %r15,96\n"
" l %r14,56(%r15)\n"
" lr %r2,%r0\n"
" br %r14\n"
#else
" lr %r0,%r2\n"
" st %r14,56(%r15)\n"
" ahi %r15,-96\n"
" balr %r14,0\n"
" l %r14,1f-.(%r14)\n"
" basr %r14,%r14\n"
" ahi %r15,96\n"
" l %r14,56(%r15)\n"
" lr %r2,%r0\n"
" br %r14\n"
"1: .long r0x2\n"
#endif
);
static int
do_test (void)
{
int i;
unsigned long r0;
const char *run;
for (i = 0; i < 2; i++)
{
run = (i == 0) ? "lazy" : "non-lazy";
r0 = magic_value;
printf ("-> %s r0 = 0x%lx\n", run, r0);
r0 = r0x2_trampoline (r0);
printf ("<- %s r0 * 2 = 0x%lx\n", run, r0);
if (r0 != magic_value * 2)
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
#include <support/test-driver.c>