summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-07-27 21:58:31 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-07-27 21:58:31 +0200
commit85a9ef05ef8c57c587df91023a132349786f0777 (patch)
treeff13b4cc4fff9967501c2994f819cc00ad012a8f /include
parentdeeb0a88017c4f7ecdd96543aa53ea3557307b6d (diff)
parent5fe555384c2b4e0edd9a11f55c4953b09b196637 (diff)
downloadbarebox-85a9ef05ef8c57c587df91023a132349786f0777.tar.gz
barebox-85a9ef05ef8c57c587df91023a132349786f0777.tar.xz
Merge branch 'for-next/elf'
Diffstat (limited to 'include')
-rw-r--r--include/bootm.h3
-rw-r--r--include/elf.h16
2 files changed, 16 insertions, 3 deletions
diff --git a/include/bootm.h b/include/bootm.h
index 7782de7a47..ef5148f31e 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -46,6 +46,9 @@ struct image_data {
/* if os is an uImage this will be provided */
struct uimage_handle *os;
+ /* if os is an elf file this will be provided */
+ struct elf_image *elf;
+
/* if os is a FIT image this will be provided */
struct fit_handle *os_fit;
diff --git a/include/elf.h b/include/elf.h
index 113728f08a..7970fd2c95 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -403,11 +403,20 @@ struct elf_image {
struct list_head list;
u8 class;
u64 entry;
- void *buf;
+ void *low_addr;
+ void *high_addr;
+ void *hdr_buf;
+ char *filename;
};
-struct elf_image *elf_load_image(void *buf);
-void elf_release_image(struct elf_image *elf);
+static inline size_t elf_get_mem_size(struct elf_image *elf)
+{
+ return elf->high_addr - elf->low_addr;
+}
+
+struct elf_image *elf_open(const char *filename);
+void elf_close(struct elf_image *elf);
+int elf_load(struct elf_image *elf);
#define ELF_GET_FIELD(__s, __field, __type) \
static inline __type elf_##__s##_##__field(struct elf_image *elf, void *arg) { \
@@ -420,6 +429,7 @@ static inline __type elf_##__s##_##__field(struct elf_image *elf, void *arg) { \
ELF_GET_FIELD(hdr, e_entry, u64)
ELF_GET_FIELD(hdr, e_phnum, u16)
ELF_GET_FIELD(hdr, e_phoff, u64)
+ELF_GET_FIELD(hdr, e_phentsize, u16)
ELF_GET_FIELD(hdr, e_type, u16)
ELF_GET_FIELD(phdr, p_paddr, u64)
ELF_GET_FIELD(phdr, p_filesz, u64)