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.
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()?
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This PR adds a new module
elfto XTLDR, which allows to boot 32-bit and 64-bit ELF kernels.Proposed changes
elfmodulextimage.hTODO
Agreements
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_IDENTMaybe _ELF_IMAGE_IDENTITY ?
@@ -609,0 +621,4 @@} ELF_IDENT;/* ELF Program header types */typedef enum _ELF_PT_ELF_IMAGE_PROGRAM_TYPE ?
@@ -609,0 +652,4 @@} ELF_IMAGE_CONTEXT, *PELF_IMAGE_CONTEXT;/* 32-bit ELF image header structure */typedef struct _ELF32_HEADERMaybe _ELF_IMAGE_HEADER32?
@@ -609,0 +672,4 @@} ELF32_HEADER, *PELF32_HEADER;/* 64-bit ELF image header structure */typedef struct _ELF64_HEADER_ELF_IMAGE_HEADER64 ?
@@ -609,0 +692,4 @@} ELF64_HEADER, *PELF64_HEADER;/* 32-bit ELF program header structure */typedef struct _ELF32_PROGRAM_HEADER_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_ELF_IMAGE_PROGRAM_HEADER64?
@@ -0,0 +14,4 @@add_executable(elf ${XTLDR_ELF_SOURCE})# Add linker librariestarget_link_libraries(elf libxtos libxtldr)libxtos should not be needed, is it?
@@ -0,0 +8,4 @@#include <elf.h>/* ELF_O module information */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");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;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__XTLDR_MODULES_ELF_H ?
@@ -0,0 +44,4 @@BlXtLdrModuleMain(IN EFI_HANDLE ImageHandle,IN PEFI_SYSTEM_TABLE SystemTable);#endif /* __XTLDR_MODULES_ELF_O_H */__XTLDR_MODULES_ELF_H ?
Pull request closed