From b09d5ece2f9799e9271e2f618b34c340e23d7725 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Wed, 4 Nov 2015 16:12:24 -0800 Subject: [PATCH] util: signer: fix nonzero offset binary image signing bug When signer code was ported and enhanced to work with binaries (in addition to hex), a bug was introduced, where the signed image is considered to always to be based at the bottom of the flash. In fact the image could be anywhere in the flash, the actual address derived from the input elf file should be used. BRANCH=none BUG=chrome-os-partner:43025 TEST=verified that when enabled, RW image is signed properly (build/cr50/RW/ec.RW.flat starts with a signature). Change-Id: I194bd02f932529165adcbebf4bcbd9020fc261dc Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/311314 Reviewed-by: Bill Richardson --- util/signer/image.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/signer/image.cc b/util/signer/image.cc index e82d3846ad..b0657b8892 100644 --- a/util/signer/image.cc +++ b/util/signer/image.cc @@ -324,7 +324,7 @@ void Image::generate(const std::string& filename, bool hex_output) const { if (hex_output) toIntelHex(fout); else // TODO: we don't expect write to fail, can be made more robust. - fwrite(mem_, 1, high_ - base_, fout); + fwrite(mem_ + base_, 1, high_ - base_, fout); fclose(fout); }