Skip to content

Commit e0cd57d

Browse files
authored
[compiler-rt] Remove support and workarounds for Android 4 and older (#124056)
1 parent 5a7d92f commit e0cd57d

File tree

7 files changed

+15
-43
lines changed

7 files changed

+15
-43
lines changed

compiler-rt/lib/asan/tests/asan_test.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,13 +1166,9 @@ TEST(AddressSanitizer, DISABLED_StressStackReuseAndExceptionsTest) {
11661166

11671167
#if !defined(_WIN32)
11681168
TEST(AddressSanitizer, MlockTest) {
1169-
#if !defined(__ANDROID__) || __ANDROID_API__ >= 17
11701169
EXPECT_EQ(0, mlockall(MCL_CURRENT));
1171-
#endif
1172-
EXPECT_EQ(0, mlock((void*)0x12345, 0x5678));
1173-
#if !defined(__ANDROID__) || __ANDROID_API__ >= 17
1170+
EXPECT_EQ(0, mlock((void *)0x12345, 0x5678));
11741171
EXPECT_EQ(0, munlockall());
1175-
#endif
11761172
EXPECT_EQ(0, munlock((void*)0x987, 0x654));
11771173
}
11781174
#endif

compiler-rt/lib/lsan/lsan_common_linux.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ static int ProcessGlobalRegionsCallback(struct dl_phdr_info *info, size_t size,
9393
return 0;
9494
}
9595

96-
#if SANITIZER_ANDROID && __ANDROID_API__ < 21
97-
extern "C" __attribute__((weak)) int dl_iterate_phdr(
98-
int (*)(struct dl_phdr_info *, size_t, void *), void *);
99-
#endif
100-
10196
// Scans global variables for heap pointers.
10297
void ProcessGlobalRegions(Frontier *frontier) {
10398
if (!flags()->use_globals) return;

compiler-rt/lib/sanitizer_common/sanitizer_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,6 @@ typedef void (*RangeIteratorCallback)(uptr begin, uptr end, void *arg);
927927

928928
enum AndroidApiLevel {
929929
ANDROID_NOT_ANDROID = 0,
930-
ANDROID_KITKAT = 19,
931930
ANDROID_LOLLIPOP_MR1 = 22,
932931
ANDROID_POST_LOLLIPOP = 23
933932
};

compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,21 @@
2121

2222
#if SANITIZER_LINUX || SANITIZER_FUCHSIA
2323

24-
# if (__GLIBC_PREREQ(2, 16) || (SANITIZER_ANDROID && __ANDROID_API__ >= 21) || \
25-
SANITIZER_FUCHSIA) && \
26-
!SANITIZER_GO
27-
# define SANITIZER_USE_GETAUXVAL 1
28-
# else
29-
# define SANITIZER_USE_GETAUXVAL 0
30-
# endif
31-
32-
# if SANITIZER_USE_GETAUXVAL
33-
# include <sys/auxv.h>
34-
# else
24+
# if (__GLIBC_PREREQ(2, 16) || SANITIZER_ANDROID || SANITIZER_FUCHSIA) && \
25+
!SANITIZER_GO
26+
# define SANITIZER_USE_GETAUXVAL 1
27+
# else
28+
# define SANITIZER_USE_GETAUXVAL 0
29+
# endif
30+
31+
# if SANITIZER_USE_GETAUXVAL
32+
# include <sys/auxv.h>
33+
# else
3534
// The weak getauxval definition allows to check for the function at runtime.
3635
// This is useful for Android, when compiled at a lower API level yet running
3736
// on a more recent platform that offers the function.
3837
extern "C" SANITIZER_WEAK_ATTRIBUTE unsigned long getauxval(unsigned long type);
39-
# endif
38+
# endif
4039

4140
#elif SANITIZER_NETBSD
4241

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,11 +1849,6 @@ int internal_uname(struct utsname *buf) {
18491849
# endif
18501850

18511851
# if SANITIZER_ANDROID
1852-
# if __ANDROID_API__ < 21
1853-
extern "C" __attribute__((weak)) int dl_iterate_phdr(
1854-
int (*)(struct dl_phdr_info *, size_t, void *), void *);
1855-
# endif
1856-
18571852
static int dl_iterate_phdr_test_cb(struct dl_phdr_info *info, size_t size,
18581853
void *data) {
18591854
// Any name starting with "lib" indicates a bug in L where library base names
@@ -1869,18 +1864,14 @@ static int dl_iterate_phdr_test_cb(struct dl_phdr_info *info, size_t size,
18691864
static atomic_uint32_t android_api_level;
18701865

18711866
static AndroidApiLevel AndroidDetectApiLevelStatic() {
1872-
# if __ANDROID_API__ <= 19
1873-
return ANDROID_KITKAT;
1874-
# elif __ANDROID_API__ <= 22
1867+
# if __ANDROID_API__ <= 22
18751868
return ANDROID_LOLLIPOP_MR1;
18761869
# else
18771870
return ANDROID_POST_LOLLIPOP;
18781871
# endif
18791872
}
18801873

18811874
static AndroidApiLevel AndroidDetectApiLevel() {
1882-
if (!&dl_iterate_phdr)
1883-
return ANDROID_KITKAT; // K or lower
18841875
bool base_name_seen = false;
18851876
dl_iterate_phdr(dl_iterate_phdr_test_cb, &base_name_seen);
18861877
if (base_name_seen)

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,6 @@ static int dl_iterate_phdr_cb(dl_phdr_info *info, size_t size, void *arg) {
773773
return 0;
774774
}
775775

776-
# if SANITIZER_ANDROID && __ANDROID_API__ < 21
777-
extern "C" __attribute__((weak)) int dl_iterate_phdr(
778-
int (*)(struct dl_phdr_info *, size_t, void *), void *);
779-
# endif
780-
781776
static bool requiresProcmaps() {
782777
# if SANITIZER_ANDROID && __ANDROID_API__ <= 22
783778
// Fall back to /proc/maps if dl_iterate_phdr is unavailable or broken.
@@ -940,11 +935,8 @@ extern "C" SANITIZER_WEAK_ATTRIBUTE int __android_log_write(int prio,
940935
void WriteOneLineToSyslog(const char *s) {
941936
if (&async_safe_write_log) {
942937
async_safe_write_log(SANITIZER_ANDROID_LOG_INFO, GetProcessName(), s);
943-
} else if (AndroidGetApiLevel() > ANDROID_KITKAT) {
944-
syslog(LOG_INFO, "%s", s);
945938
} else {
946-
CHECK(&__android_log_write);
947-
__android_log_write(SANITIZER_ANDROID_LOG_INFO, nullptr, s);
939+
syslog(LOG_INFO, "%s", s);
948940
}
949941
}
950942

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
10931093
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
10941094
CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
10951095

1096-
#if SANITIZER_LINUX && (__ANDROID_API__ >= 21 || __GLIBC_PREREQ (2, 14))
1096+
# if SANITIZER_LINUX && (SANITIZER_ANDROID || __GLIBC_PREREQ(2, 14))
10971097
CHECK_TYPE_SIZE(mmsghdr);
10981098
CHECK_SIZE_AND_OFFSET(mmsghdr, msg_hdr);
10991099
CHECK_SIZE_AND_OFFSET(mmsghdr, msg_len);

0 commit comments

Comments
 (0)