This patch is similar the arm one committed recently.
2018-10-08 Christophe Lyon <christophe.lyon@linaro.org>
* libgloss/aarch64/syscalls.c (_sbrk): Fix prototype.
(_getpid, _write, _swiwrite, _lseek, _swilseek, _read, _wriread):
Likewise.
Nowadays, the code fetching command line options via semi-hosting are
unconditionally pulled in, so that the semi-hosting code is still
there even I compile with option --specs=nosys.specs.
gdb ./aarch64-none-elf/libgloss/aarch64/crt0.o
(gdb) disassemble _start
0x0000000000000050 <+80>: ldr x1, 0x128 <_cpu_init_hook+48>
0x0000000000000054 <+84>: mov w0, #0x15
0x0000000000000058 <+88>: hlt #0xf000
This patch fixes this problem by wrapping the code by ARM_RDI_MONITOR.
When semi-hosting is not used, set command line options to NULL.
On AArch64 we currently always link in crt0 regardless of if another
one is being provided by something else, like rdimon.a. This was never
an issue before as nosys was not supported on AArch64.
This updates the specs to supply a different crt0 when a semihosting
call is required.
Signed-off-by: Tamar Christina <tamar.christina@arm.com>
This fixed the compile for nosys and validation specs
but nosys won't run because of existing limitations to
aarch64's syscalls.c, it requires semihosting to get
commandline arguments and heap info without having a
fallback method as ARM does.
Signed-off-by: Tamar Christina <tamar.christina@arm.com>
This patch fixes the issue where nosys.specs is used to link.
e.g. The use of crt0 without any support for semihosting requested.
The AArch64 crt0 was missing an #ifdef for the initialise_monitor_handles
which was causing the link to fail. Sorry for missing this before.
Semihosting v2 changes are documented here:
https://developer.arm.com/docs/100863/latest/
The biggest change is the addition of an extensions mechanism
to add more extensions in the future.
Signed-off-by: Tamar Christina <tamar.christina@arm.com>
This uses the new recursive build target in multi-build.in
For AArch64 no new spec files are needed but the makefiles
are modified to keep them in sync with the ARM ones.
Signed-off-by: Tamar Christina <tamar.christina@arm.com>
When simulating arm code, the target program startup code (crt0) uses
semihosting invocations to get the command line from the simulator. The
simulator returns the command line and its size into the area passed in
parameter. (ARM 32-bit specifications :
http://infocenter.arm.com/help/topic/com.arm.doc.dui0058d/DUI0058.pdf
chapter "5.4.19 SYS_GET_CMDLINE").
The memory area pointed by the semihosting register argument is located
in .text section (usually not writtable (RX)).
If we run this code on a simulator that respects this rights properties
(qemu user-mode for instance), the command line will not be written to
the .text program memory, in particular the length of the string. The
program runs with an empty command line. This problem hasn't been seen
earlier probably because qemu user-mode is not so much used, but this can
happen with another simulator that refuse to write in a read-only segment.
With this modification, the command line can be correctly passed to the
target program.
Changes:
- libgloss/arm/crt0.S : Arguments passed to the AngelSWI_Reason_GetCmdLine
semihosting invocation are placed into .data section instead of .text
- libgloss/aarch64/crt0.S : Idem for aarch64 AngelSVC_Reason_GetCmdLine
semihosting.
(PTR_REG): Ditto.
(PTR_SIZE): Ditto.
(PTR_LOG_SIZE): Ditto.
(start): Use GEN_DWORD to replace the .dword of HeapBase,
__bss_start__, __bss_end__, FUNCTION(_fini), env and
CommandLine; when __ILP32__ is defined, set the stack base to
the top end of the 32-bit address space if the returned value
from the Angel API call is larger than or equal to 4 GiB.
Also carry out sanity check on the heap base; abort if the
base is larger than or equal to 4 GiB. Use other new
macros in the instructions that processes the argv arrays.
(StackBase): New lable; replace __stack_base__.
(__stack_base__): Set with StackBase or StackBase + 4.
* aarch64/Machine.in (RDIMON_SCRIPTS):
Add aem-ve.specs and aem-validation.specs.
* aarch64/elf-aem-validation.specs: New file.
* aarch64/elf-aem-ve.specs: New file.