summaryrefslogtreecommitdiff
path: root/usr/src/lib/libctf/common
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2020-06-25 23:10:45 -0700
committerRobert Mustacchi <rm@fingolfin.org>2020-07-02 07:54:21 -0700
commit56f23fa092900d6145428feaadd69e5157186680 (patch)
tree1118ce17b1a20db351b18fbcf2c5ede6ba716aa2 /usr/src/lib/libctf/common
parent6ecc470585ed07369dd51b0ed85f5cf848e5b5c2 (diff)
downloadillumos-gate-56f23fa092900d6145428feaadd69e5157186680.tar.gz
12898 ctf enum size detection should use DW_AT_byte_size
Reviewed by: Rich Lowe <richlowe@richlowe.net> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Jason King <jason.brian.king@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/lib/libctf/common')
-rw-r--r--usr/src/lib/libctf/common/ctf_dwarf.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/usr/src/lib/libctf/common/ctf_dwarf.c b/usr/src/lib/libctf/common/ctf_dwarf.c
index 3079831715..cbe1661003 100644
--- a/usr/src/lib/libctf/common/ctf_dwarf.c
+++ b/usr/src/lib/libctf/common/ctf_dwarf.c
@@ -1751,40 +1751,12 @@ ctf_dwarf_create_reference(ctf_cu_t *cup, Dwarf_Die die, ctf_id_t *idp,
return (ctf_dwmap_add(cup, *idp, die, B_FALSE));
}
-/*
- * Get the size of the type of a particular die. Note that this is a simple
- * version that doesn't attempt to traverse further than expecting a single
- * sized type reference (so no qualifiers etc.). Nor does it attempt to do as
- * much as ctf_type_size() - which we cannot use here as that doesn't look up
- * dynamic types, and we don't yet want to do a ctf_update().
- */
-static int
-ctf_dwarf_get_type_size(ctf_cu_t *cup, Dwarf_Die die, size_t *sizep)
-{
- const ctf_type_t *t;
- Dwarf_Die tdie;
- ctf_id_t tid;
- int ret;
-
- if ((ret = ctf_dwarf_refdie(cup, die, DW_AT_type, &tdie)) != 0)
- return (ret);
-
- if ((ret = ctf_dwarf_convert_type(cup, tdie, &tid,
- CTF_ADD_NONROOT)) != 0)
- return (ret);
-
- if ((t = ctf_dyn_lookup_by_id(cup->cu_ctfp, tid)) == NULL)
- return (ENOENT);
-
- *sizep = ctf_get_ctt_size(cup->cu_ctfp, t, NULL, NULL);
- return (0);
-}
-
static int
ctf_dwarf_create_enum(ctf_cu_t *cup, Dwarf_Die die, ctf_id_t *idp, int isroot)
{
size_t size = 0;
Dwarf_Die child;
+ Dwarf_Unsigned dw;
ctf_id_t id;
char *name;
int ret;
@@ -1795,7 +1767,15 @@ ctf_dwarf_create_enum(ctf_cu_t *cup, Dwarf_Die die, ctf_id_t *idp, int isroot)
if (ret == ENOENT)
name = NULL;
- (void) ctf_dwarf_get_type_size(cup, die, &size);
+ /*
+ * Enumerations may have a size associated with them, particularly if
+ * they're packed. Note, a Dwarf_Unsigned is larger than a size_t on an
+ * ILP32 system.
+ */
+ if (ctf_dwarf_unsigned(cup, die, DW_AT_byte_size, &dw) == 0 &&
+ dw < SIZE_MAX) {
+ size = (size_t)dw;
+ }
id = ctf_add_enum(cup->cu_ctfp, isroot, name, size);
ctf_dprintf("added enum %s (%d)\n", name, id);