mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 22:27:44 +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:
parent
711c42e25e
commit
5b87904ab5
6 changed files with 219 additions and 151 deletions
|
@ -421,6 +421,25 @@ public:
|
|||
|
||||
int exec(String path, Vector<String> arguments, Vector<String> environment, int recusion_depth = 0);
|
||||
|
||||
struct LoadResult {
|
||||
FlatPtr load_offset { 0 };
|
||||
FlatPtr entry_eip { 0 };
|
||||
size_t size { 0 };
|
||||
FlatPtr program_headers { 0 };
|
||||
size_t num_program_headers { 0 };
|
||||
AK::WeakPtr<Region> tls_region;
|
||||
size_t tls_size { 0 };
|
||||
size_t tls_alignment { 0 };
|
||||
};
|
||||
|
||||
enum class ShouldAllocateTls {
|
||||
No = 0,
|
||||
Yes,
|
||||
};
|
||||
|
||||
int load(NonnullRefPtr<FileDescription> main_program_description, RefPtr<FileDescription> interpreter_description);
|
||||
KResultOr<LoadResult> load_elf_object(FileDescription& object_description, FlatPtr load_offset, ShouldAllocateTls);
|
||||
|
||||
bool is_superuser() const
|
||||
{
|
||||
return m_euid == 0;
|
||||
|
@ -563,6 +582,7 @@ private:
|
|||
ThreadID m_exec_tid { 0 };
|
||||
FlatPtr m_load_offset { 0U };
|
||||
FlatPtr m_entry_eip { 0U };
|
||||
int m_main_program_fd { -1 };
|
||||
|
||||
OwnPtr<ThreadTracer> m_tracer;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue