Skip to content

Commit 2447658

Browse files
committed
In case of Android and the library is in /system/lib, or if the library doesn't end with .so, we will give warning only and return empty sectionInfo.
1 parent 3a0dd61 commit 2447658

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

stdlib/public/runtime/ImageInspectionELF.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
#include <link.h>
2828
#include <string.h>
2929

30+
#if defined(__ANDROID__)
31+
#include "llvm/ADT/StringRef.h"
32+
#endif
33+
3034
using namespace swift;
3135

3236
/// The symbol name in the image that identifies the beginning of the
@@ -68,6 +72,13 @@ static SectionInfo getSectionInfo(const char *imageName,
6872
SectionInfo sectionInfo = { 0, nullptr };
6973
void *handle = dlopen(imageName, RTLD_LAZY | RTLD_NOLOAD);
7074
if (!handle) {
75+
#ifdef __ANDROID__
76+
llvm::StringRef imagePath = llvm::StringRef(imageName);
77+
if (imagePath.startswith("/system/lib") ||
78+
(imageName && !imagePath.endswith(".so"))) {
79+
return sectionInfo;
80+
}
81+
#endif
7182
fatalError(/* flags = */ 0, "dlopen() failed on `%s': %s", imageName,
7283
dlerror());
7384
}

0 commit comments

Comments
 (0)