qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH for 7.0 3/5] h.amd64: Simple hello-world test for x86_64


From: Warner Losh
Subject: [PATCH for 7.0 3/5] h.amd64: Simple hello-world test for x86_64
Date: Sat, 27 Nov 2021 13:18:44 -0700

A simple, tiny, statically linked 64-bit x86 'hello world' test. It uses
two system calls (write and exit) and provides a basic sanity check to
make sure that the arm bsd-user binary can interpret FreeBSD 64-bit
amd64 binaries. Please note: it's named amd64 because that's the target
name for FreeBSD's clang and it simplifies building a little.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 tests/bsd-user-smoke/h.amd64.S | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 tests/bsd-user-smoke/h.amd64.S

diff --git a/tests/bsd-user-smoke/h.amd64.S b/tests/bsd-user-smoke/h.amd64.S
new file mode 100644
index 00000000000..a769e59beb8
--- /dev/null
+++ b/tests/bsd-user-smoke/h.amd64.S
@@ -0,0 +1,28 @@
+# Copyright (c) 2021 Warner Losh
+# SPDX-License-Identifier: BSD-2-Clause
+
+#include <sys/syscall.h>
+#define STDOUT_FILENO  1
+
+       .text
+       .globl  qemu_start
+       .p2align        4, 0x90
+qemu_start:
+
+       # write(1, .L.str, sizeof(.L.str) - 1)
+       movq    $.L.str, %rsi
+       movl    $STDOUT_FILENO, %edi
+       movl    $len, %edx
+       movl    $SYS_write, %eax
+       syscall
+
+       # _exit(0)
+       xorl    %edi, %edi
+       movl    $SYS_exit, %eax
+       syscall
+
+       .section        .rodata.str1.1,"aMS",@progbits,1
+.L.str:
+       .asciz  "Hello World\n"
+.L.strEnd:
+len=.L.strEnd - .L.str - 1
-- 
2.33.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]