diff mbox series

[RFC,04/10,UNTESTED] image: Add support for relocating crypto_algos in linker lists

Message ID 20210514194602.598322-5-mr.nuke.me@gmail.com
State RFC
Delegated to: Tom Rini
Headers show
Series image: Reduce the abuse of #ifdefs in image-sig.c | expand

Commit Message

Alex G. May 14, 2021, 7:45 p.m. UTC
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 <mr.nuke.me@gmail.com>
---
 common/image-sig.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Simon Glass May 15, 2021, 3:20 p.m. UTC | #1
On Fri, 14 May 2021 at 13:46, Alexandru Gagniuc <mr.nuke.me@gmail.com> wrote:
>
> 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 <mr.nuke.me@gmail.com>
> ---
>  common/image-sig.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

I don't normally bother with this, since it is due to a toolchain
failure, that really should have been fixed years ago. But I am sure
someone will be happy.

+Michal Simek
Michal Simek May 19, 2021, 7:07 a.m. UTC | #2
On 5/15/21 5:20 PM, Simon Glass wrote:
> On Fri, 14 May 2021 at 13:46, Alexandru Gagniuc <mr.nuke.me@gmail.com> wrote:
>>
>> 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 <mr.nuke.me@gmail.com>
>> ---
>>  common/image-sig.c | 7 +++++++
>>  1 file changed, 7 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> I don't normally bother with this, since it is due to a toolchain
> failure, that really should have been fixed years ago. But I am sure
> someone will be happy.
> 
> +Michal Simek

It looks good to me.
Acked-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal
diff mbox series

Patch

diff --git a/common/image-sig.c b/common/image-sig.c
index 2b7e23f99a..b750751144 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -120,6 +120,13 @@  struct crypto_algo *image_get_crypto_algo(const char *full_name)
 			crypto_algos[i].name += gd->reloc_off;
 			crypto_algos[i].verify += gd->reloc_off;
 		}
+
+		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