Skip to content

Commit 8840497

Browse files
committed
Fixes for linux-4.4 kernel. Seems to panic when loaded, but at least
it compiles.
1 parent 7f12a78 commit 8840497

2 files changed

Lines changed: 39 additions & 4 deletions

File tree

driver/fbt_linux.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,16 @@ fbt_provide_module(void *arg, struct modctl *ctl)
388388
{ int i;
389389
struct module *mp = (struct module *) ctl;
390390
char *modname = mp->name;
391+
392+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
393+
char *str = mp->kallsyms->strtab;
394+
#else
391395
char *str = mp->strtab;
396+
#endif
392397
char *name;
393398
par_module_t *pmp;
394399
int ret;
400+
unsigned nsyms;
395401

396402
# if 0
397403
struct module *mp = ctl->mod_mp;
@@ -459,12 +465,22 @@ TODO();
459465
return;
460466
}
461467

468+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
469+
nsyms = mp->kallsyms->num_symtab;
470+
#else
471+
nsyms = mp->num_symtab;
472+
#endif
473+
462474
if (dtrace_here)
463-
printk("%s(%d):modname=%s num_symtab=%u\n", dtrace_basename(__FILE__), __LINE__, modname, (unsigned) mp->num_symtab);
475+
printk("%s(%d):modname=%s num_symtab=%u\n", dtrace_basename(__FILE__), __LINE__, modname, nsyms);
464476

465-
for (i = 1; i < mp->num_symtab; i++) {
477+
for (i = 1; i < nsyms; i++) {
466478
uint8_t *instr, *limit;
479+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
480+
Elf_Sym *sym = (Elf_Sym *) &mp->kallsyms->symtab[i];
481+
#else
467482
Elf_Sym *sym = (Elf_Sym *) &mp->symtab[i];
483+
#endif
468484
int dtrace_here = 0;
469485
if (strcmp(modname, "dummy") == 0) dtrace_here = 1;
470486

@@ -577,11 +593,16 @@ if (strcmp(modname, "dummy") == 0) dtrace_here = 1;
577593
/* if that page is now used by some other */
578594
/* driver. */
579595
/***********************************************/
596+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
597+
if (within_module_init(instr, mp))
598+
continue;
599+
#else
580600
if (mp->module_init && mp->init_size &&
581601
instr >= (uint8_t *) mp->module_init &&
582602
instr < (uint8_t *) mp->module_init + mp->init_size) {
583603
continue;
584604
}
605+
#endif
585606

586607
/***********************************************/
587608
/* We do have syms that appear to point to */

driver/instr_linux.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,13 @@ instr_provide_module(void *arg, struct modctl *ctl)
292292
{ int i;
293293
struct module *mp = (struct module *) ctl;
294294
char *modname = mp->name;
295+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
296+
char *str = mp->kallsyms->strtab;
297+
#else
295298
char *str = mp->strtab;
299+
#endif
296300
char *name;
301+
unsigned nsyms;
297302
par_module_t *pmp;
298303

299304
int init;
@@ -312,14 +317,23 @@ instr_provide_module(void *arg, struct modctl *ctl)
312317
return;
313318
}
314319

320+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
321+
nsyms = mp->kallsyms->num_symtab;
322+
#else
323+
nsyms = mp->num_symtab;
324+
#endif
315325
if (dtrace_here)
316-
printk("%s(%d):modname=%s num_symtab=%u\n", __FILE__, __LINE__, modname, (unsigned) mp->num_symtab);
326+
printk("%s(%d):modname=%s num_symtab=%u\n", __FILE__, __LINE__, modname, nsyms);
317327
if (strcmp(modname, "dtracedrv") == 0)
318328
return;
319329

320-
for (i = 1; i < mp->num_symtab; i++) {
330+
for (i = 1; i < nsyms; i++) {
321331
uint8_t *instr, *limit;
332+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
333+
Elf_Sym *sym = (Elf_Sym *) &mp->kallsyms->symtab[i];
334+
#else
322335
Elf_Sym *sym = (Elf_Sym *) &mp->symtab[i];
336+
#endif
323337
int dtrace_here = 0;
324338
if (strcmp(modname, "dummy") == 0) dtrace_here = 1;
325339

0 commit comments

Comments
 (0)