Skip to content

Commit 4d77d75

Browse files
authored
Update baremetal-semihosting-aarch64 sample make.bat for qemu (#232) (#233)
This applies the change #227 Makefile to the Windows make.bat. The rest of the commit message is the same as that PR. Make a temporary fix to avoid a couple of problems with the startup code on more recent qemu versions, such as the recent 9.2.2 release. The first problem is that the thunk generated for the branch from _start to _cstart loads the destination address from a literal. As this thunk executes before the memory is set up we get an abort on the read. Fix this by forcing the linker to use a position independent thunk that is execute-only. The second problem is that the picolibc startup code assumes that qemu-system-aarch64 will start in EL1. This is not always the case. When --kernel is an ELF file qemu will start in EL3, when --kernel is not ELF then qemu will start in either EL2 (if implemented) or EL1, with EL2 preferred. When starting up in EL2 this means that the startup code writing to EL1 system registers is not being used while still executing in EL2, including enabling unaligned access. To work around this disable unaligned accesses. Ideally this needs fixing in the startup code. Which should test at run time what exception level it starts in and switch to EL1 if not in EL1.
1 parent 0e7db6e commit 4d77d75

File tree

1 file changed

+1
-1
lines changed
  • arm-software/embedded/samples/src/baremetal-semihosting-aarch64

1 file changed

+1
-1
lines changed

arm-software/embedded/samples/src/baremetal-semihosting-aarch64/make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ if exist hello.img del /q hello.img
4040
@exit /B 1
4141

4242
:build_fn
43-
%BIN_PATH%\clang.exe --target=aarch64-none-elf -nostartfiles -lcrt0-semihost -lsemihost -g -T ..\..\ldscripts\raspi3b.ld -o hello.elf hello.c
43+
%BIN_PATH%\clang.exe --target=aarch64-none-elf -nostartfiles -lcrt0-semihost -lsemihost -Wl,--pic-veneer -mno-unaligned-access -g -T ..\..\ldscripts\raspi3b.ld -o hello.elf hello.c
4444
%BIN_PATH%\llvm-objcopy.exe -O binary hello.elf hello.img
4545
@exit /B

0 commit comments

Comments
 (0)