From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexandru Gagniuc Date: Mon, 17 May 2021 11:38:40 -0500 Subject: [PATCH 18/18] [UNTESTED] image: Add support for relocating crypto_algos in linker lists In-Reply-To: <20210517163840.839097-1-mr.nuke.me@gmail.com> References: <20210517163840.839097-1-mr.nuke.me@gmail.com> Message-ID: <20210517163840.839097-19-mr.nuke.me@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Function pointers from crypto_algos array are relocated, when NEEDS_MANUAL_RELOC is set. This relocation doesn't happen if the algo is placed in a linker list. Implement this relocation. Signed-off-by: Alexandru Gagniuc Reviewed-by: Simon Glass --- common/image-sig.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/image-sig.c b/common/image-sig.c index 498cd78af4..5c7ddd984d 100644 --- a/common/image-sig.c +++ b/common/image-sig.c @@ -98,6 +98,19 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name) int i; const char *name; +#if defined(CONFIG_NEEDS_MANUAL_RELOC) + static bool done; + + if (!done) { + crypto = ll_entry_start(struct crypto_algo, cryptos); + end = ll_entry_end(struct crypto_algo, cryptos); + for (; crypto < end; crypto++) { + crypto->name += gd->reloc_off; + crypto->verify += gd->reloc_off; + } + } +#endif + /* Move name to after the comma */ name = strchr(full_name, ','); if (!name) -- 2.31.1