cbfstool: add ELF header initialization helper

In order for one to extract ELF files from cbfs it's
helpful to have common code which creates a default
executable ELF header for the provided constraints.

BUG=None
TEST=With follow up patch am able to extract out romstage
     as an ELF file.

Change-Id: Ib8f2456f41b79c6c0430861e33e8b909725013f1
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/12218
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Aaron Durbin
2015-10-27 16:21:55 -05:00
parent 1762502929
commit 4f930c9649
2 changed files with 35 additions and 0 deletions

View File

@@ -76,6 +76,17 @@ elf_headers(const struct buffer *pinput,
/* ELF writing support. */
struct elf_writer;
/*
* Initialize a 64-bit ELF header provided the inputs. While the structure
* is a 64-bit header one can specify a 32-bit machine. The 64-bit version
* is just used as a common structure. If one wants to specify the entry
* point, for example, the caller can set it after filling in the common
* bits. The machine, nbits, and endian values should be from the ELF
* definitions (e.g. EM_386, ELFCLASS32, and ELFDATA2LSB) found in elf.h
* with no endian conversion required.
*/
void elf_init_eheader(Elf64_Ehdr *ehdr, int machine, int nbits, int endian);
/*
* Initialize a new ELF writer. Deafult machine type, endianness, etc is
* copied from the passed in Elf64_Ehdr. Returns NULL on failure, valid