From 8231af9d8d759ae89c8214ca2410b0feab9dfb8c Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 22 Nov 2024 07:58:15 +0100 Subject: Add basic parsing for underlying ELF executables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The given initrd is a CPIO archive of multiple ELF executables. We are already able to parse the CPIO archive to detect where each file is located, this commit adds the mapping for each ELF executable to the corresponding task_struct. Note that this is still heavily under construction, since we cannot simply jump into the entry point of an executable as we have not yet setup the proper layout from performing context switches. Signed-off-by: Miquel Sabaté Solà --- test/test_initrd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test/test_initrd.c') diff --git a/test/test_initrd.c b/test/test_initrd.c index 3662eaa..73429b8 100644 --- a/test/test_initrd.c +++ b/test/test_initrd.c @@ -3,6 +3,17 @@ #include #include +#include +#include + +unsigned long init_stack[4][THREAD_SIZE / sizeof(unsigned long)]; + +struct task_struct tasks[4] = { + [0] = { .stack = init_stack[0] }, + [1] = { .stack = init_stack[1] }, + [2] = { .stack = init_stack[2] }, + [3] = { .stack = init_stack[3] }, +}; int main(void) { @@ -13,7 +24,7 @@ int main(void) long fsize = ftell(fh); rewind(fh); - char *contents = malloc((unsigned long)fsize + 1); + unsigned char *contents = malloc((unsigned long)fsize + 1); fread(contents, (unsigned long)fsize, 1, fh); fclose(fh); -- cgit v1.2.3