summaryrefslogtreecommitdiffhomepage
path: root/public/tools/ld.dyn/src/CommandLine.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-24 13:38:05 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-24 13:38:05 +0200
commitde88c44c68f3941e003ddaf13042875370f10978 (patch)
tree14b0909de5d6d10fc7ef44fc470d210f21e94f25 /public/tools/ld.dyn/src/CommandLine.cc
parente6185ca92212ab0686892a1a12efd392f895c1f7 (diff)
dev, tooling: Improve the tools and frameworks on userspace.
Details: - See commit details for more. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'public/tools/ld.dyn/src/CommandLine.cc')
-rw-r--r--public/tools/ld.dyn/src/CommandLine.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/public/tools/ld.dyn/src/CommandLine.cc b/public/tools/ld.dyn/src/CommandLine.cc
new file mode 100644
index 00000000..90a79796
--- /dev/null
+++ b/public/tools/ld.dyn/src/CommandLine.cc
@@ -0,0 +1,47 @@
+/*
+ * Created on Thu Oct 17 08:00:42 CEST 2024
+ *
+ * Copyright (c) 2024-2025 Amlal El Mahrouss
+ */
+
+#include <user/SystemCalls.h>
+
+/// @brief Library loader.
+
+#define DYNLIB_FLAG "-dyn"
+
+SInt32 _NeMain(SInt32 argc, Char* argv[])
+{
+ SCI_UNUSED(argc);
+ SCI_UNUSED(argv);
+
+ PrintOut(nullptr, "%s", "ld.dyn: Dynamic Loader.\n");
+ PrintOut(nullptr, "%s", "ld.dyn: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n");
+
+ for (SInt32 i = 1U; i < argc; ++i)
+ {
+ if (MmStrCmp(argv[i], DYNLIB_FLAG) == 0)
+ {
+ UIntPtr ret = RtlSpawnProcess(argv[i], 0, nullptr, nullptr, 0);
+
+ if (0 < ret)
+ {
+ return RtlSpawnIB(ret);
+ }
+
+ PrintOut(nullptr, "%s", "ld.dyn: Failed to load the library.\n");
+ PrintOut(nullptr, "%s", "ld.dyn: Make sure the library is valid.\n");
+
+ break;
+ }
+ else
+ {
+ PrintOut(nullptr, "%s", "ld.dyn: Invalid argument.\n");
+ PrintOut(nullptr, "%s", "ld.dyn: Use -dyn <path> to load a dynamic library.\n");
+
+ break;
+ }
+ }
+
+ return EXIT_FAILURE;
+}