aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/vminfo/linux.go
diff options
context:
space:
mode:
authorJoey Jiao <quic_jiangenj@quicinc.com>2024-05-14 14:15:07 +0800
committerDmitry Vyukov <dvyukov@google.com>2024-07-03 08:00:41 +0000
commit4dfd9e9b413004160c9965fd0d829a88178e1ad6 (patch)
tree2566587171acfabd64bac3d4d20dec1b8db482b6 /pkg/vminfo/linux.go
parent1e708ca121f9ce1b476fbfe46a11372e4de36cb7 (diff)
all: fix larger module size in /proc/modules
Module size from /proc/modules is bigger than that from .text size in elf.
Diffstat (limited to 'pkg/vminfo/linux.go')
-rw-r--r--pkg/vminfo/linux.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/vminfo/linux.go b/pkg/vminfo/linux.go
index c8e81dd01..4f180e9ff 100644
--- a/pkg/vminfo/linux.go
+++ b/pkg/vminfo/linux.go
@@ -68,6 +68,10 @@ func (linux) parseModules(files filesystem) ([]*cover.KernelModule, error) {
modules = append(modules, &cover.KernelModule{
Name: name,
Addr: textAddr,
+ // The size is wrong as there is overlap in /proc/modules
+ // ex. module1['Addr'] + module1['Size'] > module2['Addr']
+ // runtime kernel doesn't export .text section size to /sys/module/*/sections/.text
+ // so we need to read it from elf
Size: modSize - offset,
})
}
@@ -75,7 +79,7 @@ func (linux) parseModules(files filesystem) ([]*cover.KernelModule, error) {
if err != nil {
return nil, err
}
- modules = append(modules, cover.KernelModule{
+ modules = append(modules, &cover.KernelModule{
Name: "",
Addr: _stext,
Size: _etext - _stext,