Commit 37e80fbb authored by Alexander Fedotov's avatar Alexander Fedotov Committed by Richard Earnshaw

Align libgloss/arm and libc/sys/arm sources: Fix GetCmdLine semihosting directives

Applied changes from the commit 9b116721:

	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 :
	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.

	- newlib/libc/sys/arm/crt0.S : Arguments passed to the
	AngelSWI_Reason_GetCmdLine semihosting invocation are placed into .data
	section instead of .text
parent 362b98b4
......@@ -393,13 +393,14 @@ __change_mode:
movs r1, r0
movs r0, #AngelSWI_Reason_GetCmdLine
adr r1, .LC30 /* Space for command line. */
ldr r1, .LC30 /* Space for command line. */
#ifdef THUMB_VXM
bkpt AngelSWI
AngelSWIAsm AngelSWI
ldr r1, .LC30
ldr r1, [r1]
/* Parse string at r1. */
movs r0, #0 /* Count of arguments so far. */
......@@ -586,8 +587,7 @@ change_back:
.word CommandLine
.word 255
.word AngelSWIArgs
.word __end__
......@@ -600,6 +600,9 @@ HeapLimit: .word 0
__stack_base__: .word 0
StackLimit: .word 0
CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */
.word CommandLine
.word 255
#ifdef __pe__
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment