WIP: ELF Module for XTLDR #8

Closed
Ghost wants to merge 5 commits from (deleted):master into master

This PR adds a new module elf to XTLDR, which allows to boot 32-bit and 64-bit ELF kernels.

Proposed changes

  • Added elf module
  • Added relevant structures to xtimage.h

TODO

  • Parse ELF header and save relevant information to ELF image context
  • Load program sections as per the PT_LOAD program headers
  • Perform relocations as per the PT_DYNAMIC program header(s)
  • Test the functionality of this module (loading a simple barebones ELF kernel)

Agreements

  • I have read the Contributors License Agreement and I consent to those terms.
This PR adds a new module `elf` to XTLDR, which allows to boot 32-bit and 64-bit ELF kernels. ## Proposed changes - Added `elf` module - Added relevant structures to `xtimage.h` ## TODO - [x] Parse ELF header and save relevant information to ELF image context - [x] Load program sections as per the PT_LOAD program headers - [ ] Perform relocations as per the PT_DYNAMIC program header(s) - [ ] Test the functionality of this module (loading a simple barebones ELF kernel) ## Agreements - [x] I have read the Contributors License Agreement and I consent to those terms.
Ghost added 1 commit 2024-01-10 17:49:53 +01:00
Ghost added 1 commit 2024-01-10 18:08:30 +01:00
Ghost added 1 commit 2024-01-10 18:22:47 +01:00
belliash reviewed 2024-01-12 19:24:22 +01:00
belliash left a comment
Owner

I have done some initial review.

I have done some initial review.
@@ -607,2 +607,4 @@
} PECOFF_IMAGE_RESOURCE_DATA_ENTRY, *PPECOFF_IMAGE_RESOURCE_DATA_ENTRY;
/* ELF identities */
typedef enum _ELF_IDENT
Owner

Maybe _ELF_IMAGE_IDENTITY ?

Maybe _ELF_IMAGE_IDENTITY ?
@@ -609,0 +621,4 @@
} ELF_IDENT;
/* ELF Program header types */
typedef enum _ELF_PT
Owner

_ELF_IMAGE_PROGRAM_TYPE ?

_ELF_IMAGE_PROGRAM_TYPE ?
@@ -609,0 +652,4 @@
} ELF_IMAGE_CONTEXT, *PELF_IMAGE_CONTEXT;
/* 32-bit ELF image header structure */
typedef struct _ELF32_HEADER
Owner

Maybe _ELF_IMAGE_HEADER32?

Maybe _ELF_IMAGE_HEADER32?
@@ -609,0 +672,4 @@
} ELF32_HEADER, *PELF32_HEADER;
/* 64-bit ELF image header structure */
typedef struct _ELF64_HEADER
Owner

_ELF_IMAGE_HEADER64 ?

_ELF_IMAGE_HEADER64 ?
@@ -609,0 +692,4 @@
} ELF64_HEADER, *PELF64_HEADER;
/* 32-bit ELF program header structure */
typedef struct _ELF32_PROGRAM_HEADER
Owner

_ELF_IMAGE_PROGRAM_HEADER32?

_ELF_IMAGE_PROGRAM_HEADER32?
@@ -609,0 +705,4 @@
} ELF32_PROGRAM_HEADER, *PELF32_PROGRAM_HEADER;
/* 64-bit ELF program header structure */
typedef struct _ELF64_PROGRAM_HEADER
Owner

_ELF_IMAGE_PROGRAM_HEADER64?

_ELF_IMAGE_PROGRAM_HEADER64?
@@ -0,0 +14,4 @@
add_executable(elf ${XTLDR_ELF_SOURCE})
# Add linker libraries
target_link_libraries(elf libxtos libxtldr)
Owner

libxtos should not be needed, is it?

libxtos should not be needed, is it?
@@ -0,0 +8,4 @@
#include <elf.h>
/* ELF_O module information */
Owner

ELF module information? Looks like a typo.

ELF module information? Looks like a typo.
@@ -0,0 +124,4 @@
if(Status != STATUS_EFI_SUCCESS)
{
/* Memory allocation failure */
XtLdrProtocol->Debug.Print(L"ERROR: Memory pool allocation failure\n");
Owner

I suggest to print status code as well where possible.

I suggest to print status code as well where possible.
@@ -0,0 +204,4 @@
ImageData->Header32->e_ident[EI_MAG3] != 0x46)
{
/* ELF file header is invalid */
return STATUS_EFI_INVALID_PARAMETER;
Owner

XTBL_EXECUTABLE_IMAGE_PROTOCOL expects some validation routine. Could you reconsider creating ElfVerifyImage() routine and just calling it from ElfLoadImage()?

XTBL_EXECUTABLE_IMAGE_PROTOCOL expects some validation routine. Could you reconsider creating ElfVerifyImage() routine and just calling it from ElfLoadImage()?
@@ -0,0 +6,4 @@
* DEVELOPERS: Jozef Nagy <schkwve@gmail.com>
*/
#ifndef __XTLDR_MODULES_ELF_O_H
Owner

__XTLDR_MODULES_ELF_H ?

__XTLDR_MODULES_ELF_H ?
@@ -0,0 +44,4 @@
BlXtLdrModuleMain(IN EFI_HANDLE ImageHandle,
IN PEFI_SYSTEM_TABLE SystemTable);
#endif /* __XTLDR_MODULES_ELF_O_H */
Owner

__XTLDR_MODULES_ELF_H ?

__XTLDR_MODULES_ELF_H ?
Ghost added 1 commit 2024-01-12 21:34:08 +01:00
Ghost added 1 commit 2024-01-17 15:35:54 +01:00
Ghost closed this pull request 2025-03-19 23:47:17 +01:00

Pull request closed

Sign in to join this conversation.
No description provided.