[PATCH] Fix module size and num_symtab for 2.6.27

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch implements the kernel change

    commit 2f0f2a334bc38b61a9afca951185cd3844ee709d
    Author: Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx>
    Date:   Tue Jul 22 19:24:27 2008 -0500

    module: turn longs into ints for module sizes

    This shrinks module.o and each *.ko file.

    And finally, structure members which hold length of module
    code (four such members there) and count of symbols
    are converted from longs to ints.

    We cannot possibly have a module where 32 bits won't
    be enough to hold such counts.

    For one, module loading checks module size for sanity
    before loading, so such insanely big module will fail
    that test first.

    Signed-off-by: Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx>
    Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>

in crash. Without the patch I was not able to open a core dump created with
2.6.27 on POWER. I think it's mostly a problem on big endian architectures,
because on little endian you can have luck and read zeros which don't change
the value of a number while on big endian you cannot have luck. ;-)


Signed-off-by: Bernhard Walle <bwalle@xxxxxxx>


This patch implements the kernel change

    commit 2f0f2a334bc38b61a9afca951185cd3844ee709d
    Author: Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx>
    Date:   Tue Jul 22 19:24:27 2008 -0500

    module: turn longs into ints for module sizes

    This shrinks module.o and each *.ko file.

    And finally, structure members which hold length of module
    code (four such members there) and count of symbols
    are converted from longs to ints.

    We cannot possibly have a module where 32 bits won't
    be enough to hold such counts.

    For one, module loading checks module size for sanity
    before loading, so such insanely big module will fail
    that test first.

    Signed-off-by: Denys Vlasenko <vda.linux@xxxxxxxxxxxxxx>
    Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>

in crash. Without the patch I was not able to open a core dump created with
2.6.27 on POWER. I think it's mostly a problem on big endian architectures,
because on little endian you can have luck and read zeros which don't change
the value of a number while on big endian you cannot have luck. ;-)


Signed-off-by: Bernhard Walle <bwalle@xxxxxxx>

diff -r 0fc5aeb865be -r 655e2974ac82 kernel.c
--- a/kernel.c	Thu Nov 06 18:27:10 2008 +0100
+++ b/kernel.c	Thu Nov 06 18:30:31 2008 +0100
@@ -2504,7 +2504,10 @@
 			break;
 
 		case KALLSYMS_V2:
-			numksyms = ULONG(modbuf + OFFSET(module_num_symtab));
+			if (THIS_KERNEL_VERSION >= LINUX(2,6,27))
+				numksyms = UINT(modbuf + OFFSET(module_num_symtab));
+			else
+				numksyms = ULONG(modbuf + OFFSET(module_num_symtab));
 			total += numksyms; 
 			break;
 		}
@@ -2617,8 +2620,12 @@
 				case KMOD_V2:
         				module_name = modbuf + 
 						OFFSET(module_name);
-					mod_size = LONG(modbuf + 
-						OFFSET(module_core_size));
+					if (THIS_KERNEL_VERSION >= LINUX(2,6,27))
+						mod_size = UINT(modbuf +
+							OFFSET(module_core_size));
+					else
+						mod_size = ULONG(modbuf +
+							OFFSET(module_core_size));
                 			if (strlen(module_name) < MAX_MOD_NAME)
                         			strcpy(buf, module_name);
                 			else 
diff -r 0fc5aeb865be -r 655e2974ac82 symbols.c
--- a/symbols.c	Thu Nov 06 18:27:10 2008 +0100
+++ b/symbols.c	Thu Nov 06 18:30:31 2008 +0100
@@ -1277,8 +1277,15 @@
 		gpl_syms = ULONG(modbuf + OFFSET(module_gpl_syms));
                 nsyms = UINT(modbuf + OFFSET(module_num_syms));
                 ngplsyms = UINT(modbuf + OFFSET(module_num_gpl_syms));
-                nksyms = ULONG(modbuf + OFFSET(module_num_symtab));
-		size = ULONG(modbuf + OFFSET(module_core_size));
+
+		if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
+			nksyms = UINT(modbuf + OFFSET(module_num_symtab));
+			size = UINT(modbuf + OFFSET(module_core_size));
+		} else {
+			nksyms = ULONG(modbuf + OFFSET(module_num_symtab));
+			size = ULONG(modbuf + OFFSET(module_core_size));
+		}
+
 		mod_name = modbuf + OFFSET(module_name);
 
 		lm = &st->load_modules[m++];
@@ -1301,8 +1308,12 @@
 				ngplsyms, nksyms);
 		lm->mod_flags = MOD_EXT_SYMS;
 		lm->mod_ext_symcnt = mcnt;
-		lm->mod_etext_guess = lm->mod_base + 
-			ULONG(modbuf + OFFSET(module_core_text_size));
+		if (THIS_KERNEL_VERSION >= LINUX(2,6,27))
+			lm->mod_etext_guess = lm->mod_base +
+				UINT(modbuf + OFFSET(module_core_text_size));
+		else
+			lm->mod_etext_guess = lm->mod_base +
+				ULONG(modbuf + OFFSET(module_core_text_size));
 		lm->mod_text_start = lm->mod_base;
 
 		st->ext_module_symtable[mcnt].value = lm->mod_base;
@@ -1740,7 +1751,10 @@
                 return 0;
         }
 
-	nksyms = ULONG(modbuf + OFFSET(module_num_symtab));
+	if (THIS_KERNEL_VERSION >= LINUX(2,6,27))
+		nksyms = UINT(modbuf + OFFSET(module_num_symtab));
+	else
+		nksyms = ULONG(modbuf + OFFSET(module_num_symtab));
 	ksymtab = ULONG(modbuf + OFFSET(module_symtab));
 	locsymtab = module_buf + (ksymtab - lm->mod_base);
 	kstrtab = ULONG(modbuf + OFFSET(module_strtab));
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux