summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/sources/__main_void.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 16:08:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 16:08:03 +0000
commitf1db79e6e5c383cf76f3bf0dd42115d19591a72b (patch)
tree3f9509008e8a130c45b7e31b1520d66d720493ec /libc-bottom-half/sources/__main_void.c
parentAdding upstream version 0.0~git20230821.ec4566b. (diff)
downloadwasi-libc-upstream.tar.xz
wasi-libc-upstream.zip
Adding upstream version 0.0~git20240411.9e8c542.upstream/0.0_git20240411.9e8c542upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-bottom-half/sources/__main_void.c')
-rw-r--r--libc-bottom-half/sources/__main_void.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libc-bottom-half/sources/__main_void.c b/libc-bottom-half/sources/__main_void.c
index cba22ef..9f46419 100644
--- a/libc-bottom-half/sources/__main_void.c
+++ b/libc-bottom-half/sources/__main_void.c
@@ -3,11 +3,22 @@
#include <sysexits.h>
// The user's `main` function, expecting arguments.
+//
+// Note that we make this a weak symbol so that it will have a
+// `WASM_SYM_BINDING_WEAK` flag in libc.so, which tells the dynamic linker that
+// it need not be defined (e.g. in reactor-style apps with no main function).
+// See also the TODO comment on `__main_void` below.
+__attribute__((__weak__))
int __main_argc_argv(int argc, char *argv[]);
// If the user's `main` function expects arguments, the compiler will rename
// it to `__main_argc_argv`, and this version will get linked in, which
// initializes the argument data and calls `__main_argc_argv`.
+//
+// TODO: Ideally this function would be defined in a crt*.o file and linked in
+// as necessary by the Clang driver. However, moving it to crt1-command.c
+// breaks `--no-gc-sections`, so we'll probably need to create a new file
+// (e.g. crt0.o or crtend.o) and teach Clang to use it when needed.
__attribute__((__weak__, nodebug))
int __main_void(void) {
__wasi_errno_t err;