cbfstool: extract rmodules as ELFs properly

With the previous ELF stage extract support the resulting
ELF files wouldn't handle rmodules correctly in that the
rmodule header as well as the relocations were a part of
the program proper. Instead, try an initial pass at
converting the stage as if it was an rmodule first. If it
doesn't work fall back on the normal ELF extraction.

TEST=Pulled an rmodule out of Chrome OS shellball. Manually
     matched up the metadata and relocations.

Change-Id: Iaf222f92d145116ca4dfaa955fb7278e583161f2
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/12222
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Aaron Durbin
2015-10-28 11:39:34 -05:00
parent cedcb882c1
commit 694fd13390
3 changed files with 190 additions and 0 deletions

View File

@ -88,4 +88,11 @@ int rmodule_collect_relocations(struct rmod_context *c, struct reloc_filter *f);
/* Clean up the memory consumed by the rmdoule context. */
void rmodule_cleanup(struct rmod_context *ctx);
/*
* Create an ELF file from the passed in rmodule in the buffer. The buffer
* contents will be replaced with an ELF file. Returns 1 if buff doesn't
* contain an rmodule and < 0 on failure, 0 on success.
*/
int rmodule_stage_to_elf(Elf64_Ehdr *ehdr, struct buffer *buff);
#endif /* TOOL_RMODULE_H */