[U-Boot] [PATCH 2/2] hello_world.c: fix entry point in case of arm thumb binary

Max Krummenacher max.oss.09 at gmail.com
Sat Aug 12 09:03:46 UTC 2017


If compiling for thumb the U-Boot 'go' command can not jump to the entry
point, as the jump will be done in the assumption that the code jumped to
is using the arm instruction set.

So add add a simple forwarder in arm instruction set which then jumps
to the 'real' entry.

Signed-off-by: Max Krummenacher <max.krummenacher at toradex.com>

---

 examples/standalone/hello_world.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/examples/standalone/hello_world.c b/examples/standalone/hello_world.c
index bd8b392315..0b859ca4bd 100644
--- a/examples/standalone/hello_world.c
+++ b/examples/standalone/hello_world.c
@@ -8,6 +8,21 @@
 #include <common.h>
 #include <exports.h>
 
+/*
+ * Make thumb work by providing a forwarder to the (thumb) entry point
+ * compiled for arm instruction set.
+ * Don't compile this for thumb only CPUs.
+ */
+#if defined(__thumb__) && defined(__ARM_ARCH_ISA_ARM)
+void __attribute__((unused)) __attribute__ ((naked)) dummy2(void)
+{
+asm volatile( \
+"	.code 32\n" \
+"	.arm\n" \
+"	ldr pc,=hello_world\n");
+}
+#endif
+
 int hello_world (int argc, char * const argv[])
 {
 	int i;
-- 
2.13.1



More information about the U-Boot mailing list