Skip to content

Commit a3c101a

Browse files
xyprontrini
authored andcommitted
examples: fix building on arm64
Commit f9886bc ("Added arm64 assembly for examples/api crt0") tried to add arm64 support to the examples but crt0.S does not even build for qemu_arm64_defconfig with CONFIG_API=y, CONFIG_EXAMPLES=y: examples/api/crt0.S: Assembler messages: examples/api/crt0.S:32: Error: expected a register at operand 1 -- `ldr ip,=search_hint' examples/api/crt0.S:33: Error: unexpected register type at operand 1 -- `str sp,[ip]' make[2]: *** [scripts/Makefile.build:292: examples/api/crt0.o] Error 1 Do not define _start twice. Use valid register names. Move syscall_ptr and search_hint to the data section to avoid an invalid relocation. Fixes: f9886bc ("Added arm64 assembly for examples/api crt0") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
1 parent e263557 commit a3c101a

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

examples/api/crt0.S

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ syscall:
2424
mtctr %r11
2525
bctr
2626

27-
#elif defined(CONFIG_ARM)
27+
#elif defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
2828

2929
.text
3030
.globl _start
@@ -33,26 +33,27 @@ _start:
3333
str sp, [ip]
3434
b main
3535

36-
#elif defined(CONFIG_ARM64)
37-
38-
.text
39-
.globl _start
40-
_start:
41-
ldr ip0, =search_hint
42-
str sp_el2, [ip0]
43-
b main
4436

45-
46-
.globl syscall
37+
.globl syscall
4738
syscall:
48-
ldr ip0, =syscall_ptr
49-
ldr pc_el2, [ip0]
39+
ldr ip, =syscall_ptr
40+
ldr pc, [ip]
5041

42+
#elif defined(CONFIG_ARM64)
43+
44+
.text
45+
.globl _start
46+
_start:
47+
ldr x17, =search_hint
48+
mov x16, sp
49+
str x16, [x17]
50+
b main
5151

5252
.globl syscall
5353
syscall:
54-
ldr ip, =syscall_ptr
55-
ldr pc, [ip]
54+
ldr x16, =syscall_ptr
55+
ldr x16, [x16]
56+
br x16
5657

5758
#elif defined(CONFIG_MIPS)
5859
#include <asm/asm.h>
@@ -83,11 +84,13 @@ return_addr:
8384
#error No support for this arch!
8485
#endif
8586

87+
.section .data
88+
8689
.globl syscall_ptr
8790
syscall_ptr:
8891
.align 8
8992
.long 0
9093

9194
.globl search_hint
9295
search_hint:
93-
.long 0
96+
.long 0

0 commit comments

Comments
 (0)