如何在kernel模块中使用已经编译好的obj文件

本文介绍了如何在Linux内核模块中使用预先编译好的obj文件。首先,需要在特定环境下使用`obj-y`指定obj文件,并避免直接链接。接着,创建Makefile并设置编译规则,确保obj文件能在内核编译环境中正确编译。最后,在目标模块中引用编译后的obj文件,并在源代码中调用其函数。虽然可能并无实际应用价值,但这是一个有趣的实验。
摘要由CSDN通过智能技术生成

这也是一时心血来潮,觉得好玩。 在Document/kbuild/modules.txt中看到这么一段


--- 3.3 Binary Blobs

    Some external modules need to include an object file as a blob.
    kbuild has support for this, but requires the blob file to be
    named <filename>_shipped. When the kbuild rules kick in, a copy
    of <filename>_shipped is created with _shipped stripped off,
    giving us <filename>. This shortened filename can be used in
    the assignment to the module.

    Throughout this section, 8123_bin.o_shipped has been used to
    build the kernel module 8123.ko; it has been included as
    8123_bin.o.

        8123-y := 8123_if.o 8123_pci.o 8123_bin.o

    Although there is no distinction between the ordinary source
    files and the binary file, kbuild will pick up different rules
    when creating the object file for the module.
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值