blob: fa2282b8dd96f73e6f3cb7fef51fec08ba04197d [file] [log] [blame]
Patrick Williamsb58112e2024-03-07 11:16:36 -06001From d8f07a23d608b744dcc0592f9f32f258b186a77c Mon Sep 17 00:00:00 2001
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Tue, 15 Aug 2017 17:13:59 +0800
Brad Bishop19323692019-04-05 15:28:33 -04004Subject: [PATCH] Fix elf_cvt_gunhash if dest and src are same.
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005
6Upstream-Status: Pending
7
8The 'dest' and 'src' can be same, we need to save the value of src32[2]
9before swaping it.
10
11Signed-off-by: Baoshan Pang <BaoShan.Pang@windriver.com>
12
13Rebase to 0.170
14Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
15---
16 libelf/gnuhash_xlate.h | 3 ++-
17 1 file changed, 2 insertions(+), 1 deletion(-)
18
19diff --git a/libelf/gnuhash_xlate.h b/libelf/gnuhash_xlate.h
Patrick Williamsb58112e2024-03-07 11:16:36 -060020index 3a00ae0..40468fc 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021--- a/libelf/gnuhash_xlate.h
22+++ b/libelf/gnuhash_xlate.h
Patrick Williamsb58112e2024-03-07 11:16:36 -060023@@ -42,6 +42,7 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024 words. We must detangle them here. */
25 Elf32_Word *dest32 = dest;
26 const Elf32_Word *src32 = src;
27+ Elf32_Word save_src32_2 = src32[2]; // dest could be equal to src
28
29 /* First four control words, 32 bits. */
30 for (unsigned int cnt = 0; cnt < 4; ++cnt)
Patrick Williamsb58112e2024-03-07 11:16:36 -060031@@ -52,7 +53,7 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032 len -= 4;
33 }
34
35- Elf32_Word bitmask_words = encode ? src32[2] : dest32[2];
36+ Elf32_Word bitmask_words = encode ? save_src32_2 : dest32[2];
37
38 /* Now the 64 bit words. */
39 Elf64_Xword *dest64 = (Elf64_Xword *) &dest32[4];