public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [AArch64] Don't fetch command line options without semi-hosting
@ 2017-08-09 14:38 Yao Qi
  2017-08-09 15:43 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Yao Qi @ 2017-08-09 14:38 UTC (permalink / raw)
  To: newlib

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.
---
 libgloss/aarch64/crt0.S | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libgloss/aarch64/crt0.S b/libgloss/aarch64/crt0.S
index cbff11a..3bf0278 100644
--- a/libgloss/aarch64/crt0.S
+++ b/libgloss/aarch64/crt0.S
@@ -157,6 +157,7 @@
 
 	bl	FUNCTION (_init)
 
+#ifdef ARM_RDI_MONITOR
 	/* Fetch and parse the command line.  */
 	ldr	x1, .Lcmdline		/* Command line descriptor.  */
 	mov	w0, #AngelSVC_Reason_GetCmdLine
@@ -219,6 +220,11 @@
 	and	x4, x1, ~15
 	mov	sp, x4
 
+#else
+	mov	x0, #0	/* argc = 0 */
+	mov	x1, #0	/* argv = NULL */
+#endif
+
 	bl	FUNCTION (main)
 
 	b	FUNCTION (exit)		/* Cannot return.  */
-- 
1.9.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-09 15:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-09 14:38 [PATCH] [AArch64] Don't fetch command line options without semi-hosting Yao Qi
2017-08-09 15:43 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).