cbfstool: Clean up in preparation for adding new files

This enables more warnings on the cbfstool codebase and fixes the
issues that surface as a result. A memory leak that used to occur
when compressing files with lzma is also found and fixed.
Finally, there are several fixes for the Makefile:
 - Its autodependencies used to be broken because the target for
   the .dependencies file was misnamed; this meant that Make
   didn't know how to rebuild the file, and so would silently
   skip the step of updating it before including it.
 - The ability to build to a custom output directory by defining
   the obj variable had bitrotted.
 - The default value of the obj variable was causing implicit
   rules not to apply when specifying a file as a target without
   providing a custom value for obj.
 - Add a distclean target for removing the .dependencies file.

BUG=chromium:461875
TEST=Build an image with cbfstool both before and after.
BRANCH=None

Change-Id: I951919d63443f2b053c2e67c1ac9872abc0a43ca
Signed-off-by: Sol Boucher <solb@chromium.org>
Original-Commit-Id: 49293443b4e565ca48d284e9a66f80c9c213975d
Original-Change-Id: Ia7350c2c3306905984cfa711d5fc4631f0b43d5b
Original-Signed-off-by: Sol Boucher <solb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/257340
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-on: http://review.coreboot.org/9937
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Sol Boucher
2015-03-05 15:38:03 -08:00
committed by Patrick Georgi
parent c13ad6c6df
commit 0e53931fee
14 changed files with 121 additions and 89 deletions

View File

@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <unistd.h>
#include <getopt.h>
@@ -104,8 +105,10 @@ static int cbfs_add_integer_component(const char *cbfs_name,
goto done;
}
if (cbfs_add_entry(&image, &buffer, name, CBFS_COMPONENT_RAW, param.baseaddress) != 0) {
ERROR("Failed to add %llu into ROM image as '%s'.\n", (long long unsigned)u64val, name);
if (cbfs_add_entry(&image, &buffer, name, CBFS_COMPONENT_RAW, offset) !=
0) {
ERROR("Failed to add %llu into ROM image as '%s'.\n",
(long long unsigned)u64val, name);
goto done;
}
@@ -189,8 +192,8 @@ static int cbfstool_convert_mkstage(struct buffer *buffer, uint32_t *offset)
{
struct buffer output;
int ret;
ret = parse_elf_to_stage(buffer, &output, param.arch, param.algo,
offset, param.ignore_section);
ret = parse_elf_to_stage(buffer, &output, param.algo, offset,
param.ignore_section);
if (ret != 0)
return -1;
buffer_delete(buffer);
@@ -205,7 +208,7 @@ static int cbfstool_convert_mkpayload(struct buffer *buffer,
struct buffer output;
int ret;
/* per default, try and see if payload is an ELF binary */
ret = parse_elf_to_payload(buffer, &output, param.arch, param.algo);
ret = parse_elf_to_payload(buffer, &output, param.algo);
/* If it's not an ELF, see if it's a UEFI FV */
if (ret != 0)
@@ -641,6 +644,11 @@ static void usage(char *name)
" update-fit -n MICROCODE_BLOB_NAME -x EMTPY_FIT_ENTRIES\n "
"Updates the FIT table with microcode entries\n"
"\n"
"OFFSETs:\n"
" Numbers accompanying -b, -H, and -o switches may be provided\n"
" in two possible formats: if their value is greater than\n"
" 0x80000000, they are interpreted as a top-aligned x86 memory\n"
" address; otherwise, they are treated as an offset into flash.\n"
"ARCHes:\n"
" arm64, arm, mips, x86\n"
"TYPEs:\n", name, name