Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 98751
b: refs/heads/master
c: 0fe1ef2
h: refs/heads/master
i:
  98749: 0b6b6c7
  98747: 0187a5f
  98743: cac416e
  98735: 93f3eb8
  98719: 343d816
  98687: 116eb12
v: v3
  • Loading branch information
Linus Torvalds committed Jul 6, 2008
1 parent 78d0a59 commit 9b6ab53
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4d8a743cdd2690c0bc8d1b8cbd02cffb1ead849f
refs/heads/master: 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2
41 changes: 40 additions & 1 deletion trunk/lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/kernel.h>
#include <linux/kallsyms.h>
#include <linux/uaccess.h>

#include <asm/page.h> /* for PAGE_SIZE */
#include <asm/div64.h>
Expand Down Expand Up @@ -511,15 +513,52 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio
return buf;
}

static inline void *dereference_function_descriptor(void *ptr)
{
#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
void *p;
if (!probe_kernel_address(ptr, p))
ptr = p;
#endif
return ptr;
}

static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int precision, int flags)
{
unsigned long value = (unsigned long) ptr;
#ifdef CONFIG_KALLSYMS
char sym[KSYM_SYMBOL_LEN];
sprint_symbol(sym, value);
return string(buf, end, sym, field_width, precision, flags);
#else
field_width = 2*sizeof(void *);
flags |= SPECIAL | SMALL | ZEROPAD;
return number(buf, end, value, 16, field_width, precision, flags);
#endif
}

/*
* Show a '%p' thing. A kernel extension is that the '%p' is followed
* by an extra set of alphanumeric characters that are extended format
* specifiers.
*
* Right now don't actually handle any such, but we will..
* Right now we just handle 'F' (for symbolic Function descriptor pointers)
* and 'S' (for Symbolic direct pointers), but this can easily be
* extended in the future (network address types etc).
*
* The difference between 'S' and 'F' is that on ia64 and ppc64 function
* pointers are really function descriptors, which contain a pointer the
* real address.
*/
static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags)
{
switch (*fmt) {
case 'F':
ptr = dereference_function_descriptor(ptr);
/* Fallthrough */
case 'S':
return symbol_string(buf, end, ptr, field_width, precision, flags);
}
flags |= SMALL;
if (field_width == -1) {
field_width = 2*sizeof(void *);
Expand Down

0 comments on commit 9b6ab53

Please sign in to comment.