1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

LibELF: Add MemoryRegionInfo::object_name()

We had multiple implementations of this function, and it's a small
helper related to MemoryRegionInfo's region_name, so let's move it
there.
This commit is contained in:
Linus Groh 2020-12-29 13:02:36 +01:00 committed by Andreas Kling
parent c39323401c
commit e2e2b2c08e
2 changed files with 12 additions and 12 deletions

View file

@ -26,6 +26,7 @@
#pragma once
#include <AK/String.h>
#include <AK/Types.h>
#include <LibC/sys/arch/i386/regs.h>
@ -61,6 +62,16 @@ struct [[gnu::packed]] MemoryRegionInfo
uint32_t region_end;
uint16_t program_header_index;
char region_name[]; // Null terminated
String object_name() const
{
StringView memory_region_name { region_name };
if (memory_region_name.contains("Loader.so"))
return "Loader.so";
if (!memory_region_name.contains(":"))
return {};
return memory_region_name.substring_view(0, memory_region_name.find_first_of(":").value()).to_string();
}
};
}