image: Avoid #ifdefs for manual relocation
Add a macro to handle manually relocating a pointer. Update the iamge code to use this to avoid needing #ifdefs. This also fixes a bug where the 'done' flag was not set. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
2ac00c0505
commit
c5a68d29e3
@ -9,6 +9,7 @@
|
|||||||
#include <asm/global_data.h>
|
#include <asm/global_data.h>
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
|
#include <relocate.h>
|
||||||
#include <u-boot/ecdsa.h>
|
#include <u-boot/ecdsa.h>
|
||||||
#include <u-boot/rsa.h>
|
#include <u-boot/rsa.h>
|
||||||
#include <u-boot/hash-checksum.h>
|
#include <u-boot/hash-checksum.h>
|
||||||
@ -56,17 +57,19 @@ struct checksum_algo *image_get_checksum_algo(const char *full_name)
|
|||||||
int i;
|
int i;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
#if defined(CONFIG_NEEDS_MANUAL_RELOC)
|
if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
|
||||||
static bool done;
|
static bool done;
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
done = true;
|
done = true;
|
||||||
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
|
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
|
||||||
checksum_algos[i].name += gd->reloc_off;
|
struct checksum_algo *algo = &checksum_algos[i];
|
||||||
checksum_algos[i].calculate += gd->reloc_off;
|
|
||||||
|
MANUAL_RELOC(algo->name);
|
||||||
|
MANUAL_RELOC(algo->calculate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
|
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
|
||||||
name = checksum_algos[i].name;
|
name = checksum_algos[i].name;
|
||||||
@ -84,18 +87,19 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name)
|
|||||||
struct crypto_algo *crypto, *end;
|
struct crypto_algo *crypto, *end;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
#if defined(CONFIG_NEEDS_MANUAL_RELOC)
|
if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
|
||||||
static bool done;
|
static bool done;
|
||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
crypto = ll_entry_start(struct crypto_algo, cryptos);
|
done = true;
|
||||||
end = ll_entry_end(struct crypto_algo, cryptos);
|
crypto = ll_entry_start(struct crypto_algo, cryptos);
|
||||||
for (; crypto < end; crypto++) {
|
end = ll_entry_end(struct crypto_algo, cryptos);
|
||||||
crypto->name += gd->reloc_off;
|
for (; crypto < end; crypto++) {
|
||||||
crypto->verify += gd->reloc_off;
|
MANUAL_RELOC(crypto->name);
|
||||||
|
MANUAL_RELOC(crypto->verify);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Move name to after the comma */
|
/* Move name to after the comma */
|
||||||
name = strchr(full_name, ',');
|
name = strchr(full_name, ',');
|
||||||
|
@ -57,4 +57,10 @@ static inline void *manual_reloc(void *ptr)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
|
||||||
|
#define MANUAL_RELOC(ptr) (ptr) = manual_reloc(ptr)
|
||||||
|
#else
|
||||||
|
#define MANUAL_RELOC(ptr) (void)(ptr)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _RELOCATE_H_ */
|
#endif /* _RELOCATE_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user