|
|
c5d972 |
Added $(objpfx)tst-audit23: $(libdl) to elf/Makefile since
|
|
|
c5d972 |
we still need $(libdl) in RHEL8.
|
|
|
c5d972 |
|
|
|
c5d972 |
commit 5fa11a2bc94c912c3b25860065086902674537ba
|
|
|
c5d972 |
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
|
c5d972 |
Date: Mon Jan 24 10:46:15 2022 -0300
|
|
|
c5d972 |
|
|
|
c5d972 |
elf: Add la_activity during application exit
|
|
|
c5d972 |
|
|
|
c5d972 |
la_activity is not called during application exit, even though
|
|
|
c5d972 |
la_objclose is.
|
|
|
c5d972 |
|
|
|
c5d972 |
Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.
|
|
|
c5d972 |
|
|
|
c5d972 |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
c5d972 |
Tested-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
c5d972 |
|
|
|
c5d972 |
Conflicts:
|
|
|
c5d972 |
elf/Makefile
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/elf/Makefile b/elf/Makefile
|
|
|
c5d972 |
index 954cd08c199f5037..e4955c9f575f9015 100644
|
|
|
c5d972 |
--- a/elf/Makefile
|
|
|
c5d972 |
+++ b/elf/Makefile
|
|
|
c5d972 |
@@ -345,6 +345,7 @@ tests += \
|
|
|
c5d972 |
tst-audit2 \
|
|
|
c5d972 |
tst-audit20 \
|
|
|
c5d972 |
tst-audit22 \
|
|
|
c5d972 |
+ tst-audit23 \
|
|
|
c5d972 |
tst-audit8 \
|
|
|
c5d972 |
tst-audit9 \
|
|
|
c5d972 |
tst-auditmany \
|
|
|
c5d972 |
@@ -608,6 +609,7 @@ modules-names = \
|
|
|
c5d972 |
tst-audit13mod1 \
|
|
|
c5d972 |
tst-audit18mod \
|
|
|
c5d972 |
tst-audit19bmod \
|
|
|
c5d972 |
+ tst-audit23mod \
|
|
|
c5d972 |
tst-auditlogmod-1 \
|
|
|
c5d972 |
tst-auditlogmod-2 \
|
|
|
c5d972 |
tst-auditlogmod-3 \
|
|
|
c5d972 |
@@ -630,6 +632,7 @@ modules-names = \
|
|
|
c5d972 |
tst-auditmod19b \
|
|
|
c5d972 |
tst-auditmod20 \
|
|
|
c5d972 |
tst-auditmod22 \
|
|
|
c5d972 |
+ tst-auditmod23 \
|
|
|
c5d972 |
tst-big-note-lib \
|
|
|
c5d972 |
tst-deep1mod1 \
|
|
|
c5d972 |
tst-deep1mod2 \
|
|
|
c5d972 |
@@ -2041,6 +2044,11 @@ $(objpfx)tst-auditmod20.so: $(libdl)
|
|
|
c5d972 |
$(objpfx)tst-audit22.out: $(objpfx)tst-auditmod22.so
|
|
|
c5d972 |
tst-audit22-ARGS = -- $(host-test-program-cmd)
|
|
|
c5d972 |
|
|
|
c5d972 |
+$(objpfx)tst-audit23: $(libdl)
|
|
|
c5d972 |
+$(objpfx)tst-audit23.out: $(objpfx)tst-auditmod23.so \
|
|
|
c5d972 |
+ $(objpfx)tst-audit23mod.so
|
|
|
c5d972 |
+tst-audit23-ARGS = -- $(host-test-program-cmd)
|
|
|
c5d972 |
+
|
|
|
c5d972 |
# tst-sonamemove links against an older implementation of the library.
|
|
|
c5d972 |
LDFLAGS-tst-sonamemove-linkmod1.so = \
|
|
|
c5d972 |
-Wl,--version-script=tst-sonamemove-linkmod1.map \
|
|
|
c5d972 |
diff --git a/elf/dl-fini.c b/elf/dl-fini.c
|
|
|
c5d972 |
index e102d93647cb8c47..eea9d8aad736a99e 100644
|
|
|
c5d972 |
--- a/elf/dl-fini.c
|
|
|
c5d972 |
+++ b/elf/dl-fini.c
|
|
|
c5d972 |
@@ -63,6 +63,10 @@ _dl_fini (void)
|
|
|
c5d972 |
__rtld_lock_unlock_recursive (GL(dl_load_lock));
|
|
|
c5d972 |
else
|
|
|
c5d972 |
{
|
|
|
c5d972 |
+#ifdef SHARED
|
|
|
c5d972 |
+ _dl_audit_activity_nsid (ns, LA_ACT_DELETE);
|
|
|
c5d972 |
+#endif
|
|
|
c5d972 |
+
|
|
|
c5d972 |
/* Now we can allocate an array to hold all the pointers and
|
|
|
c5d972 |
copy the pointers in. */
|
|
|
c5d972 |
struct link_map *maps[nloaded];
|
|
|
c5d972 |
@@ -153,6 +157,10 @@ _dl_fini (void)
|
|
|
c5d972 |
/* Correct the previous increment. */
|
|
|
c5d972 |
--l->l_direct_opencount;
|
|
|
c5d972 |
}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+#ifdef SHARED
|
|
|
c5d972 |
+ _dl_audit_activity_nsid (ns, LA_ACT_CONSISTENT);
|
|
|
c5d972 |
+#endif
|
|
|
c5d972 |
}
|
|
|
c5d972 |
}
|
|
|
c5d972 |
|
|
|
c5d972 |
diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..4904cf1340a97ee1
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-audit23.c
|
|
|
c5d972 |
@@ -0,0 +1,239 @@
|
|
|
c5d972 |
+/* Check for expected la_objopen and la_objeclose for all objects.
|
|
|
c5d972 |
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
c5d972 |
+ This file is part of the GNU C Library.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
c5d972 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
c5d972 |
+ License as published by the Free Software Foundation; either
|
|
|
c5d972 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c5d972 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c5d972 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c5d972 |
+ Lesser General Public License for more details.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
c5d972 |
+ License along with the GNU C Library; if not, see
|
|
|
c5d972 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+#include <array_length.h>
|
|
|
c5d972 |
+#include <errno.h>
|
|
|
c5d972 |
+#include <getopt.h>
|
|
|
c5d972 |
+#include <link.h>
|
|
|
c5d972 |
+#include <limits.h>
|
|
|
c5d972 |
+#include <inttypes.h>
|
|
|
c5d972 |
+#include <gnu/lib-names.h>
|
|
|
c5d972 |
+#include <string.h>
|
|
|
c5d972 |
+#include <stdlib.h>
|
|
|
c5d972 |
+#include <support/capture_subprocess.h>
|
|
|
c5d972 |
+#include <support/check.h>
|
|
|
c5d972 |
+#include <support/xstdio.h>
|
|
|
c5d972 |
+#include <support/xdlfcn.h>
|
|
|
c5d972 |
+#include <support/support.h>
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static int restart;
|
|
|
c5d972 |
+#define CMDLINE_OPTIONS \
|
|
|
c5d972 |
+ { "restart", no_argument, &restart, 1 },
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static int
|
|
|
c5d972 |
+handle_restart (void)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ xdlopen ("tst-audit23mod.so", RTLD_NOW);
|
|
|
c5d972 |
+ xdlmopen (LM_ID_NEWLM, LIBC_SO, RTLD_NOW);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ return 0;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static inline bool
|
|
|
c5d972 |
+startswith (const char *str, const char *pre)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ size_t lenpre = strlen (pre);
|
|
|
c5d972 |
+ size_t lenstr = strlen (str);
|
|
|
c5d972 |
+ return lenstr >= lenpre && memcmp (pre, str, lenpre) == 0;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static inline bool
|
|
|
c5d972 |
+is_vdso (const char *str)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ return startswith (str, "linux-gate")
|
|
|
c5d972 |
+ || startswith (str, "linux-vdso");
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+static int
|
|
|
c5d972 |
+do_test (int argc, char *argv[])
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ /* We must have either:
|
|
|
c5d972 |
+ - One or four parameters left if called initially:
|
|
|
c5d972 |
+ + path to ld.so optional
|
|
|
c5d972 |
+ + "--library-path" optional
|
|
|
c5d972 |
+ + the library path optional
|
|
|
c5d972 |
+ + the application name */
|
|
|
c5d972 |
+ if (restart)
|
|
|
c5d972 |
+ return handle_restart ();
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ char *spargv[9];
|
|
|
c5d972 |
+ TEST_VERIFY_EXIT (((argc - 1) + 3) < array_length (spargv));
|
|
|
c5d972 |
+ int i = 0;
|
|
|
c5d972 |
+ for (; i < argc - 1; i++)
|
|
|
c5d972 |
+ spargv[i] = argv[i + 1];
|
|
|
c5d972 |
+ spargv[i++] = (char *) "--direct";
|
|
|
c5d972 |
+ spargv[i++] = (char *) "--restart";
|
|
|
c5d972 |
+ spargv[i] = NULL;
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ setenv ("LD_AUDIT", "tst-auditmod23.so", 0);
|
|
|
c5d972 |
+ struct support_capture_subprocess result
|
|
|
c5d972 |
+ = support_capture_subprogram (spargv[0], spargv);
|
|
|
c5d972 |
+ support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* The expected la_objopen/la_objclose:
|
|
|
c5d972 |
+ 1. executable
|
|
|
c5d972 |
+ 2. loader
|
|
|
c5d972 |
+ 3. libc.so
|
|
|
c5d972 |
+ 4. tst-audit23mod.so
|
|
|
c5d972 |
+ 5. libc.so (LM_ID_NEWLM).
|
|
|
c5d972 |
+ 6. vdso (optional and ignored). */
|
|
|
c5d972 |
+ enum { max_objs = 6 };
|
|
|
c5d972 |
+ struct la_obj_t
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ char *lname;
|
|
|
c5d972 |
+ uintptr_t laddr;
|
|
|
c5d972 |
+ Lmid_t lmid;
|
|
|
c5d972 |
+ bool closed;
|
|
|
c5d972 |
+ } objs[max_objs] = { [0 ... max_objs-1] = { .closed = false } };
|
|
|
c5d972 |
+ size_t nobjs = 0;
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* The expected namespaces are one for the audit module, one for the
|
|
|
c5d972 |
+ application, and another for the dlmopen on handle_restart. */
|
|
|
c5d972 |
+ enum { max_ns = 3 };
|
|
|
c5d972 |
+ uintptr_t acts[max_ns] = { 0 };
|
|
|
c5d972 |
+ size_t nacts = 0;
|
|
|
c5d972 |
+ int last_act = -1;
|
|
|
c5d972 |
+ uintptr_t last_act_cookie = -1;
|
|
|
c5d972 |
+ bool seen_first_objclose = false;
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ FILE *out = fmemopen (result.err.buffer, result.err.length, "r");
|
|
|
c5d972 |
+ TEST_VERIFY (out != NULL);
|
|
|
c5d972 |
+ char *buffer = NULL;
|
|
|
c5d972 |
+ size_t buffer_length = 0;
|
|
|
c5d972 |
+ while (xgetline (&buffer, &buffer_length, out))
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ if (startswith (buffer, "la_activity: "))
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ uintptr_t cookie;
|
|
|
c5d972 |
+ int this_act;
|
|
|
c5d972 |
+ int r = sscanf (buffer, "la_activity: %d %"SCNxPTR"", &this_act,
|
|
|
c5d972 |
+ &cookie);
|
|
|
c5d972 |
+ TEST_COMPARE (r, 2);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* The cookie identifies the object at the head of the link map,
|
|
|
c5d972 |
+ so we only add a new namespace if it changes from the previous
|
|
|
c5d972 |
+ one. This works since dlmopen is the last in the test body. */
|
|
|
c5d972 |
+ if (cookie != last_act_cookie && last_act_cookie != -1)
|
|
|
c5d972 |
+ TEST_COMPARE (last_act, LA_ACT_CONSISTENT);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ if (this_act == LA_ACT_ADD && acts[nacts] != cookie)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ acts[nacts++] = cookie;
|
|
|
c5d972 |
+ last_act_cookie = cookie;
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ /* The LA_ACT_DELETE is called in the reverse order of LA_ACT_ADD
|
|
|
c5d972 |
+ at program termination (if the tests adds a dlclose or a library
|
|
|
c5d972 |
+ with extra dependencies this will need to be adapted). */
|
|
|
c5d972 |
+ else if (this_act == LA_ACT_DELETE)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ last_act_cookie = acts[--nacts];
|
|
|
c5d972 |
+ TEST_COMPARE (acts[nacts], cookie);
|
|
|
c5d972 |
+ acts[nacts] = 0;
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ else if (this_act == LA_ACT_CONSISTENT)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ TEST_COMPARE (cookie, last_act_cookie);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* LA_ACT_DELETE must always be followed by an la_objclose. */
|
|
|
c5d972 |
+ if (last_act == LA_ACT_DELETE)
|
|
|
c5d972 |
+ TEST_COMPARE (seen_first_objclose, true);
|
|
|
c5d972 |
+ else
|
|
|
c5d972 |
+ TEST_COMPARE (last_act, LA_ACT_ADD);
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ last_act = this_act;
|
|
|
c5d972 |
+ seen_first_objclose = false;
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ else if (startswith (buffer, "la_objopen: "))
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ char *lname;
|
|
|
c5d972 |
+ uintptr_t laddr;
|
|
|
c5d972 |
+ Lmid_t lmid;
|
|
|
c5d972 |
+ uintptr_t cookie;
|
|
|
c5d972 |
+ int r = sscanf (buffer, "la_objopen: %"SCNxPTR" %ms %"SCNxPTR" %ld",
|
|
|
c5d972 |
+ &cookie, &lname, &laddr, &lmid);
|
|
|
c5d972 |
+ TEST_COMPARE (r, 4);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* la_objclose is not triggered by vDSO because glibc does not
|
|
|
c5d972 |
+ unload it. */
|
|
|
c5d972 |
+ if (is_vdso (lname))
|
|
|
c5d972 |
+ continue;
|
|
|
c5d972 |
+ if (nobjs == max_objs)
|
|
|
c5d972 |
+ FAIL_EXIT1 ("non expected la_objopen: %s %"PRIxPTR" %ld",
|
|
|
c5d972 |
+ lname, laddr, lmid);
|
|
|
c5d972 |
+ objs[nobjs].lname = lname;
|
|
|
c5d972 |
+ objs[nobjs].laddr = laddr;
|
|
|
c5d972 |
+ objs[nobjs].lmid = lmid;
|
|
|
c5d972 |
+ objs[nobjs].closed = false;
|
|
|
c5d972 |
+ nobjs++;
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* This indirectly checks that la_objopen always comes before
|
|
|
c5d972 |
+ la_objclose btween la_activity calls. */
|
|
|
c5d972 |
+ seen_first_objclose = false;
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ else if (startswith (buffer, "la_objclose: "))
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ char *lname;
|
|
|
c5d972 |
+ uintptr_t laddr;
|
|
|
c5d972 |
+ Lmid_t lmid;
|
|
|
c5d972 |
+ uintptr_t cookie;
|
|
|
c5d972 |
+ int r = sscanf (buffer, "la_objclose: %"SCNxPTR" %ms %"SCNxPTR" %ld",
|
|
|
c5d972 |
+ &cookie, &lname, &laddr, &lmid);
|
|
|
c5d972 |
+ TEST_COMPARE (r, 4);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ for (size_t i = 0; i < nobjs; i++)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ if (strcmp (lname, objs[i].lname) == 0 && lmid == objs[i].lmid)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ TEST_COMPARE (objs[i].closed, false);
|
|
|
c5d972 |
+ objs[i].closed = true;
|
|
|
c5d972 |
+ break;
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* la_objclose should be called after la_activity(LA_ACT_DELETE) for
|
|
|
c5d972 |
+ the closed object's namespace. */
|
|
|
c5d972 |
+ TEST_COMPARE (last_act, LA_ACT_DELETE);
|
|
|
c5d972 |
+ if (!seen_first_objclose)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ TEST_COMPARE (last_act_cookie, cookie);
|
|
|
c5d972 |
+ seen_first_objclose = true;
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ for (size_t i = 0; i < nobjs; i++)
|
|
|
c5d972 |
+ {
|
|
|
c5d972 |
+ TEST_COMPARE (objs[i].closed, true);
|
|
|
c5d972 |
+ free (objs[i].lname);
|
|
|
c5d972 |
+ }
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ /* la_activity(LA_ACT_CONSISTENT) should be the last callback received.
|
|
|
c5d972 |
+ Since only one link map may be not-CONSISTENT at a time, this also
|
|
|
c5d972 |
+ ensures la_activity(LA_ACT_CONSISTENT) is the last callback received
|
|
|
c5d972 |
+ for every namespace. */
|
|
|
c5d972 |
+ TEST_COMPARE (last_act, LA_ACT_CONSISTENT);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ free (buffer);
|
|
|
c5d972 |
+ xfclose (out);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ return 0;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+#define TEST_FUNCTION_ARGV do_test
|
|
|
c5d972 |
+#include <support/test-driver.c>
|
|
|
c5d972 |
diff --git a/elf/tst-audit23mod.c b/elf/tst-audit23mod.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..30315687037d25e8
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-audit23mod.c
|
|
|
c5d972 |
@@ -0,0 +1,23 @@
|
|
|
c5d972 |
+/* Extra module for tst-audit23
|
|
|
c5d972 |
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
c5d972 |
+ This file is part of the GNU C Library.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
c5d972 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
c5d972 |
+ License as published by the Free Software Foundation; either
|
|
|
c5d972 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c5d972 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c5d972 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c5d972 |
+ Lesser General Public License for more details.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
c5d972 |
+ License along with the GNU C Library; if not, see
|
|
|
c5d972 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+int
|
|
|
c5d972 |
+foo (void)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ return 0;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
diff --git a/elf/tst-auditmod23.c b/elf/tst-auditmod23.c
|
|
|
c5d972 |
new file mode 100644
|
|
|
c5d972 |
index 0000000000000000..d7c60d7a5cbc4f8a
|
|
|
c5d972 |
--- /dev/null
|
|
|
c5d972 |
+++ b/elf/tst-auditmod23.c
|
|
|
c5d972 |
@@ -0,0 +1,74 @@
|
|
|
c5d972 |
+/* Audit module loaded by tst-audit23.
|
|
|
c5d972 |
+ Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
c5d972 |
+ This file is part of the GNU C Library.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
c5d972 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
c5d972 |
+ License as published by the Free Software Foundation; either
|
|
|
c5d972 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
c5d972 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c5d972 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c5d972 |
+ Lesser General Public License for more details.
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
c5d972 |
+ License along with the GNU C Library; if not, see
|
|
|
c5d972 |
+ <https://www.gnu.org/licenses/>. */
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+#include <link.h>
|
|
|
c5d972 |
+#include <inttypes.h>
|
|
|
c5d972 |
+#include <stdlib.h>
|
|
|
c5d972 |
+#include <stdio.h>
|
|
|
c5d972 |
+#include <string.h>
|
|
|
c5d972 |
+#include <sys/auxv.h>
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+unsigned int
|
|
|
c5d972 |
+la_version (unsigned int version)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ return LAV_CURRENT;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+struct map_desc_t
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ char *lname;
|
|
|
c5d972 |
+ uintptr_t laddr;
|
|
|
c5d972 |
+ Lmid_t lmid;
|
|
|
c5d972 |
+};
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+void
|
|
|
c5d972 |
+la_activity (uintptr_t *cookie, unsigned int flag)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ fprintf (stderr, "%s: %d %"PRIxPTR"\n", __func__, flag, (uintptr_t) cookie);
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+unsigned int
|
|
|
c5d972 |
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ const char *l_name = map->l_name[0] == '\0' ? "mainapp" : map->l_name;
|
|
|
c5d972 |
+ fprintf (stderr, "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
|
|
|
c5d972 |
+ (uintptr_t) cookie, l_name, map->l_addr, lmid);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ struct map_desc_t *map_desc = malloc (sizeof (struct map_desc_t));
|
|
|
c5d972 |
+ if (map_desc == NULL)
|
|
|
c5d972 |
+ abort ();
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ map_desc->lname = strdup (l_name);
|
|
|
c5d972 |
+ map_desc->laddr = map->l_addr;
|
|
|
c5d972 |
+ map_desc->lmid = lmid;
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ *cookie = (uintptr_t) map_desc;
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ return 0;
|
|
|
c5d972 |
+}
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+unsigned int
|
|
|
c5d972 |
+la_objclose (uintptr_t *cookie)
|
|
|
c5d972 |
+{
|
|
|
c5d972 |
+ struct map_desc_t *map_desc = (struct map_desc_t *) *cookie;
|
|
|
c5d972 |
+ fprintf (stderr, "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
|
|
|
c5d972 |
+ (uintptr_t) cookie, map_desc->lname, map_desc->laddr,
|
|
|
c5d972 |
+ map_desc->lmid);
|
|
|
c5d972 |
+
|
|
|
c5d972 |
+ return 0;
|
|
|
c5d972 |
+}
|