2 * Copyright (C) 2015 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <sys/types.h>
22 #include "../preload.h"
24 static main_t __main__
;
26 static int __preload_main__(int argc
, char **argv
, char **envp
)
28 char *env_file
= getenv("SECCOMP_FILE");
30 if (install_syscall_filter(*argv
, env_file
))
33 unsetenv("LD_PRELOAD");
34 unsetenv("SECCOMP_FILE");
36 return (*__main__
)(argc
, argv
, envp
);
39 int __libc_start_main(main_t main
,
45 void (*rtld_fini
) (void),
48 start_main_t __start_main__
;
50 __start_main__
= dlsym(RTLD_NEXT
, "__libc_start_main");
52 INFO("failed to find __libc_start_main %s\n", dlerror());
56 return (*__start_main__
)(__preload_main__
, argc
, argv
, auxvec
,
57 init
, fini
, rtld_fini
, stack_end
);
60 void __uClibc_main(main_t main
,
63 void (*app_init
)(void),
64 void (*app_fini
)(void),
65 void (*rtld_fini
)(void),
66 void *stack_end attribute_unused
)
68 uClibc_main __start_main__
;
70 __start_main__
= dlsym(RTLD_NEXT
, "__uClibc_main");
72 INFO("failed to find __uClibc_main %s\n", dlerror());
76 return (*__start_main__
)(__preload_main__
, argc
, argv
,
77 app_init
, app_fini
, rtld_fini
, stack_end
);