Skip to content
How to compile a sp...
Clear all

How to compile a specific kernel module exactly same way as in running kernel

1 Posts
1 Users
Illustrious Member
Joined: 4 months ago
Posts: 57418
Topic starter  

I'm trying to compile kernel module "r8152.ko". My goal is that my compiled module is exactly the same as r8152.ko in /lib/module/$(uname -r)

Here is what I tried:

Check kernel version

$ uname -a
Linux LPT00102259F 5.15.0-56-generic #62~20.04.1-Ubuntu SMP Tue Nov 22 21:24:20 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Download kernel source from here: 

Extract source to ~/Downloads/linux-source-5.15.0

Edit ~/Downloads/linux-source-5.15.0/drivers/net/usb/Makefile so it contains only

obj-$(CONFIG_USB_RTL8152)    += r8152.o

Copy .config, Module.symvers and run some build commands

p@LPT00102259F:~/Downloads/linux-source-5.15.0$ make mrproper
  CLEAN   arch/x86/tools
  CLEAN   scripts/basic
  CLEAN   scripts/genksyms
  CLEAN   scripts/kconfig
  CLEAN   scripts/mod
  CLEAN   scripts/selinux/genheaders
  CLEAN   scripts/selinux/mdp
  CLEAN   scripts
  CLEAN   include/config include/generated arch/x86/include/generated .config .config.old Module.symvers
p@LPT00102259F:~/Downloads/linux-source-5.15.0$ cp /boot/config-$(uname -r) .config
p@LPT00102259F:~/Downloads/linux-source-5.15.0$ cp /lib/modules/$(uname -r)/build/Module.symvers .
p@LPT00102259F:~/Downloads/linux-source-5.15.0$ make olddefconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/menu.o
  HOSTCC  scripts/kconfig/
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
# configuration written to .config
p@LPT00102259F:~/Downloads/linux-source-5.15.0$ make prepare -j8
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  WRAP    arch/x86/include/generated/uapi/asm/bpf_perf_event.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  WRAP    arch/x86/include/generated/uapi/asm/errno.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  WRAP    arch/x86/include/generated/uapi/asm/fcntl.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
  WRAP    arch/x86/include/generated/uapi/asm/ioctl.h
  WRAP    arch/x86/include/generated/uapi/asm/ioctls.h
  SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
  WRAP    arch/x86/include/generated/uapi/asm/ipcbuf.h
  WRAP    arch/x86/include/generated/uapi/asm/param.h
  WRAP    arch/x86/include/generated/uapi/asm/poll.h
  WRAP    arch/x86/include/generated/uapi/asm/resource.h
  WRAP    arch/x86/include/generated/uapi/asm/socket.h
  WRAP    arch/x86/include/generated/uapi/asm/sockios.h
  WRAP    arch/x86/include/generated/uapi/asm/termbits.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
  WRAP    arch/x86/include/generated/uapi/asm/types.h
  WRAP    arch/x86/include/generated/uapi/asm/termios.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_x32.h
  HYPERCALLS arch/x86/include/generated/asm/xen-hypercalls.h
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  WRAP    arch/x86/include/generated/asm/early_ioremap.h
  WRAP    arch/x86/include/generated/asm/export.h
  WRAP    arch/x86/include/generated/asm/mcs_spinlock.h
  WRAP    arch/x86/include/generated/asm/irq_regs.h
  WRAP    arch/x86/include/generated/asm/kmap_size.h
  WRAP    arch/x86/include/generated/asm/local64.h
  WRAP    arch/x86/include/generated/asm/mmiowb.h
  WRAP    arch/x86/include/generated/asm/
  WRAP    arch/x86/include/generated/asm/rwonce.h
  WRAP    arch/x86/include/generated/asm/unaligned.h
  UPD     include/config/kernel.release
  UPD     include/generated/uapi/linux/version.h
  HOSTCC  scripts/bin2c
  DESCEND objtool
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/genksyms/genksyms.o
  HOSTCC  scripts/selinux/genheaders/genheaders
  DESCEND bpf/resolve_btfids
  HOSTCC  /home/p/Downloads/linux-source-5.15.0/tools/objtool/fixdep.o
  HOSTCC  scripts/sorttable
  MKDIR     /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids//libbpf
  UPD     include/generated/utsrelease.h
  HOSTLD  arch/x86/tools/relocs
  YACC    scripts/genksyms/[ch]
  HOSTCC  /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/fixdep.o
  HOSTLD  /home/p/Downloads/linux-source-5.15.0/tools/objtool/fixdep-in.o
  LINK    /home/p/Downloads/linux-source-5.15.0/tools/objtool/fixdep
  HOSTCC  scripts/asn1_compiler
  HOSTCC  scripts/selinux/mdp/mdp
  LEX     scripts/genksyms/lex.lex.c
  HOSTCC  scripts/genksyms/
  HOSTLD  /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/fixdep-in.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/exec-cmd.o
  HOSTCC  scripts/genksyms/lex.lex.o
  LINK    /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/fixdep
  HOSTCC  scripts/sign-file
  MKDIR     /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids//libsubcmd
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/main.o
  HOSTCC  scripts/extract-cert
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/rbtree.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/help.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/zalloc.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/pager.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/string.o
  HOSTCC  scripts/insert-sys-cert
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/arch/x86/special.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/arch/x86/decode.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/ctype.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/weak.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/check.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/parse-options.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/str_error_r.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/run-command.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/special.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/orc_gen.o
  HOSTLD  scripts/genksyms/genksyms
  LD      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/resolve_btfids-in.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/orc_dump.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/builtin-check.o
  GEN     /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/bpf_helper_defs.h
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/sigchain.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/builtin-orc.o
  MKDIR   /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf.o
  MKDIR   /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/bpf.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/elf.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/subcmd-config.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/objtool.o
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  LD      /home/p/Downloads/linux-source-5.15.0/tools/objtool/arch/x86/objtool-in.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/libstring.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/nlattr.o
  LD      /home/p/Downloads/linux-source-5.15.0/tools/objtool/libsubcmd-in.o
  AR      /home/p/Downloads/linux-source-5.15.0/tools/objtool/libsubcmd.a
  CC      scripts/mod/devicetable-offsets.s
  MKELF   scripts/mod/elfconfig.h
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/libctype.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/str_error_r.o
  HOSTCC  scripts/mod/modpost.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/objtool/librbtree.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/btf.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/exec-cmd.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/help.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf_errno.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/pager.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/run-command.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/parse-options.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/str_error.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/netlink.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/sigchain.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/subcmd-config.o
  UPD     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/sumversion.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/bpf_prog_linfo.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf_probes.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/xsk.o
  LD      /home/p/Downloads/linux-source-5.15.0/tools/objtool/objtool-in.o
  LD      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/libsubcmd-in.o
  HOSTCC  scripts/mod/file2alias.o
  LINK    /home/p/Downloads/linux-source-5.15.0/tools/objtool/objtool
  AR      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libsubcmd/libsubcmd.a
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/hashmap.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/btf_dump.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/ringbuf.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/strset.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/linker.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/gen_loader.o
  CC      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/relo_core.o
  HOSTLD  scripts/mod/modpost
  CALL    scripts/atomic/
  CC      kernel/bounds.s
  UPD     include/generated/timeconst.h
  UPD     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  UPD     include/generated/asm-offsets.h
  CALL    scripts/
  LD      /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/staticobjs/libbpf-in.o
  LINK    /home/p/Downloads/linux-source-5.15.0/tools/bpf/resolve_btfids/libbpf/libbpf.a
  LINK     resolve_btfids
p@LPT00102259F:~/Downloads/linux-source-5.15.0$ make modules_prepare
  CALL    scripts/
  CALL    scripts/atomic/
  DESCEND objtool
  DESCEND bpf/resolve_btfids
  LDS     scripts/
p@LPT00102259F:~/Downloads/linux-source-5.15.0$ make M=drivers/net/usb
  CC [M]  drivers/net/usb/r8152.o
  MODPOST drivers/net/usb/Module.symvers
  CC [M]  drivers/net/usb/r8152.mod.o
  LD [M]  drivers/net/usb/r8152.ko

Then I run modinfo on generated r8152.ko and check vermagic

vermagic:       5.15.64 SMP mod_unload modversions

This is different from original file in /lib

vermagic:       5.15.0-56-generic SMP mod_unload modversions

Why is that and what do I need to do so they are the same ?


Unreplied Posts

Which is the real Euler’s Rotation theorem?


There are two quite different, but useful, theorems related to 3D rotation that are referred to as “Euler’s Rotation Theorem“.

The first definition is given as a quotation in the book by Kuipers

  • Any two independent orthonormal coordinate frames can be related by a sequence of rotations (not more than three) about coordinate axes, where no two successive rotations may be about the same axis.

There is a similar, but more pithy definition, from Wolfram MathWorld

  • An arbitrary rotation may be described by only three parameters.

This is related to the three-angle representation of an arbitrary rotation by Euler, roll-pitch-yaw, Tati-Bryan angles etc.

The second definition is from Wikipedia

  • When a sphere is moved around its centre it is always possible to find a diameter whose direction in the displaced position is the same as in the initial position. (Also given in latin)

This related to the angle-axis representation of an arbitrary rotation. This version of the Rotation Theorem is found in many other places as well, including here on Math Overflow.

Both definitions are related to rotation, and the second at least has a reference to Euler 1776. The first is related to Euler axes and Euler angles, seems like the sort of thing Euler might have figured out, but Kuipers does not provide a reference.

Euler was notorious for not publishing much. Somebody, post Euler, has declared these theorems as Euler’s Rotation Theorem. Which one is it? Is there a more nuanced way to refer to them?


Using Overpass to find intersections with 3 or more links

I’m trying to find all the intersections (nodes) with 3 or more links (ways) in an area as an indicator for walkability. Complete beginner to the Overpass API and this has me pretty stumped. OSM clearly shows which ways are part of a node, suggesting that this should be very doable. Can’t be much more specific as I don’t even know where to start, so thanks in advance for any help!

A riddle involving the axiom of choice


So i found a riddle on reddit which is a consequence of the axiom of choice.

There is a house with 100 rooms, and each room contains countably many boxes indexed with the natural numbers. Each box contains a random real number, which is the same over all the rooms (that is, box n contains the same real number in every room).

100 set theorists play a game. Each person will go into a unique room and open as many boxes as they like (perhaps countably many) as long as they leave at least one box in their room unopened. Then, each of them need to pick an unopened box in their room, and guess what real number is inside of it.

In order to win, 99 of them need to guess correctly.

The mathematicians can discuss a strategy beforehand, but after they go into their respective rooms, no more communication is allowed. What is a 100% winning strategy for this seemingly impossible task?

The solution is here:

My question is why can the mathematicians agree on a specific representative for each equivalence class? I thought that the axiom of choice guaranteed a choice function existed, but didnt specify it. But for the solution to the riddle, they would need to know what the choice function is. Can someone explain?


problem with Ubuntu Pro blocked my pc

I am user of Bodhi 18.04 LTS Bionic 32 bit wich based on Ubuntu.I update to nvidia-304 and now i can’t enter on my Bodhi os. because it’s show me Ubuntu Pro at the beginning.After insert my password and Token, he show me the error:

WARNING:root:failed to process /proc/version_signature.

Anyone have solution to help me ?

Exponentials of stochastic band matrices


This may be a duplicate, but I’ve done some searching and I can’t find exactly this problem setting, probably due to not knowing the right terminology for how to refer to the transition matrix.

I’m considering absorbing random walks ${X_t}$ which have symmetric transition probabilities inside a window of size $k$. For example, on ${0, 1, 2, dots, 100}$, with $k=3$ if $X_t = 5$
P[X_{t+1} = 4] &= P[X_{t+1} = 6]\
P[X_{t+1} = 3] &= P[X_{t+1} = 7]\
P[X_{t+1} = 2] &= P[X_{t+1} = 8]\

When the walk is within $k$ of the endpoint, the allowable transitions are truncated on both sides, e.g. if $X_t = 1$, $P[X_t = 3] = 0$.

I wanted to figure out the probability of the walk being absorbed at the upper endpoint, so I did some numerical experiments with walks on the integers from 0-100.
I calculated $T^n$ for the transition matrix $T$ and a large $n$. I then looked at $(T^n)_{i, 100}$ to see the probability of being absorbed at 100. It appears that the value is always equal to $i/100$, regardless of how I set the transition distribution or window-size.

The transition matrix for a walk on the integers in $[0, N]$ has the following properties:

  1. $T$ is (row) stochastic
  2. $T$ is a band matrix with upper and lower band size $k$
  3. $T_{i, j} = 0$ if $|i – j| > max (i, N – i)$
  4. $T_{i,i + r} = T_{i, i – r}$ (this is the main property I don’t know the name of)
  5. $T_{0, 0} = T_{1, 1} = 1$

I would like a proof or counterexample of the following statement:
limlimits_{n to infty} (T^n)_{i, N} = i/N

If the statement above is true, is it still true if the transition distributions are no longer left-right symmetric, but it’s still the case that $E[X_{t + 1}] = X_t$?


If $varphi$ is a normal faithful semifinite weight, is $eta_varphi(mathfrak{n}_varphicapmathfrak{n}_varphi^*)$ dense in $mathfrak{H}_varphi$


Let $M$ be a von Neumann algebra and $varphi: M_+to [0, infty]$ be a normal, faithful semifinite weight. Consider its associated semi-cyclic representation
$$pi_varphi: Mto B(mathfrak{H}_varphi)$$
(see Takesaki’s second book, chapter VII for details).

Consider the associated map
$$eta_varphi: mathfrak{n}_varphito mathfrak{H}_varphi.$$

Is it true that $eta_varphi(mathfrak{n}_varphicap mathfrak{n}_varphi^*)$ is norm-dense in $mathfrak{H}_varphi$?

Attempt: If $xi perp eta_varphi(mathfrak{n}_varphicap mathfrak{n}_varphi^*)$, then for $x,yin mathfrak{n}_varphi$
$$0 = langle xi, eta_varphi(x^*y) rangle = langle pi_varphi(x)xi, eta_varphi(y)rangle$$
so that $pi_varphi(mathfrak{n}_varphi)xi=0$. Maybe this is sufficient to conclude that $xi= 0$? I feel like non-degeneracy of $pi_varphi$ is relevant.