From 55eda22f279fa612410e057a6598f6e715aaf6d0 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 13 Jul 2023 16:08:11 +0200 Subject: 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 --- pkg/symbolizer/nm.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkg') 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" { -- cgit mrf-deployment