diff options
author | dmick <none@none> | 2007-03-23 19:23:04 -0700 |
---|---|---|
committer | dmick <none@none> | 2007-03-23 19:23:04 -0700 |
commit | e007031558dddc1a7f3593d9457d99bde738653e (patch) | |
tree | 352e144c7e4fcb1b53468827dcfd950977cc0027 /usr | |
parent | af48bdb315becc10c7a7725af8416f9112363057 (diff) | |
download | illumos-gate-e007031558dddc1a7f3593d9457d99bde738653e.tar.gz |
6448268 dis: 6427698 introduced a bunch of meaningless spew when disassembling .o files
Diffstat (limited to 'usr')
-rw-r--r-- | usr/src/cmd/dis/dis_main.c | 11 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_disasm.c | 15 | ||||
-rw-r--r-- | usr/src/common/dis/i386/dis_tables.c | 6 | ||||
-rw-r--r-- | usr/src/common/dis/i386/dis_tables.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libdisasm/common/libdisasm.h | 5 | ||||
-rw-r--r-- | usr/src/lib/libdisasm/common/mapfile-vers | 4 | ||||
-rw-r--r-- | usr/src/lib/libdisasm/i386/dis_i386.c | 23 |
7 files changed, 57 insertions, 10 deletions
diff --git a/usr/src/cmd/dis/dis_main.c b/usr/src/cmd/dis/dis_main.c index b7f12a1b70..b62047d8dd 100644 --- a/usr/src/cmd/dis/dis_main.c +++ b/usr/src/cmd/dis/dis_main.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -514,6 +514,15 @@ dis_file(const char *filename) ehdr.e_machine); } + /* + * If ET_REL (.o), printing immediate symbols is likely to + * result in garbage, as symbol lookups on unrelocated + * immediates find false and useless matches. + */ + + if (ehdr.e_type == ET_REL) + g_flags |= DIS_NOIMMSYM; + if (!g_quiet && dis_tgt_member(current) != NULL) (void) printf("\narchive member %s\n", dis_tgt_member(current)); diff --git a/usr/src/cmd/mdb/common/mdb/mdb_disasm.c b/usr/src/cmd/mdb/common/mdb/mdb_disasm.c index e3dc9d3e0a..f40c8343d6 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_disasm.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_disasm.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -308,6 +308,19 @@ libdisasm_ins2str(mdb_disasm_t *dp, mdb_tgt_t *t, mdb_tgt_as_t as, dis_set_data(dhp, &db); + if (strcmp(mdb_tgt_name(t), "proc") == 0) { + /* check for ELF ET_REL type; turn on NOIMMSYM if so */ + + GElf_Ehdr leh; + + if (mdb_tgt_getxdata(t, "ehdr", &leh, sizeof (leh)) != -1 && + leh.e_type == ET_REL) { + dis_flags_set(dhp, DIS_NOIMMSYM); + } else { + dis_flags_clear(dhp, DIS_NOIMMSYM); + } + } + /* * Attempt to disassemble the instruction. If this fails because of an * unknown opcode, drive on anyway. If it fails because we couldn't diff --git a/usr/src/common/dis/i386/dis_tables.c b/usr/src/common/dis/i386/dis_tables.c index c4384f2681..673921c080 100644 --- a/usr/src/common/dis/i386/dis_tables.c +++ b/usr/src/common/dis/i386/dis_tables.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -3263,8 +3263,8 @@ dtrace_disx86_str(dis86_t *dis, uint_t mode, uint64_t pc, char *buf, lookup = dis->d86_sym_lookup; if (tgt != 0) { - /* Print symbol, if found, for tgt */ - if (lookup(dis->d86_data, tgt, NULL, 0) == 0) { + if ((dis->d86_flags & DIS_F_NOIMMSYM) == 0 && + lookup(dis->d86_data, tgt, NULL, 0) == 0) { (void) strlcat(buf, "\t<", buflen); curlen = strlen(buf); lookup(dis->d86_data, tgt, buf + curlen, diff --git a/usr/src/common/dis/i386/dis_tables.h b/usr/src/common/dis/i386/dis_tables.h index 70aceec139..05b404f88c 100644 --- a/usr/src/common/dis/i386/dis_tables.h +++ b/usr/src/common/dis/i386/dis_tables.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -96,6 +96,7 @@ typedef struct dis86 { extern int dtrace_disx86(dis86_t *x, uint_t cpu_mode); #define DIS_F_OCTAL 0x1 /* Print all numbers in octal */ +#define DIS_F_NOIMMSYM 0x2 /* Don't print symbols for immediates (.o) */ #ifdef DIS_TEXT extern void dtrace_disx86_str(dis86_t *x, uint_t cpu_mode, uint64_t pc, diff --git a/usr/src/lib/libdisasm/common/libdisasm.h b/usr/src/lib/libdisasm/common/libdisasm.h index f66150a4ec..3ecdea0860 100644 --- a/usr/src/lib/libdisasm/common/libdisasm.h +++ b/usr/src/lib/libdisasm/common/libdisasm.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -51,6 +51,7 @@ typedef struct dis_handle dis_handle_t; /* generic disassembler flags */ #define DIS_OCTAL 0x40 +#define DIS_NOIMMSYM 0x80 typedef int (*dis_lookup_f)(void *, uint64_t, char *, size_t, uint64_t *, size_t *); @@ -62,6 +63,8 @@ extern void dis_handle_destroy(dis_handle_t *); extern int dis_disassemble(dis_handle_t *, uint64_t, char *, size_t); extern uint64_t dis_previnstr(dis_handle_t *, uint64_t, int n); extern void dis_set_data(dis_handle_t *, void *); +extern void dis_flags_set(dis_handle_t *, int f); +extern void dis_flags_clear(dis_handle_t *, int f); extern int dis_max_instrlen(dis_handle_t *); /* libdisasm errors */ diff --git a/usr/src/lib/libdisasm/common/mapfile-vers b/usr/src/lib/libdisasm/common/mapfile-vers index aba1c6a51e..221caae54d 100644 --- a/usr/src/lib/libdisasm/common/mapfile-vers +++ b/usr/src/lib/libdisasm/common/mapfile-vers @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -34,6 +34,8 @@ SUNWprivate_1.1 { dis_max_instrlen; dis_previnstr; dis_set_data; + dis_flags_set; + dis_flags_clear; dis_strerror; local: *; diff --git a/usr/src/lib/libdisasm/i386/dis_i386.c b/usr/src/lib/libdisasm/i386/dis_i386.c index e775a0b78d..a940d69f75 100644 --- a/usr/src/lib/libdisasm/i386/dis_i386.c +++ b/usr/src/lib/libdisasm/i386/dis_i386.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -99,7 +99,7 @@ dis_handle_create(int flags, void *data, dis_lookup_f lookup_func, * Validate architecture flags */ if (flags & ~(DIS_X86_SIZE16 | DIS_X86_SIZE32 | DIS_X86_SIZE64 | - DIS_OCTAL)) { + DIS_OCTAL | DIS_NOIMMSYM)) { (void) dis_seterrno(E_DIS_INVALFLAG); return (NULL); } @@ -145,6 +145,12 @@ dis_disassemble(dis_handle_t *dhp, uint64_t addr, char *buf, size_t buflen) { dhp->dh_addr = addr; + /* DIS_NOIMMSYM might not be set until now, so update */ + if (dhp->dh_flags & DIS_NOIMMSYM) + dhp->dh_dis.d86_flags |= DIS_F_NOIMMSYM; + else + dhp->dh_dis.d86_flags &= ~DIS_F_NOIMMSYM; + if (dtrace_disx86(&dhp->dh_dis, dhp->dh_mode) != 0) return (-1); @@ -167,6 +173,19 @@ dis_set_data(dis_handle_t *dhp, void *data) dhp->dh_data = data; } +void +dis_flags_set(dis_handle_t *dhp, int f) +{ + dhp->dh_flags |= f; +} + +void +dis_flags_clear(dis_handle_t *dhp, int f) +{ + dhp->dh_flags &= ~f; +} + + /* ARGSUSED */ int dis_max_instrlen(dis_handle_t *dhp) |