summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/cbfstool/rmodule.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/util/cbfstool/rmodule.c b/util/cbfstool/rmodule.c
index a5730f12ba..95aff5423a 100644
--- a/util/cbfstool/rmodule.c
+++ b/util/cbfstool/rmodule.c
@@ -518,11 +518,11 @@ write_elf(const struct rmod_context *ctx, const struct buffer *in,
* is considered a part of the program.
*/
total_size += buffer_size(&rmod_header);
- total_size += ctx->phdr->p_memsz;
- if (buffer_size(&relocs) + ctx->phdr->p_filesz > total_size) {
- total_size -= ctx->phdr->p_memsz;
+ if (buffer_size(&relocs) + ctx->phdr->p_filesz > ctx->phdr->p_memsz) {
total_size += buffer_size(&relocs);
total_size += ctx->phdr->p_filesz;
+ } else {
+ total_size += ctx->phdr->p_memsz;
}
ret = add_section(ew, &rmod_header, ".header", addr,