mirror of
https://github.com/torvalds/linux.git
synced 2026-01-24 23:16:46 +00:00
tools/nolibc: add option to disable runtime
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_RUNTIME compile time option to disable it entirely and also remove anything that depends on it. 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.berg@intel.com> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
This commit is contained in:
committed by
Thomas Weißschuh
parent
2cb6cc8361
commit
3d66c4e14f
@@ -184,6 +184,7 @@
|
||||
_arg1; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -193,5 +194,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_ARM_H */
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
_arg1; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -150,4 +151,5 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
#endif /* _NOLIBC_ARCH_ARM64_H */
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
_arg1; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -151,5 +152,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_LOONGARCH_H */
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
_num; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
void _start(void);
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -137,5 +138,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_M68K_H */
|
||||
|
||||
@@ -245,6 +245,7 @@
|
||||
|
||||
#endif /* _ABIO32 */
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code, note that it's called __start on MIPS */
|
||||
void __start(void);
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector __start(void)
|
||||
@@ -266,5 +267,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector __
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_MIPS_H */
|
||||
|
||||
@@ -183,6 +183,7 @@
|
||||
#endif
|
||||
#endif /* !__powerpc64__ */
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -215,5 +216,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
#endif
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_POWERPC_H */
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
_arg1; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -152,5 +153,6 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_RISCV_H */
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
_arg1; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -155,6 +156,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
struct s390_mmap_arg_struct {
|
||||
unsigned long addr;
|
||||
|
||||
@@ -140,6 +140,7 @@
|
||||
_ret; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void _start_wrapper(void);
|
||||
void __attribute__((weak,noreturn)) __nolibc_entrypoint __no_stack_protector _start_wrapper(void)
|
||||
@@ -158,5 +159,6 @@ void __attribute__((weak,noreturn)) __nolibc_entrypoint __no_stack_protector _st
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_ARCH_SH_H */
|
||||
|
||||
@@ -152,6 +152,7 @@
|
||||
_arg1; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _start(void)
|
||||
{
|
||||
@@ -169,6 +170,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
static pid_t getpid(void);
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
_eax; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
/*
|
||||
* i386 System V ABI mandates:
|
||||
@@ -176,6 +177,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#else /* !defined(__x86_64__) */
|
||||
|
||||
@@ -323,6 +325,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
_ret; \
|
||||
})
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* startup code */
|
||||
/*
|
||||
* x86-64 System V ABI mandates:
|
||||
@@ -340,6 +343,7 @@ void __attribute__((weak, noreturn)) __nolibc_entrypoint __no_stack_protector _s
|
||||
);
|
||||
__nolibc_entrypoint_epilogue();
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#define NOLIBC_ARCH_HAS_MEMMOVE
|
||||
void *memmove(void *dst, const void *src, size_t len);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#ifndef _NOLIBC_CRT_H
|
||||
#define _NOLIBC_CRT_H
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
char **environ __attribute__((weak));
|
||||
@@ -88,4 +90,5 @@ void _start_c(long *sp)
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
#endif /* _NOLIBC_CRT_H */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
#if defined(_NOLIBC_STACKPROTECTOR)
|
||||
|
||||
#include "sys.h"
|
||||
@@ -49,5 +50,6 @@ static __no_stack_protector void __stack_chk_init(void)
|
||||
#else /* !defined(_NOLIBC_STACKPROTECTOR) */
|
||||
static void __stack_chk_init(void) {}
|
||||
#endif /* defined(_NOLIBC_STACKPROTECTOR) */
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
#endif /* _NOLIBC_STACKPROTECTOR_H */
|
||||
|
||||
@@ -100,6 +100,7 @@ void free(void *ptr)
|
||||
munmap(heap, heap->len);
|
||||
}
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
/* getenv() tries to find the environment variable named <name> in the
|
||||
* environment array pointed to by global variable "environ" which must be
|
||||
* declared as a char **, and must be terminated by a NULL (it is recommended
|
||||
@@ -122,6 +123,7 @@ char *getenv(const char *name)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
static __attribute__((unused))
|
||||
void *malloc(size_t len)
|
||||
|
||||
@@ -512,6 +512,7 @@ pid_t gettid(void)
|
||||
return sys_gettid();
|
||||
}
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
static unsigned long getauxval(unsigned long key);
|
||||
|
||||
/*
|
||||
@@ -523,7 +524,7 @@ int getpagesize(void)
|
||||
{
|
||||
return __sysret((int)getauxval(AT_PAGESZ) ?: -ENOENT);
|
||||
}
|
||||
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
|
||||
/*
|
||||
* uid_t getuid(void);
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef _NOLIBC_SYS_AUXV_H
|
||||
#define _NOLIBC_SYS_AUXV_H
|
||||
|
||||
#ifndef NOLIBC_NO_RUNTIME
|
||||
|
||||
#include "../crt.h"
|
||||
|
||||
static __attribute__((unused))
|
||||
@@ -38,4 +40,5 @@ unsigned long getauxval(unsigned long type)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* NOLIBC_NO_RUNTIME */
|
||||
#endif /* _NOLIBC_SYS_AUXV_H */
|
||||
|
||||
Reference in New Issue
Block a user