summaryrefslogtreecommitdiff
path: root/include/relocate.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-09-25 16:03:18 +0300
committerTom Rini <trini@konsulko.com>2021-10-08 22:53:26 +0300
commit2ac00c050582389e667374bccc5cc19b4fce80f5 (patch)
treefd0e0dbb49a39e9b10cf179c1cb43b51d467f5f6 /include/relocate.h
parent5d3248a688c2368be54aaa9407be30adfa994abc (diff)
downloadu-boot-2ac00c050582389e667374bccc5cc19b4fce80f5.tar.xz
image: Create a function to do manual relocation
Rather than adding an #ifdef and open-coding this calculation, add a helper function to handle it. Use this in the image code. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/relocate.h')
-rw-r--r--include/relocate.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/include/relocate.h b/include/relocate.h
index 9ceeecdbe7..c4fad33612 100644
--- a/include/relocate.h
+++ b/include/relocate.h
@@ -7,7 +7,11 @@
#ifndef _RELOCATE_H_
#define _RELOCATE_H_
-#include <common.h>
+#ifndef USE_HOSTCC
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+#endif
/**
* copy_uboot_to_ram() - Copy U-Boot to its new relocated position
@@ -35,4 +39,22 @@ int clear_bss(void);
*/
int do_elf_reloc_fixups(void);
+/**
+ * manual_reloc() - Manually relocate a pointer if needed
+ *
+ * This is a nop in almost all cases, except for the systems with a broken gcc
+ * which need to manually relocate some things.
+ *
+ * @ptr: Pointer to relocate
+ * @return new pointer value
+ */
+static inline void *manual_reloc(void *ptr)
+{
+#ifndef USE_HOSTCC
+ if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC))
+ return ptr + gd->reloc_off;
+#endif
+ return ptr;
+}
+
#endif /* _RELOCATE_H_ */