summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2014-08-26 13:52:30 -0500
committerAaron Durbin <adurbin@google.com>2014-08-27 03:20:27 +0200
commit518a322d5880a4dd29a943ec474484cd8b48876f (patch)
tree59f0f82feffb71c513e0cc01bf4f1f742f5baebd
parent22d0ca0ceb802675cdcab1472b8477066f729373 (diff)
downloadcoreboot-518a322d5880a4dd29a943ec474484cd8b48876f.tar.xz
rmodtool: correct final memory size calculation
Apparently when I originally wrote this I confused myself to no end. The code/data of an rmodule has a set memory size which is associated with the .payload section. The relocation entries may increase the overall footprint of the memory size if the rmodule has no bss but a lot of relocations. Therefore, just compare relocation entries size plus the file size of the .payload section with the memory size of the paylod section. The .empty section is added only when we have not met the final target size. Change-Id: I5521dff048ae64a9b6e3c8f84a390eba37c7d0f5 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/6767 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com>
-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,