Clang startup files (_init and _fini symbols)

Hi,
I am trying to compile a baremetal clang toolchain (hosted on x86_64, target is aarch64). I am using newlib as replacement for glibc and I am using newlib’s libgloss for implementing syscalls via semihosting (libgloss’s rdimon library and rdimon-crt0 startup file).
Every file I try to compile with clang and newlib rdimon library and startup I get this failure:

ld.lld: error: undefined symbol: _init
referenced by crt0.S:174
/opt/clang/lib/clang-runtimes/aarch64/lib/rdimon-crt0.o:(.text+0x84)

ld.lld: error: undefined symbol: _fini
referenced by crt0.S:269
/opt/clang/lib/clang-runtimes/aarch64/lib/rdimon-crt0.o:(.text+0x160)


I checked how is the compilation process against newlib in gcc, and I found that gcc is also using libgloss’s rdimon library and rdimon-crt0 startup file. But in addition gcc is also linking against crti.o, crtbegin.o, crtend.o and crtn.o. I saw that crti.o is the file that defines the _fini and _init symbols in:

.section    ".init"
.align 2
.global _init
TYPE(_init)

_init:
FUNC_START

.section    ".fini"
.align  2
.global _fini
TYPE(_fini)

So my question is how can I generate those symbols in clang compilation? I only found crti.cpp file in $LLVM_TOP/libc/loader/linux/crti.cpp but it’s an empty file.
Is there any documentation about how and which startup files are generated with clang compilation?

compiler-rt ships something similar:
https://reviews.llvm.org/D28791
Your link refers to the LLVM-libc.