/
bionic.patch
137 lines (116 loc) · 4.25 KB
/
bionic.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
From b5f7e8bcebbfaf9afe605432879918ed54638ab2 Mon Sep 17 00:00:00 2001
From: xc-racer99 <xc-racer2@live.ca>
Date: Tue, 12 Apr 2016 19:02:17 -0700
Subject: [PATCH 1/3] bionic: Restore non-pie support
---
linker/Android.mk | 4 ++++
linker/linker.cpp | 2 ++
2 files changed, 6 insertions(+)
diff --git a/linker/Android.mk b/linker/Android.mk
index 4a4ca5c5a..a02657a74 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -54,6 +54,10 @@ ifeq ($(TARGET_IS_64_BIT),true)
LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
endif
+ifeq ($(TARGET_ENABLE_NON_PIE_SUPPORT),true)
+ LOCAL_CFLAGS += -DENABLE_NON_PIE_SUPPORT
+endif
+
# We need to access Bionic private headers in the linker.
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
diff --git a/linker/linker.cpp b/linker/linker.cpp
index a043b859a..659f2cf5c 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -4278,11 +4278,13 @@ static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(
}
si->dynamic = nullptr;
+#ifndef ENABLE_NON_PIE_SUPPORT
ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
if (elf_hdr->e_type != ET_DYN) {
__libc_fatal("\"%s\": error: only position independent executables (PIE) are supported.",
args.argv[0]);
}
+#endif
// Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
parse_LD_LIBRARY_PATH(ldpath_env);
--
2.11.0
From 4190cbea4895d7c997bd2ab156481713667e50a2 Mon Sep 17 00:00:00 2001
From: Kyle Repinski <repinski23@gmail.com>
Date: Sat, 27 Aug 2016 20:19:20 -0500
Subject: [PATCH 2/3] linker: Add build flag to allow text relocations for
platform libs.
---
linker/Android.mk | 4 ++++
linker/linker.cpp | 6 ++++++
2 files changed, 10 insertions(+)
diff --git a/linker/Android.mk b/linker/Android.mk
index a02657a74..1fa7fae55 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -58,6 +58,10 @@ ifeq ($(TARGET_ENABLE_NON_PIE_SUPPORT),true)
LOCAL_CFLAGS += -DENABLE_NON_PIE_SUPPORT
endif
+ifeq ($(TARGET_NEEDS_PLATFORM_TEXTRELS),true)
+LOCAL_CFLAGS += -DALLOW_PLATFORM_TEXTRELS
+endif
+
# We need to access Bionic private headers in the linker.
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../libc/
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 659f2cf5c..c476cfd6f 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3952,8 +3952,14 @@ bool soinfo::link_image(const soinfo_list_t& global_group, const soinfo_list_t&
#if !defined(__LP64__)
if (has_text_relocations) {
+#ifndef ALLOW_PLATFORM_TEXTRELS
// Fail if app is targeting sdk version > 22
if (get_application_target_sdk_version() > 22) {
+#else
+ // Some devices require an exception for platform libs (e.g. vendor libs)
+ if (get_application_target_sdk_version() != __ANDROID_API__ &&
+ get_application_target_sdk_version() > 22) {
+#endif
PRINT("%s: has text relocations", get_realpath());
DL_ERR("%s: has text relocations", get_realpath());
return false;
--
2.11.0
From a95aa338458d72dcf70926b3c47cbda82efb2f7f Mon Sep 17 00:00:00 2001
From: Tom Marshall <tdm@cyngn.com>
Date: Tue, 3 Nov 2015 11:12:23 -0800
Subject: [PATCH 3/3] bionic: Let popen fall back to /sbin/sh
minivold in recovery uses popen, where /system/bin/sh is not available.
Change-Id: I2136b0ca4188b7b44416f5d79492fc006382d4ad
---
libc/include/paths.h | 1 +
libc/upstream-netbsd/lib/libc/gen/popen.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/libc/include/paths.h b/libc/include/paths.h
index 82c28042f..7700cdd66 100644
--- a/libc/include/paths.h
+++ b/libc/include/paths.h
@@ -33,6 +33,7 @@
#define _PATHS_H_
#define _PATH_BSHELL "/system/bin/sh"
+#define _PATH_BSHELL2 "/sbin/sh"
#define _PATH_CONSOLE "/dev/console"
#define _PATH_DEFPATH "/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin"
#define _PATH_DEV "/dev/"
diff --git a/libc/upstream-netbsd/lib/libc/gen/popen.c b/libc/upstream-netbsd/lib/libc/gen/popen.c
index 593e34631..b6ce47c5d 100644
--- a/libc/upstream-netbsd/lib/libc/gen/popen.c
+++ b/libc/upstream-netbsd/lib/libc/gen/popen.c
@@ -152,6 +152,8 @@ popen(const char *command, const char *type)
}
execl(_PATH_BSHELL, "sh", "-c", command, NULL);
+ if (errno == ENOENT)
+ execl(_PATH_BSHELL2, "sh", "-c", command, NULL);
_exit(127);
/* NOTREACHED */
}
--
2.11.0