summaryrefslogtreecommitdiff
path: root/util/cbfstool/elfparsing.h
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2014-03-05 13:09:55 -0600
committerAaron Durbin <adurbin@google.com>2014-03-14 21:50:42 +0100
commitd0f61659238c3ed79fecf841c58cabedbf936ac8 (patch)
treee828bd0807ffe8c6ab592e066283d1fb0e14a31b /util/cbfstool/elfparsing.h
parent19a11d6fe9593e585aff8a5787d25e38faa3d88c (diff)
downloadcoreboot-d0f61659238c3ed79fecf841c58cabedbf936ac8.tar.xz
cbfstool: introduce struct parsed_elf and parse_elf()
In order to make the ELF parsing more flexible introduce a parse_elf() function which takes a struct parsed_elf parameter. In addition take a flags parameter which instructs the ELF parser as to what data within the ELF file should be parsed. Change-Id: I3e30e84bf8043c3df96a6ab56cd077eef2632173 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5373 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Diffstat (limited to 'util/cbfstool/elfparsing.h')
-rw-r--r--util/cbfstool/elfparsing.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/cbfstool/elfparsing.h b/util/cbfstool/elfparsing.h
index 3cfa1cd6ba..4ad46b3928 100644
--- a/util/cbfstool/elfparsing.h
+++ b/util/cbfstool/elfparsing.h
@@ -22,6 +22,31 @@
struct buffer;
+struct parsed_elf {
+ Elf64_Ehdr ehdr;
+ Elf64_Phdr *phdr;
+ Elf64_Shdr *shdr;
+};
+
+#define ELF_PARSE_PHDR (1 << 0)
+#define ELF_PARSE_SHDR (1 << 1)
+
+#define ELF_PARSE_ALL (-1)
+
+/*
+ * Parse an ELF file contained within provide struct buffer. The ELF header
+ * is always parsed while the flags value containing the ELF_PARSE_* values
+ * determine if other parts of the ELF file will be parsed as well.
+ * Returns 0 on success, < 0 error.
+ */
+int parse_elf(const struct buffer *pinput, struct parsed_elf *pelf, int flags);
+
+/*
+ * Clean up memory associated with parsed_elf.
+ */
+void parsed_elf_destroy(struct parsed_elf *pelf);
+
+
int
elf_headers(const struct buffer *pinput,
uint32_t arch,