From d10ef76a38ffc6d2247e5e80104834248ab1541e Mon Sep 17 00:00:00 2001 From: Marc Gonzalez Date: Tue, 1 Aug 2023 18:24:19 +0200 Subject: [PATCH] linux_dumper: Always map ELF file from offset 0 Functions such as FindElfSection and FindElfSegments that inspect the ELF header expect a pointer to the first byte of the file. IsValidElf() checks for the ELF magic number at offset 0. Thus, we must map ELF object files from offset 0. Change-Id: Icebfb46229a04019f57a7ec07844257b98ceb278 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4674337 Reviewed-by: Mike Frysinger --- src/client/linux/minidump_writer/linux_dumper.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index 85922a9c..5c4c389c 100644 --- a/src/client/linux/minidump_writer/linux_dumper.cc +++ b/src/client/linux/minidump_writer/linux_dumper.cc @@ -346,7 +346,7 @@ LinuxDumper::ElfFileIdentifierForMapping(const MappingInfo& mapping, return false; bool filename_modified = HandleDeletedFileInMapping(filename); - MemoryMappedFile mapped_file(filename, mapping.offset); + MemoryMappedFile mapped_file(filename, 0); if (!mapped_file.data() || mapped_file.size() < SELFMAG) return false; @@ -459,7 +459,7 @@ bool ElfFileSoName(const LinuxDumper& dumper, if (!dumper.GetMappingAbsolutePath(mapping, filename)) return false; - MemoryMappedFile mapped_file(filename, mapping.offset); + MemoryMappedFile mapped_file(filename, 0); if (!mapped_file.data() || mapped_file.size() < SELFMAG) { // mmap failed return false;