On 2025-09-15 09:11:12+0200, Benjamin Berg wrote: > From: Benjamin Berg <benjamin.b...@intel.com> > > In principle, it is possible to use nolibc for only some object files in > a program. In that case, the startup code in _start and _start_c is not > going to be used. Add the NOLIBC_NO_STARTCODE compile time option to > disable it entirely and also remove anything that depends on it.
Not a big fan of the naming. More than only _start()/_start_c() are disabled. Maybe NOLIBC_NO_RUNTIME? I'm horrible at naming... > Doing this avoids warnings from modpost for UML as the _start_c code > references the main function from the .init.text section while it is not > inside .init itself. > > Signed-off-by: Benjamin Berg <benjamin.b...@intel.com> > --- > tools/include/nolibc/arch-arm.h | 2 ++ > tools/include/nolibc/arch-arm64.h | 2 ++ > tools/include/nolibc/arch-loongarch.h | 2 ++ > tools/include/nolibc/arch-m68k.h | 2 ++ > tools/include/nolibc/arch-mips.h | 2 ++ > tools/include/nolibc/arch-powerpc.h | 2 ++ > tools/include/nolibc/arch-riscv.h | 2 ++ > tools/include/nolibc/arch-s390.h | 2 ++ > tools/include/nolibc/arch-sh.h | 2 ++ > tools/include/nolibc/arch-sparc.h | 2 ++ > tools/include/nolibc/arch-x86.h | 4 ++++ > tools/include/nolibc/crt.h | 3 +++ > tools/include/nolibc/stackprotector.h | 2 ++ > tools/include/nolibc/stdlib.h | 2 ++ > tools/include/nolibc/sys.h | 3 ++- > tools/include/nolibc/sys/auxv.h | 3 +++ > 16 files changed, 36 insertions(+), 1 deletion(-) > > diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h > index 1f66e7e5a444..24ad348cc1e8 100644 > --- a/tools/include/nolibc/arch-arm.h > +++ b/tools/include/nolibc/arch-arm.h > @@ -185,6 +185,7 @@ > }) > > /* startup code */ > +#ifndef NOLIBC_NO_STARTCODE I'd prefer the ifdef around the comments. > void __attribute__((weak, noreturn)) __nolibc_entrypoint > __no_stack_protector _start(void) > { > __asm__ volatile ( > @@ -193,5 +194,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint > __no_stack_protector _s > ); > __nolibc_entrypoint_epilogue(); > } > +#endif /* NOLIBC_NO_STARTCODE */ (...)