-include ../Makefile.cfg
-BIN = $(OUTPUTDIR)Libs/crt0.o $(OUTPUTDIR)Libs/crti.o $(OUTPUTDIR)Libs/crtn.o
+BIN = $(OUTPUTDIR)Libs/crt0.o $(OUTPUTDIR)Libs/crt0S.o $(OUTPUTDIR)Libs/crti.o $(OUTPUTDIR)Libs/crtn.o
+
+CFLAGS := -std=c99
.PHONY: all clean install utest utest-build generate_exp
utest generate_exp utest-build utest-run:
@echo > /dev/null
-$(OUTPUTDIR)Libs/%.o: %.c
+$(OUTPUTDIR)Libs/%.o: %.c Makefile
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) -c $< -o $@
+$(OUTPUTDIR)Libs/%S.o: %S.c Makefile
@mkdir -p $(dir $@)
- $(CC) -c $< -o $@
+ $(CC) $(CFLAGS) -c $< -o $@ -fPIC
$(OUTPUTDIR)Libs/%.o: $(ARCHDIR)-%.S
@mkdir -p $(dir $@)
- $(CC) -c $< -o $@
+ $(CC) $(CFLAGS) -c $< -o $@
#$(OUTPUTDIR)Libs/crt0.o: obj-$(ARCH)/crt0_asm.o obj-$(ARCH)/crt0_c.o
# @mkdir -p $(dir $@)
constructor_t _crtbegin_ctors[0] __attribute__((section(".ctors")));
exithandler_t _crt0_exit_handler;
-//extern constructor_t _crtbegin_ctors[];
extern void _init(void);
extern void _fini(void);
extern void _exit(int status) __attribute__((noreturn));
void start(int argc, char *argv[], char **envp)
{
- int i;
- int rv;
-
- for( i = 0; _crtbegin_ctors[i]; i ++ )
+ // TODO: isn't this handled by _init?
+ for( int i = 0; _crtbegin_ctors[i]; i ++ )
_crtbegin_ctors[i]();
_init();
- rv = main(argc, argv, envp);
+ int rv = main(argc, argv, envp);
if( _crt0_exit_handler )
_crt0_exit_handler();
--- /dev/null
+/*
+ * Acess2
+ * - CRT0 Shared library version
+ */
+
+typedef void (*exithandler_t)(void);
+typedef void (*constructor_t)(void);
+
+extern void _SysDebug(const char *, ...);
+extern void _init(void);
+extern void _fini(void);
+extern int SoMain(void *Base, int argc, char *argv[], char **envp) __attribute__((weak));
+
+int SoStart(void *Base, int argc, char *argv[], char **envp)
+{
+ //_SysDebug("SoStart(%p,%i,%p)", Base, argc, argv);
+ _init();
+
+ if( SoMain )
+ return SoMain(Base, argc, argv, envp);
+ else
+ return 0;
+}