From: Gleb Balykov Date: Tue, 9 Jul 2019 13:56:24 +0000 (+0300) Subject: Move defines to spec and set smack label on file with default base addresses X-Git-Tag: accepted/tizen/unified/20190718.075227~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4890542268b28f13b0ebb2ea1d67f38c5ae1d486;p=platform%2Fcore%2Fdotnet%2Flauncher.git Move defines to spec and set smack label on file with default base addresses --- diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 9773988..b5c2a38 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -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") diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index 79fa9f4..88fbb28 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -48,14 +48,14 @@ #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 diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index fa605df..84f7f62 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -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