summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/lib/elf.h30
-rw-r--r--api/libc/stdlib.h3
-rw-r--r--api/libc/wchar.h2
-rw-r--r--api/posix/sys/mman.h2
4 files changed, 33 insertions, 4 deletions
diff --git a/api/lib/elf.h b/api/lib/elf.h
index 951fc25..ea0d6cc 100644
--- a/api/lib/elf.h
+++ b/api/lib/elf.h
@@ -5,13 +5,37 @@
#include <stdbool.h>
#include <stddef.h>
+#include <posix/sys/types.h>
+
#ifdef __x86_64__
# define elf_validate elf64_validate
# define elf_size elf64_size
#endif
-bool elf64_validate(Elf64_Ehdr *ehdr, unsigned type, unsigned machine);
-size_t elf64_size(Elf64_Ehdr *ehdr, Elf64_Phdr *phdr);
-void *elf64_dt_ptr(void *base, Elf64_Dyn *dyntab, unsigned long dt_type);
+struct linear_buffer
+{
+ char *base;
+ size_t length;
+};
+
+struct elf64_image
+{
+ struct linear_buffer buffer;
+ struct
+ {
+ Elf64_Ehdr *file;
+ Elf64_Phdr *segments;
+ Elf64_Shdr *sections;
+ }
+ headers;
+};
+
+bool elf64_validate(Elf64_Ehdr const *ehdr, unsigned type, unsigned machine);
+bool elf64_validate_fd(int fd, unsigned type, unsigned machine);
+size_t elf64_size(Elf64_Ehdr const *ehdr, Elf64_Phdr *phdr);
+size_t elf64_size_fd(int fd);
+ssize_t elf64_load_segments(int fd, size_t buffer_size, char buffer[buffer_size]);
+void *elf64_dt_ptr(char *base, Elf64_Dyn *dyntab, unsigned long dt_type);
uintptr_t elf64_dt_val(Elf64_Dyn *dyntab, unsigned long dt_type);
+struct elf64_image elf64_open(const char *path);
diff --git a/api/libc/stdlib.h b/api/libc/stdlib.h
index 76a78eb..d1f3d3b 100644
--- a/api/libc/stdlib.h
+++ b/api/libc/stdlib.h
@@ -3,4 +3,7 @@
#include <stddef.h>
size_t mbstowcs(wchar_t *dst, const char *src, size_t length);
+void *malloc(size_t size);
+void *calloc(size_t count, size_t size);
+void free(void *block);
diff --git a/api/libc/wchar.h b/api/libc/wchar.h
index 4dd339d..350c209 100644
--- a/api/libc/wchar.h
+++ b/api/libc/wchar.h
@@ -3,4 +3,4 @@
#include <stddef.h>
size_t wcslen(const wchar_t *s);
-
+wchar_t *wcsdup(const wchar_t *s);
diff --git a/api/posix/sys/mman.h b/api/posix/sys/mman.h
index dde74c0..dd8d6f5 100644
--- a/api/posix/sys/mman.h
+++ b/api/posix/sys/mman.h
@@ -1,5 +1,7 @@
#pragma once
+#define MAP_FAILED ((void *) 1)
+
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
int munmap(void *addr, size_t length);