How to use a custom crt0.o in Newlib for my OS?
Troy Mitchell
troymitchell988@gmail.com
Wed Oct 16 07:03:29 GMT 2024
Hello Newlib developers,
I am working on a custom operating system called Caffeinix
and have created a new directory structure under
newlib/libc/sys/caffeinix:
```
caffeinix
├── aclocal.m4
├── autom4te.cache
├── configure
├── configure.in
├── crt0.c
├── Makefile.am
├── Makefile.in
└── syscalls.c
1 directory, 7 files
```
the syscalls.c works well, but crt0.o is from
libgloss/riscv/crt0.S(I checked by disassembling)
I'm sure my crt0.c is built.
Here is the relevant structure in the build directory:
```
./riscv64-caffeinix/libgloss/riscv/crt0.d
./riscv64-caffeinix/libgloss/riscv/crt0.o
./riscv64-caffeinix/newlib/crt0.o
./riscv64-caffeinix/newlib/libc/crt0.o
./riscv64-caffeinix/newlib/libc/sys/caffeinix/crt0.o
./riscv64-caffeinix/newlib/libc/sys/crt0.o
```
Here are the relevant configurations
Makefile.am
```
AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
AM_CCASFLAGS = $(INCLUDES)
noinst_LIBRARIES = lib.a
lib_a_SOURCES = syscalls.c
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS)
all-local: crt0.o
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
```
configure.in
```
AC_PREREQ(2.59)
AC_INIT([newlib], [NEWLIB_VERSION])
AC_CONFIG_SRCDIR([crt0.c])
AC_CONFIG_AUX_DIR(../../../..)
NEWLIB_CONFIGURE(../../..)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
```
Thanks for ur any help!
Best regards,
Troy
More information about the Newlib
mailing list