aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/cover/backend/modules.go
Commit message (Collapse)AuthorAgeFilesLines
* all: replace Walk with WalkDir to reduce os.Lstat callsGofastasf2025-01-301-2/+2
| | | | | | | | filepath.Walk calls os.Lstat for every file or directory to retrieve os.FileInfo. filepath.WalkDir avoids unnecessary system calls since it provides a fs.DirEntry, which includes file type information without requiring a stat call. This improves performance by reducing redundant system calls.
* pkg/cover: fix pc for core kernelJoey Jiao2024-08-051-4/+0
| | | | | | | we use offset to symbolize pc for module, while use absolute pc for core kernel. Fix by removing base address from module only.
* all: move KernelModule into vminfo packageJoey Jiao2024-07-101-17/+11
|
* all: calc kaslr offset and remove kaslr_offset from module addrJoey Jiao2024-07-031-0/+41
|
* pkg/cover: remove unused hostModulesJoey Jiao2024-07-031-12/+7
|
* all: fix larger module size in /proc/modulesJoey Jiao2024-07-031-4/+20
| | | | Module size from /proc/modules is bigger than that from .text size in elf.
* all: always use KernelModule ptr to unify usageJoey Jiao2024-06-171-2/+2
|
* all: use only one KernelModule structJoey Jiao2024-06-171-5/+6
|
* pkg/cover: move KernelModule from pkg/hostDmitry Vyukov2024-05-031-4/+8
| | | | | | In preparation for pkg/host removal. Nothing in pkg/host uses KernelModule, and pkg/cover is effectively the only user of KernelModule.
* pkg/cover: delete getModuleOffset()Alexander Potapenko2024-02-261-3/+3
| | | | | | Since commit 971a0f14c5cf6 ("pkg/host: get module .text address from /sys/module") getModuleOffset() is not used by anyone, so it should be safe to delete it.
* pkg/host: get module .text address from /sys/moduleNecip Fazil Yildiran2024-02-221-2/+1
| | | | | | | | | | | | | | | | | | The address from /proc/modules is not necessarily the address of .text, e.g., can be the address of .plt. If available, fix up the module address using the address from /sys/module/<module-name>/sections/.text This patch was originally uploaded to https://github.com/google/syzkaller/pull/4025. Additions to the original patch: - fix lint warnings - adjust the module size to account for the diff between the module address and .text address Signed-off-by: Alexander Potapenko <glider@google.com>
* pkg/cover/backend: adjust module base address by .text offsetAlexander Potapenko2024-01-171-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modules' .text sections are not necessarily loaded at the address shown in /proc/modules. If there are other non-init code sections preceding them in the ELF binary, .text is loaded at non-zero address. For example, for a module with the following sections: Idx Name Size VMA LMA File off Algn ... 5 .plt 00000001 0000000000000000 0000000000000000 00000500 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 6 .init.ddplt 00000001 0000000000000000 0000000000000000 00000501 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE 7 .text.ftrace_trampoline 00000001 0000000000000000 0000000000000000 00000502 2**0 CONTENTS, ALLOC, LOAD, READONLY, CODE 8 .hyp.text 00002000 0000000000000000 0000000000000000 00001000 2**12 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE ... 13 .text 00001aac 0000000000000000 0000000000000000 00005048 2**2 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE the base address displayed in /proc/modules points to the beginning of .plt, and other sections have the following offsets: .init.plt - ignored .text.ftrace_trampoline - 0x1 .hyp.text - 0x1000 .text - 0x3000 This patch calculates the offset of the .text section and uses it to adjust the address obtained from /proc/modules.
* all: use special placeholder for errorsTaras Madan2023-07-241-2/+2
|
* pkg/cover/backend: add mach-o object support for darwinPatrick Meyer2021-05-061-0/+1
| | | | | | I have invested time deduplicating code between the two formats. As the go modules for Mach-O and ELF don't share types, I had to re-wrap some information or move code to format specific functions though.
* pkg/cover/backend: refactor module discoveryDmitry Vyukov2021-03-181-63/+49
| | | | | Restructure discovery code that it can be tested and add a manual test. Also remove some code duplication for module creation.
* pkg/cover: refactor module discovery interfaceDmitry Vyukov2021-03-181-13/+38
| | | | | | | Make module discovery convert host.KernelModule to backend.Module. Also error if we have modules on non-Linux and make it possible to return errors from module discovery.
* pkg/cover/backend: move module discovery into separate fileDmitry Vyukov2021-03-181-0/+119
elf.go is already quite large and messy. Module discovery is a well separatable chunk of logic, move it to a dedicated file. No code changes.