1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

Kernel: Add ability to load interpreter instead of main program

When the main executable needs an interpreter, we load the requested
interpreter program, and pass to it an open file decsriptor to the main
executable via the auxiliary vector.

Note that we do not allocate a TLS region for the interpreter.
This commit is contained in:
Itamar 2020-10-10 12:13:21 +03:00 committed by Andreas Kling
parent 711c42e25e
commit 5b87904ab5
6 changed files with 219 additions and 151 deletions

View file

@ -40,8 +40,9 @@
namespace ELF {
Loader::Loader(const u8* buffer, size_t size, bool verbose_logging)
Loader::Loader(const u8* buffer, size_t size, String&& name, bool verbose_logging)
: m_image(buffer, size, verbose_logging)
, m_name(move(name))
{
if (m_image.is_valid())
m_symbol_count = m_image.symbol_count();
@ -101,7 +102,7 @@ bool Loader::layout()
program_header.alignment(),
program_header.is_readable(),
program_header.is_writable(),
String::format("elf-alloc-%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : ""));
String::format("%s-alloc-%s%s", m_name.is_empty() ? "elf" : m_name.characters(), program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : ""));
if (!allocated_section) {
failed = true;
return;
@ -133,7 +134,7 @@ bool Loader::layout()
program_header.is_readable(),
program_header.is_writable(),
program_header.is_executable(),
String::format("elf-map-%s%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "", program_header.is_executable() ? "x" : ""));
String::format("%s-map-%s%s%s", m_name.is_empty() ? "elf" : m_name.characters(), program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "", program_header.is_executable() ? "x" : ""));
if (!mapped_section) {
failed = true;
}