aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-29 13:30:13 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-29 13:30:13 -0500
commit668533dc0764b30c9dd2baf3ca800156f688326b (patch)
tree5d8d4f06b7f2278e9e91f2e03dec4890a6bc736a
parentda6af54dc0014d733ce014a196e4c84ee43cabec (diff)
kallsyms: take advantage of the new '%px' format
The conditional kallsym hex printing used a special fixed-width '%lx' output (KALLSYM_FMT) in preparation for the hashing of %p, but that series ended up adding a %px specifier to help with the conversions. Use it, and avoid the "print pointer as an unsigned long" code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/kallsyms.h6
-rw-r--r--kernel/kallsyms.c8
-rw-r--r--kernel/module.c6
3 files changed, 7 insertions, 13 deletions
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index 708f337d780b..bd118a6c60cb 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -14,12 +14,6 @@
14#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 14#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
15 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1) 15 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
16 16
17#ifndef CONFIG_64BIT
18# define KALLSYM_FMT "%08lx"
19#else
20# define KALLSYM_FMT "%016lx"
21#endif
22
23struct module; 17struct module;
24 18
25#ifdef CONFIG_KALLSYMS 19#ifdef CONFIG_KALLSYMS
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 531ffa984bc2..d5fa4116688a 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -614,14 +614,14 @@ static void s_stop(struct seq_file *m, void *p)
614 614
615static int s_show(struct seq_file *m, void *p) 615static int s_show(struct seq_file *m, void *p)
616{ 616{
617 unsigned long value; 617 void *value;
618 struct kallsym_iter *iter = m->private; 618 struct kallsym_iter *iter = m->private;
619 619
620 /* Some debugging symbols have no name. Ignore them. */ 620 /* Some debugging symbols have no name. Ignore them. */
621 if (!iter->name[0]) 621 if (!iter->name[0])
622 return 0; 622 return 0;
623 623
624 value = iter->show_value ? iter->value : 0; 624 value = iter->show_value ? (void *)iter->value : NULL;
625 625
626 if (iter->module_name[0]) { 626 if (iter->module_name[0]) {
627 char type; 627 char type;
@@ -632,10 +632,10 @@ static int s_show(struct seq_file *m, void *p)
632 */ 632 */
633 type = iter->exported ? toupper(iter->type) : 633 type = iter->exported ? toupper(iter->type) :
634 tolower(iter->type); 634 tolower(iter->type);
635 seq_printf(m, KALLSYM_FMT " %c %s\t[%s]\n", value, 635 seq_printf(m, "%px %c %s\t[%s]\n", value,
636 type, iter->name, iter->module_name); 636 type, iter->name, iter->module_name);
637 } else 637 } else
638 seq_printf(m, KALLSYM_FMT " %c %s\n", value, 638 seq_printf(m, "%px %c %s\n", value,
639 iter->type, iter->name); 639 iter->type, iter->name);
640 return 0; 640 return 0;
641} 641}
diff --git a/kernel/module.c b/kernel/module.c
index f0411a271765..dea01ac9cb74 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -4157,7 +4157,7 @@ static int m_show(struct seq_file *m, void *p)
4157{ 4157{
4158 struct module *mod = list_entry(p, struct module, list); 4158 struct module *mod = list_entry(p, struct module, list);
4159 char buf[MODULE_FLAGS_BUF_SIZE]; 4159 char buf[MODULE_FLAGS_BUF_SIZE];
4160 unsigned long value; 4160 void *value;
4161 4161
4162 /* We always ignore unformed modules. */ 4162 /* We always ignore unformed modules. */
4163 if (mod->state == MODULE_STATE_UNFORMED) 4163 if (mod->state == MODULE_STATE_UNFORMED)
@@ -4173,8 +4173,8 @@ static int m_show(struct seq_file *m, void *p)
4173 mod->state == MODULE_STATE_COMING ? "Loading" : 4173 mod->state == MODULE_STATE_COMING ? "Loading" :
4174 "Live"); 4174 "Live");
4175 /* Used by oprofile and other similar tools. */ 4175 /* Used by oprofile and other similar tools. */
4176 value = m->private ? 0 : (unsigned long)mod->core_layout.base; 4176 value = m->private ? NULL : mod->core_layout.base;
4177 seq_printf(m, " 0x" KALLSYM_FMT, value); 4177 seq_printf(m, " 0x%px", value);
4178 4178
4179 /* Taints info */ 4179 /* Taints info */
4180 if (mod->taints) 4180 if (mod->taints)