How to rename a kernel module name without renaming the .ko passed to insmod?
Rename your obj-m
in Makefile and set dependency of obj-m
to original module.
For example, I have file hello.c
that contain all of my source code. But I want module to be mynewname
.
Here is whole Makefile that does this:
obj-m := mynewname.o
mynewname-objs := hello.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
I set obj-m
to mynewname.o
and make mynewname.o
dependant on hello.o
. After invoking make you'll get mynewname.ko
.
Hello world kernel module for android & unknown relocation: 27 when insmod
It turns out I had to use
make CFLAGS_MODULE=-fno-pic
Why need add another dot in section name
Thank you Robert for reminder.
Found the answer in the mailing list
http://www.uwsg.indiana.edu/hypermail/linux/kernel/1002.2/01728.html
The problem is that with -ffunction-sections -fdata-sections gcc
creates sections like .text.head and .data.nosave
whenever someone has innocuous code like this:
static void head(...) {...}
or this:
static int nosave = 1;
somewhere in the kernel. Currently, kernel linker scripts
are confused by such names and put these sections in wrong places.
Related Topics
How to Increase The Size of Ephemeral Storage in a Kubernetes Worker Node
Monitoring (Sniffing) /Dev/Ttyusb0 Created by Ftdi Usb Serial Converter
Ssh-Add from Bash Script and Automate Passphrase Entry
Bash Script - Auto Fill Answer
Running Shell Script After Boot on Raspberry Pi
Udp Server Giving Segmentation Fault
Npm Install -G Grunt-Cli Failed in Linux
Getting Root Privileges in Ansible
Linux: Changing File Ownership Without a Copy
How to Check If a UId Exists in an Acl in Linux
Time Taken by 'Less' Command to Show Output
How Does Linux Handles The I/O Permission Bitmap in The Tss Structure
Pipe Tar Extract into Tar Create
Stream Static Image to V4L2Loopback Using Obs with V4L2 Plugin, Ffmpeg or Gstreamer