about summary refs log tree commit diff
path: root/elf/dl-audit.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-07-20 13:47:36 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-12-28 08:40:38 -0300
commitc91008d3490e4e3ce29520068405f081f0d368ca (patch)
treef7f7d9e8dbedba32b211382e02c67c515cdba94b /elf/dl-audit.c
parent3dac3959a5cb585b065cef2cb8a8d909c907e202 (diff)
downloadglibc-c91008d3490e4e3ce29520068405f081f0d368ca.tar.gz
glibc-c91008d3490e4e3ce29520068405f081f0d368ca.tar.xz
glibc-c91008d3490e4e3ce29520068405f081f0d368ca.zip
elf: Add _dl_audit_objsearch
It consolidates the code required to call la_objsearch audit
callback.

Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'elf/dl-audit.c')
-rw-r--r--elf/dl-audit.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/elf/dl-audit.c b/elf/dl-audit.c
index 74b87f4b39..5682427220 100644
--- a/elf/dl-audit.c
+++ b/elf/dl-audit.c
@@ -44,6 +44,28 @@ _dl_audit_activity_nsid (Lmid_t nsid, int action)
   _dl_audit_activity_map (head, action);
 }
 
+const char *
+_dl_audit_objsearch (const char *name, struct link_map *l, unsigned int code)
+{
+  if (l == NULL || l->l_auditing || code == 0)
+    return name;
+
+  struct audit_ifaces *afct = GLRO(dl_audit);
+  for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)
+    {
+      if (afct->objsearch != NULL)
+	{
+	  struct auditstate *state = link_map_audit_state (l, cnt);
+	  name = afct->objsearch (name, &state->cookie, code);
+	  if (name == NULL)
+	    return NULL;
+	}
+      afct = afct->next;
+   }
+
+  return name;
+}
+
 void
 _dl_audit_objopen (struct link_map *l, Lmid_t nsid)
 {