projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
netinet/if_ether.h: add ETH_P_LLDP from linux v5.3
[musl]
/
src
/
env
/
__libc_start_main.c
diff --git
a/src/env/__libc_start_main.c
b/src/env/__libc_start_main.c
index
ba4d213
..
8fbe526
100644
(file)
--- a/
src/env/__libc_start_main.c
+++ b/
src/env/__libc_start_main.c
@@
-17,6
+17,9
@@
weak_alias(dummy1, __init_ssp);
#define AUX_CNT 38
#define AUX_CNT 38
+#ifdef __GNUC__
+__attribute__((__noinline__))
+#endif
void __init_libc(char **envp, char *pn)
{
size_t i, *auxv, aux[AUX_CNT] = { 0 };
void __init_libc(char **envp, char *pn)
{
size_t i, *auxv, aux[AUX_CNT] = { 0 };
@@
-25,7
+28,7
@@
void __init_libc(char **envp, char *pn)
libc.auxv = auxv = (void *)(envp+i+1);
for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
__hwcap = aux[AT_HWCAP];
libc.auxv = auxv = (void *)(envp+i+1);
for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
__hwcap = aux[AT_HWCAP];
- __sysinfo = aux[AT_SYSINFO];
+
if (aux[AT_SYSINFO])
__sysinfo = aux[AT_SYSINFO];
libc.page_size = aux[AT_PAGESZ];
if (!pn) pn = (void*)aux[AT_EXECFN];
libc.page_size = aux[AT_PAGESZ];
if (!pn) pn = (void*)aux[AT_EXECFN];
@@
-63,18
+66,22
@@
static void libc_start_init(void)
weak_alias(libc_start_init, __libc_start_init);
weak_alias(libc_start_init, __libc_start_init);
-static int libc_start_main_stage2(int (*)(int,char **,char **), int, char **);
+typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);
+static lsm2_fn libc_start_main_stage2;
int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
{
char **envp = argv+argc+1;
int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
{
char **envp = argv+argc+1;
+ /* External linkage, and explicit noinline attribute if available,
+ * are used to prevent the stack frame used during init from
+ * persisting for the entire process lifetime. */
__init_libc(envp, argv[0]);
/* Barrier against hoisting application code or anything using ssp
* or thread pointer prior to its initialization above. */
__init_libc(envp, argv[0]);
/* Barrier against hoisting application code or anything using ssp
* or thread pointer prior to its initialization above. */
-
int (*stage2)()
;
- __asm__ ( "" : "
=r"(stage2) : "r"(libc_start_main_stage2)
: "memory" );
+
lsm2_fn *stage2 = libc_start_main_stage2
;
+ __asm__ ( "" : "
+r"(stage2) :
: "memory" );
return stage2(main, argc, argv);
}
return stage2(main, argc, argv);
}