util/cbfstool: Do minor fixes
- Fix truncation of stage->loadaddr by replacing be32toh with be64toh - Remove some redundant htobe32 calls - Address checkpatch lints Change-Id: I81b8cfd9eb0b2feffefaa9338bac9ae209e39a3c Signed-off-by: Alex James <theracermaster@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60933 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
88e37c7aff
commit
b3398ba562
|
@ -54,7 +54,7 @@ static struct typedesc_t filetypes[] unused = {
|
||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + be32toh((_p)->offset))) )
|
#define CBFS_SUBHEADER(_p) ((void *) ((((uint8_t *) (_p)) + be32toh((_p)->offset))))
|
||||||
|
|
||||||
static inline size_t cbfs_file_attr_hash_size(enum vb2_hash_algorithm algo)
|
static inline size_t cbfs_file_attr_hash_size(enum vb2_hash_algorithm algo)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,9 +86,8 @@ static int cbfs_fix_legacy_size(struct cbfs_image *image, char *hdr_loc)
|
||||||
entry && cbfs_is_valid_entry(image, entry);
|
entry && cbfs_is_valid_entry(image, entry);
|
||||||
entry = cbfs_find_next_entry(image, entry)) {
|
entry = cbfs_find_next_entry(image, entry)) {
|
||||||
/* Is the header guarded by a CBFS file entry? Then exit */
|
/* Is the header guarded by a CBFS file entry? Then exit */
|
||||||
if (((char *)entry) + be32toh(entry->offset) == hdr_loc) {
|
if (((char *)entry) + be32toh(entry->offset) == hdr_loc)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
last = entry;
|
last = entry;
|
||||||
}
|
}
|
||||||
if ((char *)first < (char *)hdr_loc &&
|
if ((char *)first < (char *)hdr_loc &&
|
||||||
|
@ -525,11 +524,9 @@ int cbfs_compact_instance(struct cbfs_image *image)
|
||||||
size_t cur_size;
|
size_t cur_size;
|
||||||
size_t empty_metadata_size;
|
size_t empty_metadata_size;
|
||||||
size_t spill_size;
|
size_t spill_size;
|
||||||
uint32_t type = htobe32(cur->type);
|
|
||||||
|
|
||||||
/* Current entry is empty. Kepp track of it. */
|
/* Current entry is empty. Kepp track of it. */
|
||||||
if ((type == htobe32(CBFS_TYPE_NULL)) ||
|
if (cur->type == CBFS_TYPE_NULL || cur->type == CBFS_TYPE_DELETED) {
|
||||||
(type == htobe32(CBFS_TYPE_DELETED))) {
|
|
||||||
prev = cur;
|
prev = cur;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1025,7 @@ static int cbfs_stage_make_elf(struct buffer *buff, uint32_t arch,
|
||||||
memset(&shdr, 0, sizeof(shdr));
|
memset(&shdr, 0, sizeof(shdr));
|
||||||
shdr.sh_type = SHT_NOBITS;
|
shdr.sh_type = SHT_NOBITS;
|
||||||
shdr.sh_flags = SHF_WRITE | SHF_ALLOC;
|
shdr.sh_flags = SHF_WRITE | SHF_ALLOC;
|
||||||
shdr.sh_addr = be32toh(stage->loadaddr) + buffer_size(buff);
|
shdr.sh_addr = be64toh(stage->loadaddr) + buffer_size(buff);
|
||||||
shdr.sh_size = empty_sz;
|
shdr.sh_size = empty_sz;
|
||||||
if (elf_writer_add_section(ew, &shdr, &b, ".empty")) {
|
if (elf_writer_add_section(ew, &shdr, &b, ".empty")) {
|
||||||
ERROR("Unable to add ELF section: .empty\n");
|
ERROR("Unable to add ELF section: .empty\n");
|
||||||
|
|
Loading…
Reference in New Issue