2020-11-06 08:09:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019-2020, Jesse Buhagiar <jooster669@gmail.com>
|
|
|
|
* Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
|
2021-04-22 20:51:19 +00:00
|
|
|
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
|
2021-06-29 20:07:36 +00:00
|
|
|
* Copyright (c) 2021, Andreas Kling <klingi@serenityos.org>
|
2020-11-06 08:09:51 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-11-06 08:09:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <AK/ByteBuffer.h>
|
2021-06-29 20:07:36 +00:00
|
|
|
#include <AK/JsonObjectSerializer.h>
|
2020-11-06 08:09:51 +00:00
|
|
|
#include <Kernel/CoreDump.h>
|
|
|
|
#include <Kernel/FileSystem/Custody.h>
|
|
|
|
#include <Kernel/FileSystem/FileDescription.h>
|
|
|
|
#include <Kernel/FileSystem/VirtualFileSystem.h>
|
2021-07-06 09:21:52 +00:00
|
|
|
#include <Kernel/KLexicalPath.h>
|
2020-11-06 08:09:51 +00:00
|
|
|
#include <Kernel/Process.h>
|
|
|
|
#include <Kernel/RTC.h>
|
|
|
|
#include <Kernel/SpinLock.h>
|
|
|
|
#include <Kernel/VM/ProcessPagingScope.h>
|
2021-04-16 19:53:43 +00:00
|
|
|
#include <LibC/elf.h>
|
2020-11-06 08:09:51 +00:00
|
|
|
#include <LibELF/CoreDump.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2020-12-26 23:51:48 +00:00
|
|
|
OwnPtr<CoreDump> CoreDump::create(NonnullRefPtr<Process> process, const String& output_path)
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2020-12-26 23:51:48 +00:00
|
|
|
if (!process->is_dumpable()) {
|
|
|
|
dbgln("Refusing to generate CoreDump for non-dumpable process {}", process->pid().value());
|
2021-01-10 23:29:28 +00:00
|
|
|
return {};
|
2020-12-25 17:27:42 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 20:38:58 +00:00
|
|
|
auto fd = create_target_file(process, output_path);
|
2020-11-06 08:09:51 +00:00
|
|
|
if (!fd)
|
2021-01-10 23:29:28 +00:00
|
|
|
return {};
|
2021-06-20 08:21:16 +00:00
|
|
|
return adopt_own_if_nonnull(new (nothrow) CoreDump(move(process), fd.release_nonnull()));
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
2020-12-26 23:51:48 +00:00
|
|
|
CoreDump::CoreDump(NonnullRefPtr<Process> process, NonnullRefPtr<FileDescription>&& fd)
|
|
|
|
: m_process(move(process))
|
2020-11-06 08:09:51 +00:00
|
|
|
, m_fd(move(fd))
|
2021-02-08 14:45:40 +00:00
|
|
|
, m_num_program_headers(m_process->space().region_count() + 1) // +1 for NOTE segment
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-12-15 10:17:01 +00:00
|
|
|
RefPtr<FileDescription> CoreDump::create_target_file(const Process& process, const String& output_path)
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2021-07-06 09:21:52 +00:00
|
|
|
auto output_directory = KLexicalPath::dirname(output_path);
|
2021-07-10 22:25:24 +00:00
|
|
|
auto dump_directory = VirtualFileSystem::the().open_directory(output_directory, VirtualFileSystem::the().root_custody());
|
2021-01-10 10:27:02 +00:00
|
|
|
if (dump_directory.is_error()) {
|
|
|
|
dbgln("Can't find directory '{}' for core dump", output_directory);
|
|
|
|
return nullptr;
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
2021-01-10 10:27:02 +00:00
|
|
|
auto dump_directory_metadata = dump_directory.value()->inode().metadata();
|
2021-03-26 15:46:20 +00:00
|
|
|
if (dump_directory_metadata.uid != 0 || dump_directory_metadata.gid != 0 || dump_directory_metadata.mode != 040777) {
|
2021-01-10 10:27:02 +00:00
|
|
|
dbgln("Refusing to put core dump in sketchy directory '{}'", output_directory);
|
2020-11-06 08:09:51 +00:00
|
|
|
return nullptr;
|
2021-01-10 10:27:02 +00:00
|
|
|
}
|
2021-07-10 22:25:24 +00:00
|
|
|
auto fd_or_error = VirtualFileSystem::the().open(
|
2021-07-06 09:21:52 +00:00
|
|
|
KLexicalPath::basename(output_path),
|
2020-11-06 08:09:51 +00:00
|
|
|
O_CREAT | O_WRONLY | O_EXCL,
|
2021-01-23 16:57:21 +00:00
|
|
|
S_IFREG, // We will enable reading from userspace when we finish generating the coredump file
|
2021-01-10 10:27:02 +00:00
|
|
|
*dump_directory.value(),
|
2020-11-06 08:09:51 +00:00
|
|
|
UidAndGid { process.uid(), process.gid() });
|
|
|
|
|
2021-01-10 10:27:02 +00:00
|
|
|
if (fd_or_error.is_error()) {
|
|
|
|
dbgln("Failed to open core dump '{}' for writing", output_path);
|
2020-11-06 08:09:51 +00:00
|
|
|
return nullptr;
|
2021-01-10 10:27:02 +00:00
|
|
|
}
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
return fd_or_error.value();
|
|
|
|
}
|
|
|
|
|
2020-12-22 08:59:14 +00:00
|
|
|
KResult CoreDump::write_elf_header()
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2021-06-28 15:24:08 +00:00
|
|
|
ElfW(Ehdr) elf_file_header;
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_ident[EI_MAG0] = 0x7f;
|
|
|
|
elf_file_header.e_ident[EI_MAG1] = 'E';
|
|
|
|
elf_file_header.e_ident[EI_MAG2] = 'L';
|
|
|
|
elf_file_header.e_ident[EI_MAG3] = 'F';
|
2021-06-29 15:48:01 +00:00
|
|
|
#if ARCH(I386)
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_ident[EI_CLASS] = ELFCLASS32;
|
2021-06-29 15:48:01 +00:00
|
|
|
#else
|
|
|
|
elf_file_header.e_ident[EI_CLASS] = ELFCLASS64;
|
|
|
|
#endif
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_ident[EI_DATA] = ELFDATA2LSB;
|
|
|
|
elf_file_header.e_ident[EI_VERSION] = EV_CURRENT;
|
|
|
|
elf_file_header.e_ident[EI_OSABI] = 0; // ELFOSABI_NONE
|
|
|
|
elf_file_header.e_ident[EI_ABIVERSION] = 0;
|
|
|
|
elf_file_header.e_ident[EI_PAD + 1] = 0;
|
|
|
|
elf_file_header.e_ident[EI_PAD + 2] = 0;
|
|
|
|
elf_file_header.e_ident[EI_PAD + 3] = 0;
|
|
|
|
elf_file_header.e_ident[EI_PAD + 4] = 0;
|
|
|
|
elf_file_header.e_ident[EI_PAD + 5] = 0;
|
|
|
|
elf_file_header.e_ident[EI_PAD + 6] = 0;
|
|
|
|
elf_file_header.e_type = ET_CORE;
|
2021-06-29 15:48:01 +00:00
|
|
|
#if ARCH(I386)
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_machine = EM_386;
|
2021-06-29 15:48:01 +00:00
|
|
|
#else
|
|
|
|
elf_file_header.e_machine = EM_X86_64;
|
|
|
|
#endif
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_version = 1;
|
|
|
|
elf_file_header.e_entry = 0;
|
2021-06-28 15:24:08 +00:00
|
|
|
elf_file_header.e_phoff = sizeof(ElfW(Ehdr));
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_shoff = 0;
|
|
|
|
elf_file_header.e_flags = 0;
|
2021-06-28 15:24:08 +00:00
|
|
|
elf_file_header.e_ehsize = sizeof(ElfW(Ehdr));
|
|
|
|
elf_file_header.e_shentsize = sizeof(ElfW(Shdr));
|
|
|
|
elf_file_header.e_phentsize = sizeof(ElfW(Phdr));
|
2020-11-06 08:09:51 +00:00
|
|
|
elf_file_header.e_phnum = m_num_program_headers;
|
|
|
|
elf_file_header.e_shnum = 0;
|
|
|
|
elf_file_header.e_shstrndx = SHN_UNDEF;
|
|
|
|
|
2021-06-28 15:24:08 +00:00
|
|
|
auto result = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&elf_file_header)), sizeof(ElfW(Ehdr)));
|
2020-12-22 08:59:14 +00:00
|
|
|
if (result.is_error())
|
|
|
|
return result.error();
|
|
|
|
return KSuccess;
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
2020-12-22 08:59:14 +00:00
|
|
|
KResult CoreDump::write_program_headers(size_t notes_size)
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2021-06-28 15:24:08 +00:00
|
|
|
size_t offset = sizeof(ElfW(Ehdr)) + m_num_program_headers * sizeof(ElfW(Phdr));
|
2021-02-08 14:45:40 +00:00
|
|
|
for (auto& region : m_process->space().regions()) {
|
2021-06-28 15:24:08 +00:00
|
|
|
ElfW(Phdr) phdr {};
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
phdr.p_type = PT_LOAD;
|
|
|
|
phdr.p_offset = offset;
|
2021-04-06 23:20:29 +00:00
|
|
|
phdr.p_vaddr = region->vaddr().get();
|
2020-11-06 08:09:51 +00:00
|
|
|
phdr.p_paddr = 0;
|
|
|
|
|
2021-04-06 23:20:29 +00:00
|
|
|
phdr.p_filesz = region->page_count() * PAGE_SIZE;
|
|
|
|
phdr.p_memsz = region->page_count() * PAGE_SIZE;
|
2020-11-06 08:09:51 +00:00
|
|
|
phdr.p_align = 0;
|
|
|
|
|
2021-04-06 23:20:29 +00:00
|
|
|
phdr.p_flags = region->is_readable() ? PF_R : 0;
|
|
|
|
if (region->is_writable())
|
2020-11-06 08:09:51 +00:00
|
|
|
phdr.p_flags |= PF_W;
|
2021-04-06 23:20:29 +00:00
|
|
|
if (region->is_executable())
|
2020-11-06 08:09:51 +00:00
|
|
|
phdr.p_flags |= PF_X;
|
|
|
|
|
|
|
|
offset += phdr.p_filesz;
|
|
|
|
|
2021-06-28 15:24:08 +00:00
|
|
|
[[maybe_unused]] auto rc = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(&phdr)), sizeof(ElfW(Phdr)));
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
2021-06-28 15:24:08 +00:00
|
|
|
ElfW(Phdr) notes_pheader {};
|
2020-11-06 08:09:51 +00:00
|
|
|
notes_pheader.p_type = PT_NOTE;
|
|
|
|
notes_pheader.p_offset = offset;
|
|
|
|
notes_pheader.p_vaddr = 0;
|
|
|
|
notes_pheader.p_paddr = 0;
|
|
|
|
notes_pheader.p_filesz = notes_size;
|
2020-12-27 20:33:32 +00:00
|
|
|
notes_pheader.p_memsz = notes_size;
|
2020-11-06 08:09:51 +00:00
|
|
|
notes_pheader.p_align = 0;
|
|
|
|
notes_pheader.p_flags = 0;
|
|
|
|
|
2021-06-28 15:24:08 +00:00
|
|
|
auto result = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(reinterpret_cast<uint8_t*>(¬es_pheader)), sizeof(ElfW(Phdr)));
|
2020-12-22 08:59:14 +00:00
|
|
|
if (result.is_error())
|
|
|
|
return result.error();
|
|
|
|
return KSuccess;
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
2020-12-22 08:59:14 +00:00
|
|
|
KResult CoreDump::write_regions()
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2021-02-08 14:45:40 +00:00
|
|
|
for (auto& region : m_process->space().regions()) {
|
2021-04-06 23:20:29 +00:00
|
|
|
if (region->is_kernel())
|
2020-11-06 08:09:51 +00:00
|
|
|
continue;
|
|
|
|
|
2021-04-06 23:20:29 +00:00
|
|
|
region->set_readable(true);
|
|
|
|
region->remap();
|
2020-11-06 08:09:51 +00:00
|
|
|
|
2021-04-06 23:20:29 +00:00
|
|
|
for (size_t i = 0; i < region->page_count(); i++) {
|
|
|
|
auto* page = region->physical_page(i);
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
uint8_t zero_buffer[PAGE_SIZE] = {};
|
|
|
|
Optional<UserOrKernelBuffer> src_buffer;
|
|
|
|
|
|
|
|
if (page) {
|
2021-04-06 23:20:29 +00:00
|
|
|
src_buffer = UserOrKernelBuffer::for_user_buffer(reinterpret_cast<uint8_t*>((region->vaddr().as_ptr() + (i * PAGE_SIZE))), PAGE_SIZE);
|
2020-11-06 08:09:51 +00:00
|
|
|
} else {
|
|
|
|
// If the current page is not backed by a physical page, we zero it in the coredump file.
|
|
|
|
// TODO: Do we want to include the contents of pages that have not been faulted-in in the coredump?
|
|
|
|
// (A page may not be backed by a physical page because it has never been faulted in when the process ran).
|
|
|
|
src_buffer = UserOrKernelBuffer::for_kernel_buffer(zero_buffer);
|
|
|
|
}
|
2020-12-22 08:59:14 +00:00
|
|
|
auto result = m_fd->write(src_buffer.value(), PAGE_SIZE);
|
|
|
|
if (result.is_error())
|
|
|
|
return result.error();
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-22 08:59:14 +00:00
|
|
|
return KSuccess;
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
2020-12-22 08:59:14 +00:00
|
|
|
KResult CoreDump::write_notes_segment(ByteBuffer& notes_segment)
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2020-12-22 08:59:14 +00:00
|
|
|
auto result = m_fd->write(UserOrKernelBuffer::for_kernel_buffer(notes_segment.data()), notes_segment.size());
|
|
|
|
if (result.is_error())
|
|
|
|
return result.error();
|
|
|
|
return KSuccess;
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
2020-12-30 12:19:53 +00:00
|
|
|
ByteBuffer CoreDump::create_notes_process_data() const
|
|
|
|
{
|
|
|
|
ByteBuffer process_data;
|
|
|
|
|
|
|
|
ELF::Core::ProcessInfo info {};
|
|
|
|
info.header.type = ELF::Core::NotesEntryHeader::Type::ProcessInfo;
|
|
|
|
process_data.append((void*)&info, sizeof(info));
|
|
|
|
|
2021-06-29 20:07:36 +00:00
|
|
|
StringBuilder builder;
|
|
|
|
{
|
2021-06-29 20:27:11 +00:00
|
|
|
JsonObjectSerializer process_obj { builder };
|
|
|
|
process_obj.add("pid"sv, m_process->pid().value());
|
|
|
|
process_obj.add("termination_signal"sv, m_process->termination_signal());
|
|
|
|
process_obj.add("executable_path"sv, m_process->executable() ? m_process->executable()->absolute_path() : String::empty());
|
|
|
|
|
|
|
|
{
|
|
|
|
auto arguments_array = process_obj.add_array("arguments"sv);
|
|
|
|
for (auto& argument : m_process->arguments())
|
|
|
|
arguments_array.add(argument);
|
|
|
|
}
|
2021-06-29 20:07:36 +00:00
|
|
|
|
2021-06-29 20:27:11 +00:00
|
|
|
{
|
|
|
|
auto environment_array = process_obj.add_array("environment"sv);
|
|
|
|
for (auto& variable : m_process->environment())
|
|
|
|
environment_array.add(variable);
|
|
|
|
}
|
2021-06-29 20:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
builder.append(0);
|
|
|
|
process_data.append(builder.string_view().characters_without_null_termination(), builder.length());
|
2020-12-30 12:19:53 +00:00
|
|
|
|
|
|
|
return process_data;
|
|
|
|
}
|
|
|
|
|
2020-11-06 08:09:51 +00:00
|
|
|
ByteBuffer CoreDump::create_notes_threads_data() const
|
|
|
|
{
|
|
|
|
ByteBuffer threads_data;
|
|
|
|
|
2021-01-28 07:41:18 +00:00
|
|
|
for (auto& thread : m_process->threads_for_coredump({})) {
|
2020-11-06 08:09:51 +00:00
|
|
|
ByteBuffer entry_buff;
|
|
|
|
|
|
|
|
ELF::Core::ThreadInfo info {};
|
2020-11-11 20:02:39 +00:00
|
|
|
info.header.type = ELF::Core::NotesEntryHeader::Type::ThreadInfo;
|
2020-11-06 08:09:51 +00:00
|
|
|
info.tid = thread.tid().value();
|
2021-02-08 18:34:41 +00:00
|
|
|
copy_kernel_registers_into_ptrace_registers(info.regs, thread.get_register_dump_from_stack());
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
entry_buff.append((void*)&info, sizeof(info));
|
|
|
|
|
|
|
|
threads_data += entry_buff;
|
2021-01-28 07:41:18 +00:00
|
|
|
}
|
2020-11-06 08:09:51 +00:00
|
|
|
return threads_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
ByteBuffer CoreDump::create_notes_regions_data() const
|
|
|
|
{
|
|
|
|
ByteBuffer regions_data;
|
2021-04-06 23:20:29 +00:00
|
|
|
size_t region_index = 0;
|
|
|
|
for (auto& region : m_process->space().regions()) {
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
ByteBuffer memory_region_info_buffer;
|
|
|
|
ELF::Core::MemoryRegionInfo info {};
|
2020-11-11 20:02:39 +00:00
|
|
|
info.header.type = ELF::Core::NotesEntryHeader::Type::MemoryRegionInfo;
|
2020-11-06 08:09:51 +00:00
|
|
|
|
2021-04-06 23:20:29 +00:00
|
|
|
info.region_start = region->vaddr().get();
|
|
|
|
info.region_end = region->vaddr().offset(region->size()).get();
|
|
|
|
info.program_header_index = region_index++;
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
memory_region_info_buffer.append((void*)&info, sizeof(info));
|
2021-05-28 07:33:14 +00:00
|
|
|
// NOTE: The region name *is* null-terminated, so the following is ok:
|
2021-05-28 14:13:47 +00:00
|
|
|
auto name = region->name();
|
2021-05-30 17:59:03 +00:00
|
|
|
if (name.is_empty()) {
|
|
|
|
char null_terminator = '\0';
|
|
|
|
memory_region_info_buffer.append(&null_terminator, 1);
|
|
|
|
} else {
|
2021-05-28 14:13:47 +00:00
|
|
|
memory_region_info_buffer.append(name.characters_without_null_termination(), name.length() + 1);
|
2021-05-30 17:59:03 +00:00
|
|
|
}
|
2020-11-06 08:09:51 +00:00
|
|
|
|
|
|
|
regions_data += memory_region_info_buffer;
|
|
|
|
}
|
|
|
|
return regions_data;
|
|
|
|
}
|
|
|
|
|
2020-12-30 14:20:30 +00:00
|
|
|
ByteBuffer CoreDump::create_notes_metadata_data() const
|
|
|
|
{
|
|
|
|
ByteBuffer metadata_data;
|
|
|
|
|
|
|
|
ELF::Core::Metadata metadata {};
|
|
|
|
metadata.header.type = ELF::Core::NotesEntryHeader::Type::Metadata;
|
|
|
|
metadata_data.append((void*)&metadata, sizeof(metadata));
|
|
|
|
|
2021-06-29 20:07:36 +00:00
|
|
|
StringBuilder builder;
|
2021-06-29 20:27:11 +00:00
|
|
|
{
|
|
|
|
JsonObjectSerializer metadata_obj { builder };
|
|
|
|
for (auto& it : m_process->coredump_metadata())
|
|
|
|
metadata_obj.add(it.key, it.value);
|
|
|
|
}
|
2021-06-29 20:07:36 +00:00
|
|
|
builder.append(0);
|
|
|
|
metadata_data.append(builder.string_view().characters_without_null_termination(), builder.length());
|
2020-12-30 14:20:30 +00:00
|
|
|
|
|
|
|
return metadata_data;
|
|
|
|
}
|
|
|
|
|
2020-11-06 08:09:51 +00:00
|
|
|
ByteBuffer CoreDump::create_notes_segment_data() const
|
|
|
|
{
|
|
|
|
ByteBuffer notes_buffer;
|
|
|
|
|
2020-12-30 12:19:53 +00:00
|
|
|
notes_buffer += create_notes_process_data();
|
2020-11-06 08:09:51 +00:00
|
|
|
notes_buffer += create_notes_threads_data();
|
|
|
|
notes_buffer += create_notes_regions_data();
|
2020-12-30 14:20:30 +00:00
|
|
|
notes_buffer += create_notes_metadata_data();
|
2020-11-06 08:09:51 +00:00
|
|
|
|
2020-11-11 20:02:39 +00:00
|
|
|
ELF::Core::NotesEntryHeader null_entry {};
|
|
|
|
null_entry.type = ELF::Core::NotesEntryHeader::Type::Null;
|
2020-11-06 08:09:51 +00:00
|
|
|
notes_buffer.append(&null_entry, sizeof(null_entry));
|
|
|
|
|
|
|
|
return notes_buffer;
|
|
|
|
}
|
|
|
|
|
2020-12-22 08:59:14 +00:00
|
|
|
KResult CoreDump::write()
|
2020-11-06 08:09:51 +00:00
|
|
|
{
|
2021-02-08 14:45:40 +00:00
|
|
|
ScopedSpinLock lock(m_process->space().get_lock());
|
2020-11-06 08:09:51 +00:00
|
|
|
ProcessPagingScope scope(m_process);
|
|
|
|
|
|
|
|
ByteBuffer notes_segment = create_notes_segment_data();
|
|
|
|
|
2020-12-22 08:59:14 +00:00
|
|
|
auto result = write_elf_header();
|
|
|
|
if (result.is_error())
|
|
|
|
return result;
|
|
|
|
result = write_program_headers(notes_segment.size());
|
|
|
|
if (result.is_error())
|
|
|
|
return result;
|
|
|
|
result = write_regions();
|
|
|
|
if (result.is_error())
|
|
|
|
return result;
|
|
|
|
result = write_notes_segment(notes_segment);
|
|
|
|
if (result.is_error())
|
|
|
|
return result;
|
|
|
|
|
2021-03-26 15:46:20 +00:00
|
|
|
return m_fd->chmod(0600); // Make coredump file read/writable
|
2020-11-06 08:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|