Skip to content

Commit

Permalink
Merge pull request raspberrypi#756 from ojeda/new-kallsyms-patches
Browse files Browse the repository at this point in the history
kallsyms: provide a bigger buffer to report the real length
  • Loading branch information
ojeda authored May 4, 2022
2 parents 426f7e4 + 49aab5e commit eca090f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions scripts/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@

#define KSYM_NAME_LEN 512

/* A substantially bigger size than the current maximum. */
#define KSYM_NAME_LEN_BUFFER 2048
_Static_assert(
KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4,
"Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN"
);

struct sym_entry {
unsigned long long addr;
unsigned int len;
Expand Down Expand Up @@ -200,15 +207,15 @@ static void check_symbol_range(const char *sym, unsigned long long addr,

static struct sym_entry *read_symbol(FILE *in)
{
char name[KSYM_NAME_LEN+1], type;
char name[KSYM_NAME_LEN_BUFFER+1], type;
unsigned long long addr;
unsigned int len;
struct sym_entry *sym;
int rc;

rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN) "s\n", &addr, &type, name);
rc = fscanf(in, "%llx %c %" _stringify(KSYM_NAME_LEN_BUFFER) "s\n", &addr, &type, name);
if (rc != 3) {
if (rc != EOF && fgets(name, KSYM_NAME_LEN + 1, in) == NULL)
if (rc != EOF && fgets(name, KSYM_NAME_LEN_BUFFER + 1, in) == NULL)
fprintf(stderr, "Read error or end of file.\n");
return NULL;
}
Expand Down

0 comments on commit eca090f

Please sign in to comment.