sp uninitialized in imx6_cpu_lowlevel_init
Hello,
when building imx_v7_defconfig and then looking at images/start_imx6_gk802.pbl (several more are affected, too), I get:
$ objdump -d images/start_imx6_gk802.pbl
00000000 <start_imx6_gk802>:
0: e28f9001 add r9, pc, #1
4: e12fff19 bx r9
8: f000 f822 bl 50 <start_imx6_gk802+0x50>
...
50: f000 f850 bl f4 <__start_imx6_gk802>
...
f4: f000 f80c bl 110 <imx6_cpu_lowlevel_init>
...
110: b508 push {r3, lr}That is the sp register is used here without being initialized. I guess this didn't break up to now because when barebox is jumped into, sp was already used by the boot rom and still points into SRAM.
Still I think this is worth to be fixed. I think this means that imx6_cpu_lowlevel_init must be marked __naked and lr must be saved into a register that is preserved by the functions called by imx6_cpu_lowlevel_init.
Sounds reasonable?
Best regards
Uwe
Signature · 7 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 21 lines · Uwe Kleine-König
Hello,
when building
imx_v7_defconfigand then looking at images/start_imx6_gk802.pbl (several more are affected, too), I get:$ objdump -d images/start_imx6_gk802.pbl 00000000 <start_imx6_gk802>: 0: e28f9001 add r9, pc, #1 4: e12fff19 bx r9 8: f000 f822 bl 50 <start_imx6_gk802+0x50> ... 50: f000 f850 bl f4 <__start_imx6_gk802> ... f4: f000 f80c bl 110 <imx6_cpu_lowlevel_init> ... 110: b508 push {r3, lr}That is the sp register is used here without being initialized. I guess this didn't break up to now because when barebox is jumped into, sp was already used by the boot rom and still points into SRAM.
Quoted 6 lines
Still I think this is worth to be fixed. I think this means that
imx6_cpu_lowlevel_initmust be marked__nakedand lr must be saved into a register that is preserved by the functions called byimx6_cpu_lowlevel_init.Sounds reasonable?
I think we should rather setup a stack before calling imx6_cpu_lowlevel_init. We have SRAM for that so we can use it.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox