aboutsummaryrefslogtreecommitdiff
path: root/libgloss/aarch64
diff options
context:
space:
mode:
authorLaurent ALFONSI <laurent.alfonsi@st.com>2017-04-18 17:50:16 +0200
committerJeff Johnston <jjohnstn@redhat.com>2017-05-19 15:45:58 -0400
commit9b1167219a11311dd5a3db4b6802feea2f2ee765 (patch)
tree36ffd5c202e32f5a65a5fe3122742292dc1c9cc3 /libgloss/aarch64
parent9d32147e35464893987d72ffae6d900dec5f9106 (diff)
downloadnewlib-9b1167219a11311dd5a3db4b6802feea2f2ee765.zip
newlib-9b1167219a11311dd5a3db4b6802feea2f2ee765.tar.gz
newlib-9b1167219a11311dd5a3db4b6802feea2f2ee765.tar.bz2
ARM/AArch64: Fix GetCmdLine semihosting directivesnewlib-snapshot-20170519
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.
Diffstat (limited to 'libgloss/aarch64')
-rw-r--r--libgloss/aarch64/crt0.S10
1 files changed, 6 insertions, 4 deletions
diff --git a/libgloss/aarch64/crt0.S b/libgloss/aarch64/crt0.S
index ae6264d..ed4dafc 100644
--- a/libgloss/aarch64/crt0.S
+++ b/libgloss/aarch64/crt0.S
@@ -156,10 +156,11 @@
bl FUNCTION (_init)
/* Fetch and parse the command line. */
- adr x1, .Lcmdline /* Command line descriptor. */
+ ldr x1, .Lcmdline /* Command line descriptor. */
mov w0, #AngelSVC_Reason_GetCmdLine
AngelSVCAsm AngelSVC
ldr x8, .Lcmdline
+ ldr x8, [x8]
mov x0, #0 /* argc */
mov x1, sp /* argv */
@@ -239,9 +240,7 @@ FUNCTION (_cpu_init_hook):
.Lenvp:
GEN_DWORD env
.Lcmdline:
- GEN_DWORD CommandLine
- .dword 255
-
+ GEN_DWORD AngelSVCArgs
/* Workspace for Angel calls. */
.data
.align 3
@@ -258,3 +257,6 @@ StackBase: .dword 0
StackLimit: .dword 0
env: .dword 0 /* Dummy environment array */
CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */
+AngelSVCArgs:
+ GEN_DWORD CommandLine
+ .dword 255