Commit 10088fb0373a0dc6f907f81279db004f5c35c4ea

Authored by T Karthik Reddy
Committed by Michal Simek
1 parent 62e3fb027b

common: hash: Manually relocate struct hash_algo

This patch adds manual relocation for struct hash_algo if
CONFIG_NEEDS_MANUAL_RELOC is enabled.

Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Showing 1 changed file with 29 additions and 0 deletions Side-by-side Diff

... ... @@ -30,6 +30,12 @@
30 30 #include <u-boot/sha256.h>
31 31 #include <u-boot/md5.h>
32 32  
  33 +#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
  34 +DECLARE_GLOBAL_DATA_PTR;
  35 +#endif
  36 +
  37 +static void reloc_update(void);
  38 +
33 39 #if defined(CONFIG_SHA1) && !defined(CONFIG_SHA_PROG_HW_ACCEL)
34 40 static int hash_init_sha1(struct hash_algo *algo, void **ctxp)
35 41 {
36 42  
... ... @@ -215,10 +221,31 @@
215 221 #define multi_hash() 0
216 222 #endif
217 223  
  224 +static void reloc_update(void)
  225 +{
  226 +#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
  227 + int i;
  228 + static bool done;
  229 +
  230 + if (!done) {
  231 + done = true;
  232 + for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
  233 + hash_algo[i].name += gd->reloc_off;
  234 + hash_algo[i].hash_func_ws += gd->reloc_off;
  235 + hash_algo[i].hash_init += gd->reloc_off;
  236 + hash_algo[i].hash_update += gd->reloc_off;
  237 + hash_algo[i].hash_finish += gd->reloc_off;
  238 + }
  239 + }
  240 +#endif
  241 +}
  242 +
218 243 int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
219 244 {
220 245 int i;
221 246  
  247 + reloc_update();
  248 +
222 249 for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
223 250 if (!strcmp(algo_name, hash_algo[i].name)) {
224 251 *algop = &hash_algo[i];
... ... @@ -234,6 +261,8 @@
234 261 struct hash_algo **algop)
235 262 {
236 263 int i;
  264 +
  265 + reloc_update();
237 266  
238 267 for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
239 268 if (!strcmp(algo_name, hash_algo[i].name)) {