aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-07-13 16:08:11 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-07-13 14:27:10 +0000
commit55eda22f279fa612410e057a6598f6e715aaf6d0 (patch)
tree3e9b28f26dc4dc56f62a33dfe22b2336b42104fc /pkg
parented0de6423efe063def1c26c3dfd5d2b4369f6c31 (diff)
pkg/symbolizer: skip the elf.SHF_WRITE check
The remaining checks (elf.SHF_ALLOC and elf.SHF_EXECINSTR) seem to a good enough filter for matching symbols. Additionally, there have already been cases when absolutely valid functions ended up in SHF_WRITE sections: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?id=0fddb79bf283
Diffstat (limited to 'pkg')
-rw-r--r--pkg/symbolizer/nm.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkg/symbolizer/nm.go b/pkg/symbolizer/nm.go
index cf8ebd86b..471640b4f 100644
--- a/pkg/symbolizer/nm.go
+++ b/pkg/symbolizer/nm.go
@@ -72,7 +72,8 @@ func load(target *targets.Target, bin string, text bool) ([]elf.Symbol, error) {
}
sect := file.Sections[symb.Section]
isText := sect.Type == elf.SHT_PROGBITS &&
- sect.Flags&(elf.SHF_WRITE|elf.SHF_ALLOC|elf.SHF_EXECINSTR) == (elf.SHF_ALLOC|elf.SHF_EXECINSTR)
+ sect.Flags&elf.SHF_ALLOC != 0 &&
+ sect.Flags&elf.SHF_EXECINSTR != 0
// Note: x86_64 vmlinux .rodata is marked as writable and according to flags it looks like .data,
// so we look at the name.
if text && !isText || !text && sect.Name != ".rodata" {