cbfstool: add ELF writing support
In order to generate rmodules in the format of ELF files there needs to be support for writing out ELF files. The ELF writer is fairly simple. It accpets sections that can be associated with an optional buffer (file data). For each section flagged with SHF_ALLOC a PT_LOAD segment is generated. There isn't smart merging of the sections into a single PT_LOAD segment. Change-Id: I4d1a11f2e65be2369fb3f8bff350cbb28e14c89d Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5377 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
committed by
Stefan Reinauer
parent
8089f17806
commit
36be8135d7
@@ -74,4 +74,35 @@ elf_headers(const struct buffer *pinput,
|
||||
Elf64_Phdr **pphdr,
|
||||
Elf64_Shdr **pshdr);
|
||||
|
||||
/* ELF writing support. */
|
||||
struct elf_writer;
|
||||
|
||||
/*
|
||||
* Initialize a new ELF writer. Deafult machine type, endianness, etc is
|
||||
* copied from the passed in Elf64_Ehdr. Returns NULL on failure, valid
|
||||
* pointer on success.
|
||||
*/
|
||||
struct elf_writer *elf_writer_init(const Elf64_Ehdr *ehdr);
|
||||
|
||||
/*
|
||||
* Clean up any internal state represented by ew. Aftewards the elf_writer
|
||||
* is invalid.
|
||||
*/
|
||||
void elf_writer_destroy(struct elf_writer *ew);
|
||||
|
||||
/*
|
||||
* Add a section to the ELF file. Section type, flags, and memsize are
|
||||
* maintained from the passed in Elf64_Shdr. The buffer represents the
|
||||
* content of the section while the name is the name of section itself.
|
||||
* Returns < 0 on error, 0 on success.
|
||||
*/
|
||||
int elf_writer_add_section(struct elf_writer *ew, const Elf64_Shdr *shdr,
|
||||
struct buffer *contents, const char *name);
|
||||
|
||||
/*
|
||||
* Serialize the ELF file to the output buffer. Return < 0 on error,
|
||||
* 0 on success.
|
||||
*/
|
||||
int elf_writer_serialize(struct elf_writer *ew, struct buffer *out);
|
||||
|
||||
#endif /* ELFPARSING_H */
|
||||
|
Reference in New Issue
Block a user