summaryrefslogtreecommitdiff
path: root/usr/src/common/ctf/ctf_util.c
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2014-07-30 19:32:50 +0000
committerRobert Mustacchi <rm@joyent.com>2015-02-15 17:26:09 +0000
commitb9050054bed684df58fc1c855197eec06a2036bf (patch)
treecc8ec42bb149c4c00b068fc8cab890ec5cdfc61a /usr/src/common/ctf/ctf_util.c
parentf31c6fa33bcc9a608ce6f9ffd671ffc2b65a30ef (diff)
downloadillumos-joyent-b9050054bed684df58fc1c855197eec06a2036bf.tar.gz
OS-3851 ctfdump should be written in terms of libctf
OS-3852 ctfdiff could be more useful OS-3853 ctfmerge and ctfconvert could have an altexec OS-3854 ctfmerge should be implemented in terms of libctf Reviewed by: Keith M Wesolowski <wesolows@foobazco.org>
Diffstat (limited to 'usr/src/common/ctf/ctf_util.c')
-rw-r--r--usr/src/common/ctf/ctf_util.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/usr/src/common/ctf/ctf_util.c b/usr/src/common/ctf/ctf_util.c
index 740d403e8c..550195b5e1 100644
--- a/usr/src/common/ctf/ctf_util.c
+++ b/usr/src/common/ctf/ctf_util.c
@@ -23,10 +23,12 @@
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2015, Joyent, Inc.
+ */
#include <ctf_impl.h>
+#include <sys/debug.h>
/*
* Simple doubly-linked list append routine. This implementation assumes that
@@ -71,6 +73,24 @@ ctf_list_prepend(ctf_list_t *lp, void *new)
lp->l_prev = p;
}
+void
+ctf_list_insert_before(ctf_list_t *head, void *item, void *nitem)
+{
+ ctf_list_t *lp = item;
+ ctf_list_t *new = nitem;
+ ctf_list_t *prev = lp->l_prev;
+
+ lp->l_prev = new;
+ new->l_next = lp;
+ new->l_prev = prev;
+ if (prev != NULL) {
+ prev->l_next = new;
+ } else {
+ ASSERT(head->l_next == lp);
+ head->l_next = new;
+ }
+}
+
/*
* Delete the specified existing element from the given ctf_list_t. The
* existing pointer should be pointing at a struct with embedded ctf_list_t.
@@ -150,3 +170,22 @@ ctf_set_errno(ctf_file_t *fp, int err)
fp->ctf_errno = err;
return (CTF_ERR);
}
+
+boolean_t
+ctf_sym_valid(uintptr_t strbase, int type, uint16_t shndx, uint64_t val,
+ uint32_t noff)
+{
+ const char *name;
+
+ if (type != STT_OBJECT && type != STT_FUNC)
+ return (B_FALSE);
+ if (shndx == SHN_UNDEF || noff == 0)
+ return (B_FALSE);
+ if (type == STT_OBJECT && shndx == SHN_ABS && val == 0)
+ return (B_FALSE);
+ name = (char *)(strbase + noff);
+ if (strcmp(name, "_START_") == 0 || strcmp(name, "_END_") == 0)
+ return (B_FALSE);
+
+ return (B_TRUE);
+}