Move defines to spec and set smack label on file with default base addresses
authorGleb Balykov <g.balykov@samsung.com>
Tue, 9 Jul 2019 13:56:24 +0000 (16:56 +0300)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Tue, 16 Jul 2019 05:05:17 +0000 (14:05 +0900)
NativeLauncher/CMakeLists.txt
NativeLauncher/tool/ni_common.cc
packaging/dotnet-launcher.spec

index 9773988..b5c2a38 100644 (file)
@@ -46,6 +46,14 @@ IF(DEFINED UNIQUE_DEFAULT_BASE_ADDR_SUPPORT)
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUNIQUE_DEFAULT_BASE_ADDR_SUPPORT")
 ENDIF(DEFINED UNIQUE_DEFAULT_BASE_ADDR_SUPPORT)
 
+IF(DEFINED SYSTEM_BASE_FILE)
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DSYSTEM_BASE_FILE=${SYSTEM_BASE_FILE}")
+ENDIF(DEFINED SYSTEM_BASE_FILE)
+
+IF(DEFINED DEFAULT_BASE_ADDR_START)
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEFAULT_BASE_ADDR_START=${DEFAULT_BASE_ADDR_START}")
+ENDIF(DEFINED DEFAULT_BASE_ADDR_START)
+
 OPTION(NOT_USE_FUNCTION "Remove build warning" OFF)
 IF(NOT_USE_FUNCTION)
     ADD_DEFINITIONS("-DNOT_USE_FUNCTION")
index 79fa9f4..88fbb28 100644 (file)
 #error "CROSSGEN_PATH is missed"
 #endif
 
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
-#define SYSTEM_BASE_FILE "/usr/share/dotnet.tizen/system.base.addr.txt"
-#define DEFAULT_BASE_ADDR_START 0x3000000
-#endif
-
 #define __XSTR(x) #x
 #define __STR(x) __XSTR(x)
 static const char* __CROSSGEN_PATH = __STR(CROSSGEN_PATH);
+
+#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
+static const char* __SYSTEM_BASE_FILE = __STR(SYSTEM_BASE_FILE);
+#endif
+
 #undef __STR
 #undef __XSTR
 
@@ -141,12 +141,12 @@ static bool niExist(const std::string& path)
 
 #ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
 // Get next base address to be used for system ni image from file
-// SYSTEM_BASE_FILE should be checked for existance before calling this function
+// __SYSTEM_BASE_FILE should be checked for existance before calling this function
 static uintptr_t getNextBaseAddrFromFile()
 {
-       FILE *pFile = fopen(SYSTEM_BASE_FILE, "r");
+       FILE *pFile = fopen(__SYSTEM_BASE_FILE, "r");
        if (pFile == NULL) {
-               fprintf(stderr, "Failed to open " SYSTEM_BASE_FILE "\n");
+               fprintf(stderr, "Failed to open %s\n", __SYSTEM_BASE_FILE);
                return 0;
        }
 
@@ -166,7 +166,7 @@ static uintptr_t getNextBaseAddr()
 {
        uintptr_t baseAddr = 0;
 
-       if (!isFileExist(SYSTEM_BASE_FILE)) {
+       if (!isFileExist(__SYSTEM_BASE_FILE)) {
                // This is the starting address for all default base addresses
                baseAddr = DEFAULT_BASE_ADDR_START;
        } else {
@@ -196,9 +196,9 @@ static void updateBaseAddrFile(const std::string &dllPath, uintptr_t baseAddr)
        }
 
        // Write new entry to the file
-       FILE *pFile = fopen(SYSTEM_BASE_FILE, "a");
+       FILE *pFile = fopen(__SYSTEM_BASE_FILE, "a");
        if (pFile == NULL) {
-               fprintf(stderr, "Failed to open " SYSTEM_BASE_FILE "\n");
+               fprintf(stderr, "Failed to open %s\n", __SYSTEM_BASE_FILE);
                return;
        }
 
@@ -529,9 +529,9 @@ void removeNiPlatform()
        }
 
 #ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
-       if (isFileExist(SYSTEM_BASE_FILE)) {
-               if (remove(SYSTEM_BASE_FILE)) {
-                       fprintf(stderr, "Failed to remove " SYSTEM_BASE_FILE " file\n");
+       if (isFileExist(__SYSTEM_BASE_FILE)) {
+               if (remove(__SYSTEM_BASE_FILE)) {
+                       fprintf(stderr, "Failed to remove %s\n", __SYSTEM_BASE_FILE);
                }
        }
 #endif
index fa605df..84f7f62 100644 (file)
@@ -53,6 +53,9 @@ Requires(preun): /usr/bin/systemctl
 %define _install_mdplugin_dir /etc/package-manager/parserlib/metadata
 %define _native_lib_dir /usr/share/dotnet.tizen/lib
 %define _tac_dir /opt/usr/dotnet
+%define _system_base_addr_file /usr/share/dotnet.tizen/system.base.addr
+
+%define _default_base_addr_start 0x3000000
 
 ExcludeArch: aarch64
 
@@ -114,6 +117,8 @@ cmake \
        -DUSE_DEFAULT_BASE_ADDR="" \
 %endif
        -DUNIQUE_DEFAULT_BASE_ADDR_SUPPORT="" \
+       -DSYSTEM_BASE_FILE=%{_system_base_addr_file} \
+       -DDEFAULT_BASE_ADDR_START=%{_default_base_addr_start} \
        NativeLauncher
 
 make %{?jobs:-j%jobs} VERBOSE=1
@@ -136,6 +141,7 @@ install -m 0644 %{name}.conf %{buildroot}/etc/tmpfiles.d/%{name}.conf
 mkdir -p /opt/etc/skel/.dotnet
 chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet
 %{_bindir}/nitool --dll %{_runtime_dir}/System.Private.CoreLib.dll
+chsmack -a _ %{_system_base_addr_file}
 
 %files
 %manifest dotnet-launcher.manifest