summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2014-08-26 14:59:36 -0700
committerFurquan Shaikh <furquan@google.com>2014-09-23 22:26:57 +0200
commitb237c108991c46f9ed67130b57828bef1b1f423a (patch)
tree08b0cc0f9b9a45b0f94005e3d80ff252443509b7 /util
parent2af76f4bdc81df699bad55f65335ff518381d7dd (diff)
rmodtool: Allow rmodules with 0 relocations
Currently, rmodules with 0 relocations are not allowed. Fix this by skipping addition of .rmodules section on 0 relocs. Change-Id: I7a39cf409a5f2bc808967d2b5334a15891c4748e Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: http://review.coreboot.org/6774 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@google.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/rmodule.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/util/cbfstool/rmodule.c b/util/cbfstool/rmodule.c
index 95aff5423a..168d71a8f7 100644
--- a/util/cbfstool/rmodule.c
+++ b/util/cbfstool/rmodule.c
@@ -259,10 +259,8 @@ static int collect_relocations(struct rmod_context *ctx)
nrelocs = ctx->nrelocs;
INFO("%d relocations to be emitted.\n", nrelocs);
- if (!nrelocs) {
- ERROR("No valid relocations in file.\n");
- return -1;
- }
+ if (!nrelocs)
+ return 0;
/* Reset the counter for indexing into the array. */
ctx->nrelocs = 0;
@@ -536,10 +534,13 @@ write_elf(const struct rmod_context *ctx, const struct buffer *in,
goto out;
addr += ctx->phdr->p_filesz;
- ret = add_section(ew, &relocs, ".relocs", addr, buffer_size(&relocs));
- if (ret < 0)
- goto out;
- addr += buffer_size(&relocs);
+ if (ctx->nrelocs) {
+ ret = add_section(ew, &relocs, ".relocs", addr,
+ buffer_size(&relocs));
+ if (ret < 0)
+ goto out;
+ addr += buffer_size(&relocs);
+ }
if (total_size != addr) {
ret = add_section(ew, NULL, ".empty", addr, total_size - addr);