From a9856a47a87ea75cf08f9b1f71d9a0f938f569f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 8 Oct 2019 00:00:00 +0000 Subject: [PATCH] nodejs: start sketch --- README.adoc | 53 ++++++++++++++----- .../lkmc/nodejs/command_line_arguments.js | 5 ++ ...{print_argv.c => command_line_arguments.c} | 0 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100755 rootfs_overlay/lkmc/nodejs/command_line_arguments.js rename userland/c/{print_argv.c => command_line_arguments.c} (100%) diff --git a/README.adoc b/README.adoc index fdac405..ca7f0f5 100644 --- a/README.adoc +++ b/README.adoc @@ -1108,7 +1108,7 @@ sudo apt-get install gcc-aarch64-linux-gnu qemu-system-aarch64 --arch aarch64 \ --qemu-which host \ --userland-build-id host \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; .... @@ -1142,7 +1142,7 @@ and <>: --gcc-which host \ --qemu-which host \ --userland-build-id host \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; .... @@ -2646,7 +2646,7 @@ Source: link:rootfs_overlay/lkmc/gdbserver.sh[]. And on host: .... -./run-gdb --gdbserver --userland userland/c/print_argv.c main +./run-gdb --gdbserver --userland userland/c/command_line_arguments.c main .... or alternatively with the path to the executable itself: @@ -3584,12 +3584,12 @@ See also: xref:user-mode-simulation-with-glibc[xrefstyle=full] === QEMU user mode getting started -Let's run link:userland/c/print_argv.c[] built with the Buildroot toolchain on QEMU user mode: +Let's run link:userland/c/command_line_arguments.c[] built with the Buildroot toolchain on QEMU user mode: .... ./build user-mode-qemu ./run \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args='asdf "qw er"' \ ; .... @@ -3620,7 +3620,7 @@ It's nice when <> just works, right? ./run \ --arch aarch64 \ --gdb-wait \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; .... @@ -3630,7 +3630,7 @@ and on another shell: .... ./run-gdb \ --arch aarch64 \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ main \ ; .... @@ -3641,7 +3641,7 @@ Or alternatively, if you are using <>, do everything in one go with: ./run \ --arch aarch64 \ --gdb \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; .... @@ -3793,7 +3793,7 @@ Example: ./run \ --arch aarch64 \ --static \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; .... @@ -3879,7 +3879,7 @@ So let's just play with some static ones: ./run \ --arch aarch64 \ --emulator gem5 \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; .... @@ -3894,14 +3894,14 @@ TODO: how to escape spaces on the command line arguments? --emulator gem5 \ --gdb-wait \ --static \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ --userland-args 'asdf "qw er"' \ ; ./run-gdb \ --arch aarch64 \ --emulator gem5 \ --static \ - --userland userland/c/print_argv.c \ + --userland userland/c/command_line_arguments.c \ main \ ; .... @@ -12854,7 +12854,7 @@ Programs under link:userland/c/[] are examples of https://en.wikipedia.org/wiki/ ** link:userland/c/exit0.c[] ** link:userland/c/exit1.c[] ** link:userland/c/exit2.c[] -** link:userland/c/print_argv.c[] +** link:userland/c/command_line_arguments.c[] * Standard library ** `assert.h` *** link:userland/c/assert_fail.c[] @@ -13164,6 +13164,33 @@ How to debug: https://stackoverflow.com/questions/6261201/how-to-find-memory-lea Example: link:userland/c/memory_leak.c[] +=== Interpreted languages + +Maybe some day someone will use this setup to study the performance of interpreters: + +* <> + +=== Node.js + +Parent section: <>. + +Install the interpreter with: + +.... +./build-buildroot --config 'BR2_PACKAGE_NODEJS=y' +.... + +TODO: broken as of 3c3deb14dc8d6511680595dc42cb627d5781746d + 1: + +.... +ERROR: package host-nodejs installs executables without proper RPATH +.... + +Examples: + +* process +** link:rootfs_overlay/lkmc/nodejs/command_line_arguments.js[] + === Userland content bibliography * The Linux Programming Interface by Michael Kerrisk https://www.amazon.co.uk/Linux-Programming-Interface-System-Handbook/dp/1593272200 Lots of open source POSIX examples: https://github.com/cirosantilli/linux-programming-interface-kerrisk diff --git a/rootfs_overlay/lkmc/nodejs/command_line_arguments.js b/rootfs_overlay/lkmc/nodejs/command_line_arguments.js new file mode 100755 index 0000000..da9651e --- /dev/null +++ b/rootfs_overlay/lkmc/nodejs/command_line_arguments.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +for (const arg of process.argv) { + console.log(arg); +} diff --git a/userland/c/print_argv.c b/userland/c/command_line_arguments.c similarity index 100% rename from userland/c/print_argv.c rename to userland/c/command_line_arguments.c