-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
musl.patch
98 lines (86 loc) · 3.11 KB
/
musl.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
--- a/renderdoc/os/posix/linux/linux_hook.cpp
+++ b/renderdoc/os/posix/linux/linux_hook.cpp
@@ -70,8 +70,10 @@ __attribute__((visibility("default"))) v
void *ret = passthru(filename, flag);
+#ifdef __GLIBC__
if(filename && ret && (flag & RTLD_DEEPBIND))
plthook_lib(ret);
+#endif
return ret;
}
@@ -506,8 +508,10 @@ void *intercept_dlopen(const char *filen
if(filename == NULL)
return ret;
+#ifdef __GLIBC__
if(flag & RTLD_DEEPBIND)
plthook_lib(ret);
+#endif
rdcstr base = get_basename(filename);
--- a/renderdoc/3rdparty/plthook/plthook_elf.c
+++ b/renderdoc/3rdparty/plthook/plthook_elf.c
@@ -62,7 +62,7 @@
#include <link.h>
#include "plthook.h"
-#if defined __UCLIBC__ && !defined RTLD_NOLOAD
+#if !defined(__GLIBC__) && !defined(RTLD_NOLOAD)
#define RTLD_NOLOAD 0
#endif
@@ -204,7 +204,7 @@ static int check_elf_header(const Elf_Eh
#endif
static void set_errmsg(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
-#if defined __ANDROID__ || defined __UCLIBC__
+#if defined(__linux__) && !defined(__GLIBC__)
struct dl_iterate_data {
char* addr;
struct link_map lmap;
@@ -249,7 +249,7 @@ int plthook_open(plthook_t **plthook_out
int plthook_open_by_handle(plthook_t **plthook_out, void *hndl)
{
-#if defined __ANDROID__ || defined __UCLIBC__
+#if defined (__linux__) && !defined(__GLIBC__)
const static char *symbols[] = {
"__INIT_ARRAY__",
"_end",
@@ -288,7 +288,7 @@ int plthook_open_by_address(plthook_t **
{
#if defined __FreeBSD__
return PLTHOOK_NOT_IMPLEMENTED;
-#elif defined __ANDROID__ || defined __UCLIBC__
+#elif defined(__linux__) && !defined(__GLIBC__)
struct dl_iterate_data data = {0,};
data.addr = address;
dl_iterate_phdr(dl_iterate_cb, &data);
@@ -312,7 +312,7 @@ int plthook_open_by_address(plthook_t **
static int plthook_open_executable(plthook_t **plthook_out)
{
-#if defined __ANDROID__ || defined __UCLIBC__
+#if defined(__linux__) && !defined(__GLIBC__)
return plthook_open_shared_library(plthook_out, NULL);
#elif defined __linux__
return plthook_open_real(plthook_out, _r_debug.r_map);
@@ -351,7 +351,7 @@ static int plthook_open_executable(pltho
static int plthook_open_shared_library(plthook_t **plthook_out, const char *filename)
{
void *hndl = dlopen(filename, RTLD_LAZY | RTLD_NOLOAD);
-#if defined __ANDROID__ || defined __UCLIBC__
+#if defined(__linux__) && !defined(__GLIBC__)
int rv;
#else
struct link_map *lmap = NULL;
@@ -361,7 +361,7 @@ static int plthook_open_shared_library(p
set_errmsg("dlopen error: %s", dlerror());
return PLTHOOK_FILE_NOT_FOUND;
}
-#if defined __ANDROID__ || defined __UCLIBC__
+#if defined(__linux__) && !defined(__GLIBC__)
rv = plthook_open_by_handle(plthook_out, hndl);
dlclose(hndl);
return rv;
@@ -553,7 +553,7 @@ static int plthook_open_real(plthook_t *
#if defined __linux__
plthook.plt_addr_base = (char*)lmap->l_addr;
-#if defined __ANDROID__ || defined __UCLIBC__
+#if !defined(__GLIBC__)
dyn_addr_base = (const char*)lmap->l_addr;
#endif
#elif defined __FreeBSD__ || defined __sun