From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org, Szabolcs Nagy <szabolcs.nagy@arm.com>,
Florian Weimer <fweimer@redhat.com>
Subject: Re: [PATCH v6 3/4] linux: Add a getauxval test [BZ #23293]
Date: Fri, 13 May 2022 17:21:28 -0300 [thread overview]
Message-ID: <f2d0e1ee-3828-ac78-4a91-8587a9232830@linaro.org> (raw)
In-Reply-To: <7b79ffb5ec178813653763651aa46403afd49cc2.1651757640.git.szabolcs.nagy@arm.com>
On 05/05/2022 10:59, Szabolcs Nagy via Libc-alpha wrote:
> This is for bug 23293 and it relies on the glibc test system running
> tests via explicit ld.so invokation by default.
I think it is 'invocation'.
>
> Reviewed-by: Florian Weimer <fweimer@redhat.com>
LGTM as well.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> ---
> v4:
> - New patch.
> ---
> sysdeps/unix/sysv/linux/Makefile | 1 +
> sysdeps/unix/sysv/linux/tst-getauxval.c | 74 +++++++++++++++++++++++++
> 2 files changed, 75 insertions(+)
> create mode 100644 sysdeps/unix/sysv/linux/tst-getauxval.c
>
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index ca953804d0..89cb005c7d 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -126,6 +126,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \
> tst-prctl \
> tst-scm_rights \
> tst-epoll \
> + tst-getauxval \
> # tests
>
> # For +depfiles in Makerules.
> diff --git a/sysdeps/unix/sysv/linux/tst-getauxval.c b/sysdeps/unix/sysv/linux/tst-getauxval.c
> new file mode 100644
> index 0000000000..c4b6195743
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/tst-getauxval.c
> @@ -0,0 +1,74 @@
> +/* Basic test for getauxval.
> + Copyright (C) 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 <unistd.h>
> +#include <stdio.h>
> +#include <support/check.h>
> +#include <sys/auxv.h>
> +
> +static int missing;
> +static int mismatch;
> +
> +static void
> +check_nonzero (unsigned long t, const char *s)
> +{
> + unsigned long v = getauxval (t);
> + printf ("%s: %lu (0x%lx)\n", s, v, v);
> + if (v == 0)
> + missing++;
> +}
> +
> +static void
> +check_eq (unsigned long t, const char *s, unsigned long want)
> +{
> + unsigned long v = getauxval (t);
> + printf ("%s: %lu want: %lu\n", s, v, want);
> + if (v != want)
> + mismatch++;
> +}
> +
> +#define NZ(x) check_nonzero (x, #x)
> +#define EQ(x, want) check_eq (x, #x, want)
> +
> +static int
> +do_test (void)
> +{
> + /* These auxv entries should be non-zero on Linux. */
> + NZ (AT_PHDR);
> + NZ (AT_PHENT);
> + NZ (AT_PHNUM);
> + NZ (AT_PAGESZ);
> + NZ (AT_ENTRY);
> + NZ (AT_CLKTCK);
> + NZ (AT_RANDOM);
> + NZ (AT_EXECFN);
> + if (missing)
> + FAIL_EXIT1 ("Found %d missing auxv entries.\n", missing);
> +
> + /* Check against syscalls. */
> + EQ (AT_UID, getuid ());
> + EQ (AT_EUID, geteuid ());
> + EQ (AT_GID, getgid ());
> + EQ (AT_EGID, getegid ());
> + if (mismatch)
> + FAIL_EXIT1 ("Found %d mismatching auxv entries.\n", mismatch);
> +
> + return 0;
> +}
> +
> +#include <support/test-driver.c>
next prev parent reply other threads:[~2022-05-13 20:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 13:58 [PATCH v6 0/4] Args adjustment with ./ld.so exe " Szabolcs Nagy
2022-05-05 13:58 ` [PATCH v6 1/4] rtld: Use generic argv adjustment in ld.so " Szabolcs Nagy
2022-05-13 19:56 ` Adhemerval Zanella
2022-05-17 9:27 ` Szabolcs Nagy
2022-05-05 13:58 ` [PATCH v6 2/4] rtld: Remove DL_ARGV_NOT_RELRO and make _dl_skip_args const Szabolcs Nagy
2022-05-13 20:14 ` Adhemerval Zanella
2022-05-05 13:59 ` [PATCH v6 3/4] linux: Add a getauxval test [BZ #23293] Szabolcs Nagy
2022-05-13 20:21 ` Adhemerval Zanella [this message]
2022-05-05 13:59 ` [PATCH v6 4/4] aarch64: Move ld.so _start to separate file and drop _dl_skip_args Szabolcs Nagy
2022-05-13 20:46 ` Adhemerval Zanella
2022-05-06 10:07 ` [PATCH v6 0/4] Args adjustment with ./ld.so exe [BZ #23293] Szabolcs Nagy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2d0e1ee-3828-ac78-4a91-8587a9232830@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=szabolcs.nagy@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).