}
}
+static bool hasCoreLibNI()
+{
+ FILE *fp;
+ char buff[1024];
+ std::string ildasm = concatPath(getRuntimeDir(), "ildasm");
+ std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll");
+ std::string cmd = ildasm + " " + coreLib + " | grep '\\.corflags'";
+ fp = popen(cmd.c_str(), "r");
+ if (fp != NULL) {
+ while (fgets(buff, sizeof(buff), fp) != NULL) {
+ buff[strlen(buff) - 1] = '\0';
+ }
+ std::string corflag = replaceAll(buff, ".corflags", "");
+ corflag.erase(std::remove(corflag.begin(), corflag.end(), ' '), corflag.end());
+ // CorFlags.ILLibrary=0x00000004 (.ni.dll)
+ if (!strcmp(corflag.substr(0, 10).c_str(), "0x00000004")) {
+ pclose(fp);
+ return true;
+ }
+ pclose(fp);
+ }
+ return false;
+}
+
static ni_error_e createCoreLibNI(DWORD flags)
{
std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll");
std::string niCoreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.ni.dll");
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
- if (!isFile(coreLibBackup)) {
+ if (!isFile(coreLibBackup) && !hasCoreLibNI()) {
if (!crossgen(coreLib, std::string(), flags)) {
if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
fprintf(stderr, "Failed to rename System.Private.CoreLib.dll\n");
std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll");
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
- if (!isFile(coreLibBackup)) {
- return;
+ if (hasCoreLibNI()) {
+ if (!isFile(coreLibBackup)) {
+ return;
+ }
+
+ if (remove(coreLib.c_str())) {
+ fprintf(stderr, "Failed to remove System.Private.CoreLib native image file\n");
+ }
+ if (rename(coreLibBackup.c_str(), coreLib.c_str())) {
+ fprintf(stderr, "Failed to rename System.Private.CoreLib.Backup to origin\n");
+ }
}
#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
}
#endif
- if (remove(coreLib.c_str())) {
- fprintf(stderr, "Failed to remove System.Private.CoreLib native image file\n");
- }
-
- if (rename(coreLibBackup.c_str(), coreLib.c_str())) {
- fprintf(stderr, "Failed to rename System.Private.CoreLib.Backup to origin\n");
- }
-
const std::string platformDirs[] = {getRuntimeDir(), getTizenFXDir()};
removeNIUnderDirs(platformDirs, 2);