Skip to content

Commit

Permalink
Commit f877881 was missing a file
Browse files Browse the repository at this point in the history
  • Loading branch information
th-otto committed Jun 5, 2024
1 parent 69d64fc commit 9ee3a4b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions include/linux/libcmain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#if defined(__LINUX_GLIBC_WRAP_H)

/* ugly hack to get __libc_start_main versioned */

#if __GLIBC_PREREQ(2, 34)

#define STR_(s) #s
#define STR(s) STR_(s)
#include <dlfcn.h>

#ifdef __UCLIBC__
#define __libc_start_main __uClibc_main
#endif

#ifdef __cplusplus
extern "C" {
#endif
int __libc_start_main(
int (*main)(int,char**,char**), int ac, char **av,
int (*init)(void), void (*fini)(void),
void (*rtld_fini)(void), void *stack_end);
int __libc_start_main(
int (*main)(int,char**,char**), int ac, char **av,
int (*init)(void), void (*fini)(void),
void (*rtld_fini)(void), void *stack_end)
{
typeof(__libc_start_main) *real_lsm;
if ((*(void**)&real_lsm = dlsym(RTLD_NEXT, STR(__libc_start_main))) != 0)
return real_lsm(main, ac, av, init, fini, rtld_fini, stack_end);
fputs("BUG: dlsym error\n", stderr);
return 1;
}
#ifdef __cplusplus
}
#endif
#undef STR
#undef STR_
#endif
#endif

0 comments on commit 9ee3a4b

Please sign in to comment.