// Save base address of system ni image to file
static void updateBaseAddrFile(const std::string& absNIPath, uintptr_t baseAddr)
{
- uintptr_t niSize = getFileSize(absNIPath);
+ uintptr_t niSize = getSizeOfImage(absNIPath);
if (niSize == 0) {
_SERR("File %s doesn't exist", absNIPath.c_str());
return;
}
if (fstat(fd, &sb) == -1) {
+ close(fd);
return false;
}
close(fd);
return ret;
}
+
+unsigned int getSizeOfImage(std::string fileName)
+{
+ int fd;
+ struct stat sb;
+ if ((fd = open(fileName.c_str(), O_RDONLY)) == -1) {
+ _SERR("File Not Found: %s", fileName.c_str());
+ return 0;
+ }
+
+ if (fstat(fd, &sb) == -1) {
+ close(fd);
+ return 0;
+ }
+
+ void* pAddr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (pAddr == MAP_FAILED) {
+ _SERR("Fail to Map File: %s", fileName.c_str());
+ close(fd);
+ return 0;
+ }
+
+ IMAGE_NT_HEADERS* pNTHeaders = getNTHeaders(pAddr);
+ if (!pNTHeaders) {
+ _SERR("Invalid NT Header");
+ munmap(pAddr, sb.st_size);
+ close(fd);
+ return 0;
+ }
+
+ // typedef unsigned int ULONG;
+ unsigned int ret = pNTHeaders->OptionalHeader.SizeOfImage;
+
+ munmap(pAddr, sb.st_size);
+ close(fd);
+ return ret;
+}
%define _system_base_addr_file /opt/usr/dotnet.system.base.addr
%define _tizen_preload_dir /usr/share/dotnet.tizen/preload
-%define _default_base_addr_start 0x3000000
+%ifarch x86_64 aarch64
+%define _default_base_addr_start 0x6000000000
+%endif
+
+%ifarch %{arm}
+%define _default_base_addr_start 0x30000000
+%endif
%define _rw_update_scripts_dir /usr/share/upgrade/scripts
%define _rw_dotnet_update_script 715.dotnet_regen_app_ni.patch.sh