Re-compiled module sizes different from image


#1

I’m trying to compile a kernel module that’s not part of the standard Ubuntu release for the DragonBoard. But before that, I tried compiling all the standard modules, and the file sizes are different from what I have installed on my board. Any idea why, or whether I should even be concerned? Some details:

I have the alip image of Ubuntu release 15.07 installed on my board. I followed the instructions at the following links to cross-compile the modules:
http://builds.96boards.org/releases/dragonboard410c/linaro/ubuntu/15.07/

I’m particularly interested in the USB gadget modules, so here are a couple examples from that part of the source tree:

Installed on the DragonBoard:

-rw-r--r-- 1 root root 15608 Jul 27 09:23 kernel/drivers/usb/gadget/legacy/g_ether.ko
-rw-r--r-- 1 root root 14952 Jul 27 09:23 kernel/drivers/usb/gadget/legacy/g_mass_storage.ko
-rw-r--r-- 1 root root 12328 Jul 27 09:23 kernel/drivers/usb/gadget/legacy/g_serial.ko
-rw-r--r-- 1 root root 17776 Jul 27 09:23 kernel/drivers/usb/gadget/legacy/g_zero.ko

From what I re-compiled:

-rw-rw-r-- 1 mtr mtr 313940 Aug 21 00:21 kernel/drivers/usb/gadget/legacy/g_ether.ko
-rw-rw-r-- 1 mtr mtr 211209 Aug 21 00:21 kernel/drivers/usb/gadget/legacy/g_mass_storage.ko
-rw-rw-r-- 1 mtr mtr 246921 Aug 21 00:21 kernel/drivers/usb/gadget/legacy/g_serial.ko
-rw-rw-r-- 1 mtr mtr 216597 Aug 21 00:21 kernel/drivers/usb/gadget/legacy/g_zero.ko

Notice that the modules that I compiled are quite a bit bigger. Same thing happened when I compiled on the board itself as well as when I cross-compiled on my laptop with the 2015.06 Linaro cross-compiler. (Per the instructions at the link above, I started with the 2014.11 cross-compiler.) I also confirmed that my .config file is identical to the kernel.config file at the link above.

I’m guessing there’s something wrong with the toolchain I’m using, but I’m otherwise stumped.


#2

I just saw that @doitright mentioned using the strip command as part of the following thread:
https://www.96boards.org/forums/topic/rebuilding-the-boot-partition-on-410c/

After compiling the modules I ran

make INSTALL_MOD_PATH=build-${ARCH}-modules INSTALL_MOD_STRIP=1 modules_install

Now the *.ko file sizes are nearly the same. :slight_smile:

The ones I compiled seem to be a couple hundred bytes smaller than the ones from the released 15.07 image. I’m guessing this is because the release was compiled with a different version of the cross-compiler than the one linked to in the instructions.


#3

Lots of things can impact the size of compiled binaries.
You can even change the parameters to the strip command to change what, precisely, is stripped out of the binaries.

Generally, the unstripped binaries will consume more memory when loaded, but will be easier to work with when debugging.