From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH v2 15/16] dlfcn: Eliminate GLIBC_PRIVATE dependency from tststatic2
Date: Mon, 31 May 2021 16:12:36 +0200 [thread overview]
Message-ID: <66fdbeb88347a0f07f1185e3294bbc78ded0d370.1622469909.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1622469908.git.fweimer@redhat.com>
The test appears to use _dlfcn_hook@@GLIBC_PRIVATE as a way to
test dlvsym without having to know the appropriate symbol version.
With <first-versions.h>, we can use a public symbol and the symbol
version at which it was defined first.
---
dlfcn/modstatic2.c | 10 +++++++++-
dlfcn/tststatic2.c | 10 +++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlfcn/modstatic2.c b/dlfcn/modstatic2.c
index 9b5aae8b9f..02d561a7b0 100644
--- a/dlfcn/modstatic2.c
+++ b/dlfcn/modstatic2.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <gnu/lib-names.h>
+#include <first-versions.h>
int test (FILE *out, int a);
@@ -117,11 +118,18 @@ test (FILE *out, int a)
exit (1);
}
- if (dlvsym (handle2, "_dlfcn_hook", "GLIBC_PRIVATE") == NULL)
+ /* _exit is very unlikely to receive a second symbol version. */
+ void *exit_ptr = dlvsym (handle2, "_exit", FIRST_VERSION_libc__exit_STRING);
+ if (exit_ptr == NULL)
{
fprintf (out, "dlvsym: %s\n", dlerror ());
exit (1);
}
+ if (exit_ptr != dlsym (handle2, "_exit"))
+ {
+ fprintf (out, "dlvsym for _exit does not match dlsym\n");
+ exit (1);
+ }
void *(*dlsymfn) (void *, const char *);
dlsymfn = dlsym (handle2, "dlsym");
diff --git a/dlfcn/tststatic2.c b/dlfcn/tststatic2.c
index f8cd5a964b..5d8a7831b2 100644
--- a/dlfcn/tststatic2.c
+++ b/dlfcn/tststatic2.c
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <gnu/lib-names.h>
+#include <first-versions.h>
static int
do_test (void)
@@ -115,11 +116,18 @@ do_test (void)
exit (1);
}
- if (dlvsym (handle2, "_dlfcn_hook", "GLIBC_PRIVATE") == NULL)
+ /* _exit is very unlikely to receive a second symbol version. */
+ void *exit_ptr = dlvsym (handle2, "_exit", FIRST_VERSION_libc__exit_STRING);
+ if (exit_ptr == NULL)
{
printf ("dlvsym: %s\n", dlerror ());
exit (1);
}
+ if (exit_ptr != dlsym (handle2, "_exit"))
+ {
+ printf ("dlvsym for _exit does not match dlsym\n");
+ exit (1);
+ }
void *(*dlsymfn) (void *, const char *);
dlsymfn = dlsym (handle2, "dlsym");
--
2.31.1
next prev parent reply other threads:[~2021-05-31 14:12 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-31 14:10 [PATCH v3 00/16] Move libdl into libc Florian Weimer
2021-05-31 14:11 ` [PATCH v2 01/16] stdio-common: Remove _IO_vfwscanf Florian Weimer
2021-05-31 19:42 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH 02/16] Add missing symbols to Version files Florian Weimer
2021-06-01 19:12 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH 03/16] scripts/versions.awk: Add local: * to all version nodes Florian Weimer
2021-06-01 19:23 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH v2 04/16] Add libc ABI extension kludge for baseline-violating libdl symbols Florian Weimer
2021-06-01 19:31 ` Adhemerval Zanella
2021-06-01 19:34 ` Florian Weimer
2021-06-01 19:38 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH 05/16] dlfcn: Move dlerror into libc Florian Weimer
2021-06-01 19:36 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH 06/16] dlfcn: Move dlclose " Florian Weimer
2021-06-02 12:58 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH 07/16] dlfcn: Move dladdr " Florian Weimer
2021-06-02 14:02 ` Adhemerval Zanella
2021-05-31 14:11 ` [PATCH 08/16] dlfcn: Move dlsym " Florian Weimer
2021-06-02 14:12 ` Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 09/16] dlfcn: Move dlmopen " Florian Weimer
2021-06-02 14:19 ` Adhemerval Zanella
2021-06-02 14:37 ` Florian Weimer
2021-06-02 14:43 ` Adhemerval Zanella
2021-06-02 17:49 ` Florian Weimer
2021-06-02 18:00 ` Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 10/16] dlfcn: Move dladdr1 " Florian Weimer
2021-06-02 14:29 ` Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 11/16] dlfcn: Move dlinfo " Florian Weimer
2021-06-02 14:31 ` Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 12/16] dlfcn: Move dlvsym " Florian Weimer
2021-06-02 14:34 ` Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 13/16] dlfcn: Move dlopen " Florian Weimer
2021-06-02 14:54 ` Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 14/16] dlfcn: Cleanups after -ldl is no longer required Florian Weimer
2021-06-02 18:08 ` Adhemerval Zanella
2021-05-31 14:12 ` Florian Weimer [this message]
2021-06-02 18:09 ` [PATCH v2 15/16] dlfcn: Eliminate GLIBC_PRIVATE dependency from tststatic2 Adhemerval Zanella
2021-05-31 14:12 ` [PATCH 16/16] dlfcn: Rework static dlopen hooks Florian Weimer
2021-06-02 19:18 ` Adhemerval Zanella
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=66fdbeb88347a0f07f1185e3294bbc78ded0d370.1622469909.git.fweimer@redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/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).