Add multi-architecture support to cbfstool

This is an initial re-factoring of CBFS code to enable multiple
architectures. To achieve a clean solution, an additional field
describing the architecture has to be added to the master header.
Hence we also increase the version number in the master header.

Change-Id: Icda681673221f8c27efbc46f16c2c5682b16a265
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/1944
Tested-by: build bot (Jenkins)
This commit is contained in:
David Hendricks
2012-11-16 14:48:22 -08:00
committed by Stefan Reinauer
parent 11a20b614e
commit 90ca3b6bd7
11 changed files with 288 additions and 71 deletions

View File

@@ -35,7 +35,7 @@ int parse_elf_to_payload(unsigned char *input, unsigned char **output,
comp_algo algo)
{
Elf32_Phdr *phdr;
Elf32_Ehdr *ehdr;
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) input;
Elf32_Shdr *shdr;
char *header;
char *strtab;
@@ -48,16 +48,20 @@ int parse_elf_to_payload(unsigned char *input, unsigned char **output,
int i;
if(!iself(input)){
printf("Fatal error: the payload file is not in ELF format!\n");
exit(1);
fprintf(stderr, "E: The payload file is not in ELF format!\n");
return -1;
}
if (!((ehdr->e_machine == EM_ARM) && (arch == CBFS_ARCHITECTURE_ARMV7)) &&
!((ehdr->e_machine == EM_386) && (arch == CBFS_ARCHITECTURE_X86))) {
fprintf(stderr, "E: The payload file has the wrong architecture\n");
return -1;
}
comp_func_ptr compress = compression_function(algo);
if (!compress)
return -1;
ehdr = (Elf32_Ehdr *) input;
headers = ehdr->e_phnum;
header = (char *)ehdr;