summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/command.c5
-rw-r--r--common/hash.c29
-rw-r--r--common/image-sig.c29
3 files changed, 63 insertions, 0 deletions
diff --git a/common/command.c b/common/command.c
index 4b887a267f..ceca992510 100644
--- a/common/command.c
+++ b/common/command.c
@@ -496,6 +496,11 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
for (i = 0; i < size; i++) {
ulong addr;
+ addr = (ulong)(cmdtp->cmd_rep) + gd->reloc_off;
+ cmdtp->cmd_rep =
+ (int (*)(struct cmd_tbl_s *, int, int,
+ char * const [], int *))addr;
+
addr = (ulong)(cmdtp->cmd) + gd->reloc_off;
#ifdef DEBUG_COMMANDS
printf("Command \"%s\": 0x%08lx => 0x%08lx\n",
diff --git a/common/hash.c b/common/hash.c
index d33e329897..d0d825e389 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -30,6 +30,12 @@
#include <u-boot/sha256.h>
#include <u-boot/md5.h>
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
+static void reloc_update(void);
+
#if defined(CONFIG_SHA1) && !defined(CONFIG_SHA_PROG_HW_ACCEL)
static int hash_init_sha1(struct hash_algo *algo, void **ctxp)
{
@@ -215,10 +221,31 @@ static struct hash_algo hash_algo[] = {
#define multi_hash() 0
#endif
+static void reloc_update(void)
+{
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+ int i;
+ static bool done;
+
+ if (!done) {
+ done = true;
+ for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
+ hash_algo[i].name += gd->reloc_off;
+ hash_algo[i].hash_func_ws += gd->reloc_off;
+ hash_algo[i].hash_init += gd->reloc_off;
+ hash_algo[i].hash_update += gd->reloc_off;
+ hash_algo[i].hash_finish += gd->reloc_off;
+ }
+ }
+#endif
+}
+
int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
{
int i;
+ reloc_update();
+
for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
if (!strcmp(algo_name, hash_algo[i].name)) {
*algop = &hash_algo[i];
@@ -235,6 +262,8 @@ int hash_progressive_lookup_algo(const char *algo_name,
{
int i;
+ reloc_update();
+
for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
if (!strcmp(algo_name, hash_algo[i].name)) {
if (hash_algo[i].hash_init) {
diff --git a/common/image-sig.c b/common/image-sig.c
index 004fbc525b..639a112450 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -89,6 +89,21 @@ struct checksum_algo *image_get_checksum_algo(const char *full_name)
int i;
const char *name;
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+ static bool done;
+
+ if (!done) {
+ done = true;
+ for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
+ checksum_algos[i].name += gd->reloc_off;
+#if IMAGE_ENABLE_SIGN
+ checksum_algos[i].calculate_sign += gd->reloc_off;
+#endif
+ checksum_algos[i].calculate += gd->reloc_off;
+ }
+ }
+#endif
+
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
name = checksum_algos[i].name;
/* Make sure names match and next char is a comma */
@@ -105,6 +120,20 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name)
int i;
const char *name;
+#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
+ static bool done;
+
+ if (!done) {
+ done = true;
+ for (i = 0; i < ARRAY_SIZE(crypto_algos); i++) {
+ crypto_algos[i].name += gd->reloc_off;
+ crypto_algos[i].sign += gd->reloc_off;
+ crypto_algos[i].add_verify_data += gd->reloc_off;
+ crypto_algos[i].verify += gd->reloc_off;
+ }
+ }
+#endif
+
/* Move name to after the comma */
name = strchr(full_name, ',');
if (!name)