mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 20:44:26 +01:00
nodejs: start sketch
This commit is contained in:
53
README.adoc
53
README.adoc
@@ -1108,7 +1108,7 @@ sudo apt-get install gcc-aarch64-linux-gnu qemu-system-aarch64
|
|||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--qemu-which host \
|
--qemu-which host \
|
||||||
--userland-build-id host \
|
--userland-build-id host \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -1142,7 +1142,7 @@ and <<user-mode-gdb>>:
|
|||||||
--gcc-which host \
|
--gcc-which host \
|
||||||
--qemu-which host \
|
--qemu-which host \
|
||||||
--userland-build-id host \
|
--userland-build-id host \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -2646,7 +2646,7 @@ Source: link:rootfs_overlay/lkmc/gdbserver.sh[].
|
|||||||
And on host:
|
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:
|
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
|
=== 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
|
./build user-mode-qemu
|
||||||
./run \
|
./run \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args='asdf "qw er"' \
|
--userland-args='asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -3620,7 +3620,7 @@ It's nice when <<gdb,the obvious>> just works, right?
|
|||||||
./run \
|
./run \
|
||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--gdb-wait \
|
--gdb-wait \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -3630,7 +3630,7 @@ and on another shell:
|
|||||||
....
|
....
|
||||||
./run-gdb \
|
./run-gdb \
|
||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
main \
|
main \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -3641,7 +3641,7 @@ Or alternatively, if you are using <<tmux>>, do everything in one go with:
|
|||||||
./run \
|
./run \
|
||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--gdb \
|
--gdb \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -3793,7 +3793,7 @@ Example:
|
|||||||
./run \
|
./run \
|
||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--static \
|
--static \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -3879,7 +3879,7 @@ So let's just play with some static ones:
|
|||||||
./run \
|
./run \
|
||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--emulator gem5 \
|
--emulator gem5 \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
....
|
....
|
||||||
@@ -3894,14 +3894,14 @@ TODO: how to escape spaces on the command line arguments?
|
|||||||
--emulator gem5 \
|
--emulator gem5 \
|
||||||
--gdb-wait \
|
--gdb-wait \
|
||||||
--static \
|
--static \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
--userland-args 'asdf "qw er"' \
|
--userland-args 'asdf "qw er"' \
|
||||||
;
|
;
|
||||||
./run-gdb \
|
./run-gdb \
|
||||||
--arch aarch64 \
|
--arch aarch64 \
|
||||||
--emulator gem5 \
|
--emulator gem5 \
|
||||||
--static \
|
--static \
|
||||||
--userland userland/c/print_argv.c \
|
--userland userland/c/command_line_arguments.c \
|
||||||
main \
|
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/exit0.c[]
|
||||||
** link:userland/c/exit1.c[]
|
** link:userland/c/exit1.c[]
|
||||||
** link:userland/c/exit2.c[]
|
** link:userland/c/exit2.c[]
|
||||||
** link:userland/c/print_argv.c[]
|
** link:userland/c/command_line_arguments.c[]
|
||||||
* Standard library
|
* Standard library
|
||||||
** `assert.h`
|
** `assert.h`
|
||||||
*** link:userland/c/assert_fail.c[]
|
*** 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[]
|
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>>
|
||||||
|
|
||||||
|
=== Node.js
|
||||||
|
|
||||||
|
Parent section: <<interpreted-languages>>.
|
||||||
|
|
||||||
|
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
|
=== 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
|
* 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
|
||||||
|
|||||||
5
rootfs_overlay/lkmc/nodejs/command_line_arguments.js
Executable file
5
rootfs_overlay/lkmc/nodejs/command_line_arguments.js
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
for (const arg of process.argv) {
|
||||||
|
console.log(arg);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user