Define ELF and auxiliary vector internally This removes any external ELF dependency from sel4runtime as the runtime now implements the minimal subset of ELF and auxiliary vector definitions internally. Signed-off-by: Curtis Millar <curtis@curtism.me>
diff --git a/include/mode/32/sel4runtime/mode/elf.h b/include/mode/32/sel4runtime/mode/elf.h index e164ae2..df55349 100644 --- a/include/mode/32/sel4runtime/mode/elf.h +++ b/include/mode/32/sel4runtime/mode/elf.h
@@ -9,7 +9,7 @@ * * @TAG(DATA61_BSD) */ -#include <elf.h> +#include <sel4runtime/elf.h> #pragma once // The elf header is a different structure depending on the word size of
diff --git a/include/mode/64/sel4runtime/mode/elf.h b/include/mode/64/sel4runtime/mode/elf.h index 515e9b4..cd18346 100644 --- a/include/mode/64/sel4runtime/mode/elf.h +++ b/include/mode/64/sel4runtime/mode/elf.h
@@ -9,7 +9,7 @@ * * @TAG(DATA61_BSD) */ -#include <elf.h> +#include <sel4runtime/elf.h> #pragma once
diff --git a/include/sel4runtime/auxv.h b/include/sel4runtime/auxv.h index 36e5b63..66a6334 100644 --- a/include/sel4runtime/auxv.h +++ b/include/sel4runtime/auxv.h
@@ -11,6 +11,17 @@ */ #pragma once +// Standard auciliary vector values +#define AT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define AT_PHDR 3 +#define AT_PHENT 4 +#define AT_PHNUM 5 +#define PT_TLS 7 +#define PT_NUM 8 +#define AT_SYSINFO 32 + // seL4-specific auxiliary vector values. #define AT_SEL4_BOOT_INFO 64 #define AT_SEL4_CSPACE_DESCRIPTOR 65
diff --git a/include/sel4runtime/elf.h b/include/sel4runtime/elf.h new file mode 100644 index 0000000..226de2d --- /dev/null +++ b/include/sel4runtime/elf.h
@@ -0,0 +1,78 @@ +/* + * @TAG(OTHER_MIT) + */ +/* + * Copyright © 2005-2014 Rich Felker, et al. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include <sel4runtime/stdint.h> + +/* + * This is a minimal definition of the ELF headers that is sufficient + * for sel4runtime to pass through program headers. + */ + +typedef sel4runtime_uint16_t Elf32_Half; +typedef sel4runtime_uint16_t Elf64_Half; + +typedef sel4runtime_uint32_t Elf32_Word; +typedef sel4runtime_int32_t Elf32_Sword; +typedef sel4runtime_uint32_t Elf64_Word; +typedef sel4runtime_int32_t Elf64_Sword; + +typedef sel4runtime_uint64_t Elf32_Xword; +typedef sel4runtime_int64_t Elf32_Sxword; +typedef sel4runtime_uint64_t Elf64_Xword; +typedef sel4runtime_int64_t Elf64_Sxword; + +typedef sel4runtime_uint32_t Elf32_Addr; +typedef sel4runtime_uint64_t Elf64_Addr; + +typedef sel4runtime_uint32_t Elf32_Off; +typedef sel4runtime_uint64_t Elf64_Off; + +typedef sel4runtime_uint16_t Elf32_Section; +typedef sel4runtime_uint16_t Elf64_Section; + +typedef struct { + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +typedef struct { + Elf64_Word p_type; + Elf64_Word p_flags; + Elf64_Off p_offset; + Elf64_Addr p_vaddr; + Elf64_Addr p_paddr; + Elf64_Xword p_filesz; + Elf64_Xword p_memsz; + Elf64_Xword p_align; +} Elf64_Phdr;
diff --git a/include/sel4runtime/start.h b/include/sel4runtime/start.h index e2629af..0c5df80 100644 --- a/include/sel4runtime/start.h +++ b/include/sel4runtime/start.h
@@ -12,7 +12,7 @@ #pragma once #include <sel4runtime/auxv.h> -#include <elf.h> +#include <sel4runtime/elf.h> #include <sel4runtime/mode/elf.h> // Entry into C program.