diff options
author | Sol Boucher <solb@chromium.org> | 2015-03-05 15:38:03 -0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-04-25 12:14:25 +0200 |
commit | 0e53931fee0178c4f4ac4e2e6b355b103b5e8c42 (patch) | |
tree | f38674ea0f24986093c5852115966fa27db2130a /util/cbfstool/rmodule.c | |
parent | c13ad6c6df709fda1d70743a860a406643620b9e (diff) |
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>
Diffstat (limited to 'util/cbfstool/rmodule.c')
-rw-r--r-- | util/cbfstool/rmodule.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/util/cbfstool/rmodule.c b/util/cbfstool/rmodule.c index 23eb25f58e..fa175db789 100644 --- a/util/cbfstool/rmodule.c +++ b/util/cbfstool/rmodule.c @@ -15,6 +15,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA */ +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -28,9 +29,9 @@ struct rmod_context; struct arch_ops { int arch; /* Determine if relocation is a valid type for the architecture. */ - int (*valid_type)(struct rmod_context *ctx, Elf64_Rela *rel); + int (*valid_type)(Elf64_Rela *rel); /* Determine if relocation should be emitted. */ - int (*should_emit)(struct rmod_context *ctx, Elf64_Rela *rel); + int (*should_emit)(Elf64_Rela *rel); }; struct rmod_context { @@ -62,7 +63,7 @@ struct rmod_context { /* * Architecture specific support operations. */ -static int valid_reloc_386(struct rmod_context *ctx, Elf64_Rela *rel) +static int valid_reloc_386(Elf64_Rela *rel) { int type; @@ -72,7 +73,7 @@ static int valid_reloc_386(struct rmod_context *ctx, Elf64_Rela *rel) return (type == R_386_32 || type == R_386_PC32); } -static int should_emit_386(struct rmod_context *ctx, Elf64_Rela *rel) +static int should_emit_386(Elf64_Rela *rel) { int type; @@ -82,7 +83,7 @@ static int should_emit_386(struct rmod_context *ctx, Elf64_Rela *rel) return (type == R_386_32); } -static int valid_reloc_arm(struct rmod_context *ctx, Elf64_Rela *rel) +static int valid_reloc_arm(Elf64_Rela *rel) { int type; @@ -94,7 +95,7 @@ static int valid_reloc_arm(struct rmod_context *ctx, Elf64_Rela *rel) type == R_ARM_CALL || type == R_ARM_JUMP24); } -static int should_emit_arm(struct rmod_context *ctx, Elf64_Rela *rel) +static int should_emit_arm(Elf64_Rela *rel) { int type; @@ -104,7 +105,7 @@ static int should_emit_arm(struct rmod_context *ctx, Elf64_Rela *rel) return (type == R_ARM_ABS32); } -static int valid_reloc_aarch64(struct rmod_context *ctx, Elf64_Rela *rel) +static int valid_reloc_aarch64(Elf64_Rela *rel) { int type; @@ -122,7 +123,7 @@ static int valid_reloc_aarch64(struct rmod_context *ctx, Elf64_Rela *rel) type == R_AARCH64_ADR_PREL_LO21); } -static int should_emit_aarch64(struct rmod_context *ctx, Elf64_Rela *rel) +static int should_emit_aarch64(Elf64_Rela *rel) { int type; @@ -176,13 +177,13 @@ static int for_each_reloc(struct rmod_context *ctx, int do_emit) for (j = 0; j < nrelocs; j++) { Elf64_Rela *r = &relocs[j]; - if (!ctx->ops->valid_type(ctx, r)) { + if (!ctx->ops->valid_type(r)) { ERROR("Invalid reloc type: %u\n", (unsigned int)ELF64_R_TYPE(r->r_info)); return -1; } - if (ctx->ops->should_emit(ctx, r)) { + if (ctx->ops->should_emit(r)) { int n = ctx->nrelocs; if (do_emit) ctx->emitted_relocs[n] = r->r_offset; @@ -306,7 +307,7 @@ static int vaddr_cmp(const void *a, const void *b) static int collect_relocations(struct rmod_context *ctx) { - int nrelocs; + Elf64_Xword nrelocs; /* * The relocs array in the pelf should only contain relocations that @@ -317,7 +318,7 @@ static int collect_relocations(struct rmod_context *ctx) return -1; nrelocs = ctx->nrelocs; - INFO("%d relocations to be emitted.\n", nrelocs); + INFO("%" PRIu64 " relocations to be emitted.\n", nrelocs); if (!nrelocs) return 0; @@ -457,7 +458,6 @@ static int write_elf(const struct rmod_context *ctx, const struct buffer *in, struct buffer *out) { - int i; int ret; int bit64; size_t loc; @@ -556,7 +556,7 @@ write_elf(const struct rmod_context *ctx, const struct buffer *in, ctx->xdr->put32(&rmod_header, 0); /* Write the relocations. */ - for (i = 0; i < ctx->nrelocs; i++) { + for (unsigned i = 0; i < ctx->nrelocs; i++) { if (bit64) ctx->xdr->put64(&relocs, ctx->emitted_relocs[i]); else |