Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+7 -13
-6
include/linux/kallsyms.h
··· 14 14 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 15 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 - 23 17 struct module; 24 18 25 19 #ifdef CONFIG_KALLSYMS
+4 -4
kernel/kallsyms.c
··· 614 614 615 615 static int s_show(struct seq_file *m, void *p) 616 616 { 617 - unsigned long value; 617 + void *value; 618 618 struct kallsym_iter *iter = m->private; 619 619 620 620 /* Some debugging symbols have no name. Ignore them. */ 621 621 if (!iter->name[0]) 622 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 626 if (iter->module_name[0]) { 627 627 char type; ··· 632 632 */ 633 633 type = iter->exported ? toupper(iter->type) : 634 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 636 type, iter->name, iter->module_name); 637 637 } else 638 - seq_printf(m, KALLSYM_FMT " %c %s\n", value, 638 + seq_printf(m, "%px %c %s\n", value, 639 639 iter->type, iter->name); 640 640 return 0; 641 641 }
+3 -3
kernel/module.c
··· 4157 4157 { 4158 4158 struct module *mod = list_entry(p, struct module, list); 4159 4159 char buf[MODULE_FLAGS_BUF_SIZE]; 4160 - unsigned long value; 4160 + void *value; 4161 4161 4162 4162 /* We always ignore unformed modules. */ 4163 4163 if (mod->state == MODULE_STATE_UNFORMED) ··· 4173 4173 mod->state == MODULE_STATE_COMING ? "Loading" : 4174 4174 "Live"); 4175 4175 /* Used by oprofile and other similar tools. */ 4176 - value = m->private ? 0 : (unsigned long)mod->core_layout.base; 4177 - seq_printf(m, " 0x" KALLSYM_FMT, value); 4176 + value = m->private ? NULL : mod->core_layout.base; 4177 + seq_printf(m, " 0x%px", value); 4178 4178 4179 4179 /* Taints info */ 4180 4180 if (mod->taints)