ITKeyword,专注技术干货聚合推荐

注册 | 登录

解决linux - Finding the kernel address of a loadable kernel module

itPublisher 分享于

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

推荐:Linux kernel & module program

Linux内核/模块开发常见问题集(FAQ)(转载) 1. 请推荐一些好的Linux内核参考书? a.《Linux Device Drivers, 2nd Edition》,有中文译本   b.《Understanding the

I'm trying to find the kernel address space where my loadable kernel module is relocated by insmod.

I came to know that by using the -m, -O switches while insmod'ing the module, we can only see the symbol table and the executable's sections' addresses from the view-point of the module and not their relocated addresses, as that process of relocation is carried out when we do an insmod.

Can anyone tell how to find the relocated address of a module in the kernel-memory i.e the address bound within the kernel where a loaded module resides?

Thanks!

P.S Please note that I'm using a Redhat 2.4 Linux kernel in which the /proc/modules listing doesn't show the virtual addresses of the loaded modules.

linux linux-kernel kernel embedded-linux kernel-module
edited Mar 21 '13 at 5:30 asked Mar 21 '13 at 2:59 freax 62 1 8

 | 

2 Answers
2

解决方法

You can get the core section pointer(virtual address, not physical memory address, but it can be converted to physical address) and the footprint size of the module from /proc/modules file.

推荐:The Linux Kernel Module Programming Guide

原文地址:http://tldp.org/LDP/lkmpg/2.6/html/   Table of Contents Foreword 1. Authorship 2. Versioning and Notes 3. Acknowledgements 1. Introduction 1

Such as part of the file on my Linux box:

autofs4 29253 3 - Live 0xf9014000
hidp 23105 2 - Live 0xf900d000
rfcomm 42457 0 - Live 0xf8f84000

answered Mar 21 '13 at 3:16 tian_yufeng 1,482 5 8      Hi @tian_yufeng, thanks! However I'm using a Redhat 2.4 Linux kernel in which the /proc/modules listing doesn't show the virtual address as edited in my question. Do you know how to get the kernel address of loaded modules in this 2.4 kernel? –  freax Mar 21 '13 at 5:49      2.4 kernel is a little out. I think codes changes needed to support the feature you want. Can you tell me the detail version of your kernel? So I can download one to have a check. –  tian_yufeng Mar 21 '13 at 7:02      I'm using Redhat 2.4.20-24.7 kernel Have found the addresses of the modules using "__this_module.next" pointer which I believe are virtual. Can you tell me how to convert these virtual addresses into physical addresses? Thanks! –  freax Mar 21 '13 at 7:48      I think in 2.4.20, the loadable modules are using VMALLOC memory. So you can try to use page_to_pfn(vmalloc_to_page(vmalloc_addr)) to convert the VMALLOC virtual address to physical page, then you can get the physical addresss. –  tian_yufeng Mar 21 '13 at 8:28      Thanks for your suggestion. Will try that and get back to you! I wanted to ask you how to verify if this kernel uses VMALLOC for virtual memory allocation? Because I did a "man" vmalloc and vmalloc_to_page but couldn't find any man page telling their details –  freax Mar 21 '13 at 9:36  |  show more comments

Go to directory /sys/module/<module-name>/sections/.text - will show where the code is loaded /sys/module/<module-name>/sections/.data will show the data section and .bss for the bss section of the module.


edited Apr 3 '15 at 2:29 Pang 5,574 14 48 79 answered Apr 6 '13 at 17:50 Ulka Vaze 116 1 3   A quick tip: you require root to get the cat /sys/module/module-name-here/sections/.* stuff to work.. (else it just displays the value 0x0). –  kaiwan Apr 3 '15 at 2:43      @kaiwan Your tip saves my day! –  mkdong Aug 9 '16 at 13:03

 | 

推荐:Linux Debugging 8 - Kernel Module

refer to http://tldp.org/LDP/lkmpg/2.6/html/   The Linux Kernel Module Programming Guide    


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。