Commits
- Increment build number to 68 and update version string to "v0.1.68 testing-alpha".
- Introduce UserDefaults persistence methods for loading and saving user data.
- Modify audio playback function to include gain parameter for effects.
- Implement logging optimizations to reduce I/O during loading.
- Add network availability check to improve game connectivity handling.
- Prevent multiple game sessions per launch to avoid issues with JIT regions and threads.
- Incremented build number to 60 and updated version string to "v0.1.60 testing-alpha".
- Added `compatAudioWarmup()` function to initialize the audio mixer before the game loop starts, preventing lazy initialization during rendering.
- Enhanced fault logging in `elf_loader.cpp` to provide detailed memory region information for faulting addresses, including type and permissions.
- Updated `runGameOnMainThread()` to call `compatAudioWarmup()` for early audio setup.
- Improved fault handling by logging additional context about the program counter (PC) and fault address (FAR) during unrecovered faults.
- Added audio handling capabilities through SDL2_mixer for music and sound effects.
- Implemented functions for playing, stopping, pausing, and resuming music and sound effects.
- Introduced asset directory management for audio files.
- Added volume control for music and sound effects.
- Implemented caching for sound effects to optimize loading.
- Updated build number and version to 0.1.55.
- Added backtrace logging for exit and abort calls to improve debugging.
- Implemented a virtual file descriptor for /dev/urandom to handle random number generation on Switch.
- Enhanced file I/O logging to capture stdout/stderr messages.
- Introduced screenshot functionality to capture game frames and UI states at specific moments.
- Added README documentation for automatic screenshot captures during gameplay.
- Bump build number to 53 and update version string to "v0.1.53 testing-alpha".
- Improve ELF loader with detailed crash logging, including function addresses.
- Add debug logging for JNI method calls, specifically for "debugStringOnAndroid".
- Enhance shim table to log termination calls with caller addresses.
- Introduce a starfield background with animated elements in the main application.
- Refactor rendering functions to improve visual layout and responsiveness.
- Update footer and header rendering to include dynamic content based on APK count.
- Incremented build number to 50 and updated version string to "testing-alpha-50".
- Added a new function to log unrecovered faults in the ELF loader, capturing relevant context before process termination.
- Modified the exception handler to call the new logging function for better fault diagnostics.
- Updated the shim table to log game-initiated exits and aborts, improving visibility into process terminations.
- Enhanced the game loop to ensure recovery logging occurs during the entire iteration, including event polling and rendering.
- Adjusted color definitions in the main application for improved aesthetics, aligning with the app icon theme.
- Added a new color for the horizon accent line and updated various UI elements to enhance visual consistency.
- Updated BUILD_NUMBER to 47 and BUILD_VERSION to "testing-alpha-47" in build_number.h.
- Added a fake Android TLS block in loader.cpp to ensure valid memory access for thread-local state in homebrew applications.
- Implemented androidTlsInstall function to set up the fake TLS block before any game code execution, preventing faults when accessing Bionic's thread-local state.
- Incremented build number from 43 to 44 in build_number.txt and build_number.h.
- Added detailed instruction logging in elf_loader.cpp and loader.cpp to aid in diagnosing faults during execution.
- Enhanced logging around fault occurrences to include surrounding instructions, improving the ability to trace issues.
- Incremented BUILD_NUMBER to 43 and updated BUILD_VERSION to "testing-alpha-43".
- Modified symbol resolution logic in `elf_loader.cpp` to prioritize shim table entries over loaded libraries, ensuring game-specific implementations take precedence.
- Enhanced `pt_getspecific` in `shim_table.cpp` to return a per-key scratch buffer for uninitialized TLS slots, allowing code that skips null-checks to operate without faulting. This change improves compatibility with certain game libraries.
- Incremented BUILD_NUMBER to 42 and updated BUILD_VERSION to "testing-alpha-42".
- Introduced elfNearestSym function to find the nearest symbol at or before a given ELF virtual address, enhancing symbol resolution capabilities.
- Integrated elfNearestSym into error logging for JNI_OnLoad and Cocos2d-x functions to provide more informative fault messages, including the nearest symbol and offset.
- Added logging for pthread key creation and retrieval to improve debugging of thread-local storage operations.
- Incremented build number to 41 and updated version string to "testing-alpha-41".
- Added `game_so` pointer to `LaunchResult` struct for tracking loaded ELF.
- Introduced `runGameOnMainThread` function to handle game execution on the main thread with SDL2's EGL context.
- Enhanced error handling in ELF constructors by including Fault Address Register (FAR) in logs.
- Modified `launchApk` to store paths for ANativeActivity and facilitate game execution.
- Updated JNI handling to ensure proper initialization and error logging.
- Refactored game loop to support SDL event polling and buffer swapping.
- Incremented BUILD_NUMBER to 39 and updated BUILD_VERSION to "testing-alpha-39".
- Added checks in LoadedSo::findSym to reject garbage entries in the symbol table based on allocation size.
- Implemented probing of the first 5 JMPREL GOT entries in elfLoad to confirm values are correctly reaching data_va_base, enhancing debugging and logging capabilities.
- Incremented build number and version in build_number.txt and build_number.h.
- Modified elf_loader.cpp to improve memory management during ELF loading:
- Introduced a separate write alias for code memory to ensure proper data writing before mapping.
- Enhanced logging for better diagnostics during the loading process.
- Updated memory reservation logic to handle adjacent executable and writable memory regions more effectively.
- Ensured proper cleanup of resources in case of failures during memory mapping.
- Incremented BUILD_NUMBER to 37 and updated BUILD_VERSION to "testing-alpha-37" in build_number.h.
- Added new AndroidHorizonNX.elf file.
- Created new AndroidHorizonNX.nacp file with initial metadata.
- Introduced new AndroidHorizonNX.nro file.
- Added AndroidHorizonNX.lst and AndroidHorizonNX.map files to the build directory.
- Changed APK and log directory paths from "sdmc:/BareDroidNX" to "sdmc:/AndroidHorizonNX" in loader.cpp and main.cpp.
- Updated log messages and window titles to reflect the new branding.
- Added new image file for AndroidHorizonNX.
- Incremented BUILD_NUMBER to 35 and updated BUILD_VERSION to "testing-alpha-35".
- Added D-cache flush calls in elfLoad function to ensure data integrity before kernel ownership.
- Implemented I-cache invalidation to guarantee fresh instruction fetching from physical memory when using split map or JIT.
- Incremented BUILD_NUMBER to 33 and updated BUILD_VERSION to "testing-alpha-33".
- Changed the avatar URL in avatar.cpp to point to a new GitHub account.
- Added compatLogFlush function to immediately flush log messages to disk.
- Integrated compatLogFlush calls in elf_loader and loader to ensure timely logging during ELF loading and constructor execution.
- Improved logging messages for clarity and detail.
- Initialized and exited socket in main application flow for better resource management.
- Incremented build number to 32 and updated version string to "testing-alpha-32".
- Disabled SSL peer verification in avatar.cpp for compatibility with the Switch platform.
- Improved logging in loader.cpp by adding a detail ring buffer for live log output, allowing for real-time display without file I/O.
- Refactored log handling in main.cpp to utilize the in-memory detail log instead of reading from disk, ensuring immediate access to the latest log entries.
- Incremented build number to 30 and updated version string to "testing-alpha-30".
- Removed unnecessary nifm initialization in avatarThreadFunc to avoid permission issues on homebrew.
- Added progress logging during ELF loading to improve user feedback.
- Increased UI log buffer size to 20 entries and width to 128 characters for better logging.
- Enhanced progress screen to include a live tail of compat_log.txt, providing real-time feedback during APK launches.
- Refactored launch process to run in a background thread, improving responsiveness of the UI.
- Updated various UI elements to reflect the new application name "Android Horizon" and improved overall aesthetics.
Progress screen now actually scrolls during loading:
applyRela now calls cb() every 512 entries (triggering a showProgress re-render), so processing libgame.so's ~49,500 RELA entries will show live "RELA N/49533" updates every ~512 steps instead of sitting frozen.
Loop detection:
showProgress tracks when g_ui_head last advanced. After 45 seconds with zero progress, a red banner appears: "No progress for 45s — may be stuck in a loop. Good time to share compat_log.txt with the test environment."
Avatar:
Removed the broken nifmGetInternetConnectionStatus check (which requires NifmServiceType_System but we were passing User, causing the check to always fail and skip the fetch). Now tries curl immediately — curl handles offline gracefully with its own timeout.
- Incremented BUILD_NUMBER to 23 and updated BUILD_VERSION to "testing-alpha-23".
- Changed avatar URL to use GitHub's direct avatar link, eliminating reliance on a third-party API.
- Enhanced ELF loader's relocation logging to provide throttled updates during long operations, improving user feedback.
- Refactored memory mapping logic in the ELF loader to clarify the handling of code and data memory permissions.
- Introduced avatar.h and avatar.cpp to manage fetching the user's GitHub avatar.
- Implemented a worker thread that fetches the avatar every 5 minutes while the app is running.
- Added caching mechanism to store the avatar locally on the SD card.
- Provided functions to start and stop the avatar fetching process, as well as to poll for new images.
- Updated build number and version to 17.
- Refactored ELF loader to support split-VA CodeMemory mapping for improved memory management.
- Allocated separate memory regions for code and data segments, allowing for more efficient access and execution.
- Enhanced logging for memory allocation and mapping operations.
- Adjusted JIT handling to accommodate new memory management strategy, ensuring proper transitions between writable and executable states.
- Improved error handling and fallback mechanisms for memory allocation failures.
- Incremented BUILD_NUMBER to 15 and updated BUILD_VERSION to "testing-alpha-15".
- Improved JIT handling in elf_loader.cpp to check the distance between data and code JIT regions, falling back to single-JIT if necessary.
- Enhanced logging in loader.cpp to include the program counter (PC) in crash recovery logs for better debugging.
- Incremented BUILD_NUMBER to 13 and updated BUILD_VERSION to "testing-alpha-13".
refactor: enhance LoadedSo structure for data segment handling
- Added `data_alloc` pointer to `LoadedSo` structure to manage data segment JIT allocation.
- Updated `data_vaddr` to store the page-aligned base address of the data segment.
fix: improve symbol resolution for data segment
- Modified `findSym` function to return the correct address for symbols in the data segment.
- Implemented `patchAdrpToDataJit` function to redirect ADRP instructions to the new data segment.
refactor: separate code and data JIT allocations
- Allocated separate JIT regions for code and data segments to optimize memory usage.
- Updated memory allocation logic to handle both code and data segments correctly.
chore: enhance logging for JIT memory operations
- Improved logging for JIT memory allocation and transitions to provide better debugging information.
- Incremented build number to 12 and updated build version to "testing-alpha-12".
- Improved logging in loader.cpp to reduce duplicate log messages by collapsing consecutive identical lines into a single entry with a count.
- Added a logFlushDedup function to handle the flushing of logs when duplicates are detected.
- Ensured log flushing occurs before closing the log file in various error handling paths.
- Incremented BUILD_NUMBER to 11 and updated BUILD_VERSION to "testing-alpha-11".
- Improved the JIT memory permission logic in elf_loader.cpp to handle code and data page transitions more effectively.
- Added checks to set memory permissions for code pages to Rx while leaving data pages as Rw, allowing for better memory management and avoiding unnecessary transitions.
- Implemented a fallback mechanism to promote the entire region to executable if the initial transition fails.
- Incremented BUILD_NUMBER to 9 and updated BUILD_VERSION to "testing-alpha-9".
- Removed the patchAdrpDataRefs function which was responsible for redirecting ADRP instructions in the ELF loader.
- Implemented a new approach to downgrade data-segment pages in exec_alloc from Rx to Rw, allowing game code to write to global variables without requiring ADRP patching.
- Enhanced logging for memory permission changes during JIT execution.
- Incremented BUILD_NUMBER to 7 and updated BUILD_VERSION to "testing-alpha-7".
- Added a new member `write_alloc` to the `LoadedSo` struct in loader.h for RW twin allocation.
- Implemented `patchAdrpDataRefs` function in elf_loader.cpp to redirect ADRP instructions from the exec side to the write side of the data segment.
- Modified `elfLoad` function to find the first writable segment and store its virtual address in `data_vaddr`.
- Updated the `LoadedSo` initialization to include the new `data_vaddr` member.
- Enhanced logging in loader.cpp to include the exception syndrome register (esr) during fault handling.
- Incremented BUILD_NUMBER to 6 and updated BUILD_VERSION to "testing-alpha-6".
- Removed JIT write-fault emulation code from elf_loader.cpp, simplifying exception handling.
- Added support for Cocos2d-x in loader.cpp, allowing direct Java_ calls for initialization and rendering.
- Implemented error handling for Cocos2d-x native methods with logging for success and faults.
- Incremented BUILD_NUMBER to 5 and updated BUILD_VERSION to "testing-alpha-5".
- Added a new function `inJitRegion` to check if a given address falls within JIT emulation regions.
- Enhanced the exception handler to handle BadSVC faults when the program counter is within a JIT region, allowing for smoother execution by faking success and advancing the program counter.
- Improved logging in the `elfRunCtors` function to include the program counter in fault messages for better debugging.
- Updated build number and version to 4.
- Implemented a mechanism to emulate write-faults for JIT regions, allowing writes to read-execute memory without crashing.
- Introduced a new structure, JitEmuRegion, to track regions of memory for emulation.
- Modified the exception handler to intercept write-permission faults and redirect writes to a writable address.
- Removed logic for consecutive write-permission fault tracking, simplifying the handling of initialization functions.
- Added logging for JIT emulation regions during memory allocation.
- Incremented BUILD_NUMBER to 3 and updated BUILD_VERSION to "testing-alpha-3".
- Improved exception handling in elf_loader.cpp by capturing the ESR on faults.
- Added logic to track consecutive write-permission faults and bail early to prevent flooding the exception handler.
- Removed unused data segment collection logic that was previously intended for setting memory permissions.
- Introduced build_number.h to define BUILD_NUMBER and BUILD_VERSION.
- Updated main.cpp to display the build version in the header.
- Added build_number.txt to track the current build number.
- Modified main.d to include build_number.h in the build process.
- Added detailed logging for hardware faults in the ELF loader to capture program counter, fault address, and general-purpose registers before recovery.
- Implemented scanning for Java_ native methods in the loaded shared object, logging the found methods for better diagnostics of JNI-only games.
- Updated error messages to clarify when a pure-JNI game is detected, providing guidance on checking the log for entry points.
- Improved overall structure and readability of the logging process during the APK launch sequence.
- Introduced an `installed` flag in `ApkInfo` to track if an APK has been extracted.
- Added `apkIsInstalled` function to check for the presence of an `.installed` marker.
- Implemented `apkInstall` function to handle APK extraction and marker creation.
- Modified `launchApk` to skip extraction if the APK is already installed.
- Updated UI to display an "INSTALLED" badge for installed APKs.
- Enhanced main application logic to handle reinstallation and launching of cached APKs.
- Updated elfRunCtors to accept a callback for progress updates and integrated UI logging for constructor execution.
- Implemented shared crash recovery mechanisms across loader and shim table components to prevent process termination on faults.
- Added UI logging for various stages of APK extraction, library loading, and JNI setup to improve user feedback during initialization.
- Introduced a rolling log display and progress bar in the main application to visually indicate the current launch stage.
- Refactored JNI method stubs to include logging for method calls, aiding in debugging and performance tracking.
- Override the weak __libnx_exception_handler to handle hardware faults during game constructors.
- Ensure that longjmp is called to recover from crashes instead of terminating the process.
- Capture the error description from the ThreadExceptionDump and re-raise as fatal if not in a constructor.
This commit introduces the handling of the DT_INIT dynamic tag in the ELF loader. The following changes were made:
- Added definitions for DT_INIT and DT_FINI in `loader.h`.
- Updated the `LoadedSo` structure to include a pointer for the init function (`init_fn`), which will be called before the DT_INIT_ARRAY functions.
- Modified the `elfRunCtors` function to execute the init function if it is defined, ensuring it runs before any constructors in the DT_INIT_ARRAY.
- Enhanced the `elfLoad` function to retrieve the address of the init function from the dynamic section and store it in the `LoadedSo` structure.
These changes align the behavior of the ELF loader with the expected initialization order, similar to the Android linker.
In the elfRunCtors function, the logging of constructor functions has been enhanced to dump the first 32 instructions instead of just 4. This change aims to provide more context for identifying the first data access during execution, which can aid in debugging crashes related to JIT compilation. The log format has been updated to reflect this change, ensuring that developers have better visibility into the initialization process of loaded shared objects.
This change enhances the logging in the elfRunCtors function by dumping the first four instructions of the constructor function being executed. This will help in verifying the JIT copy and identifying the type of crash if one occurs. The previous logging only indicated the execution of the constructor without providing insight into the code being executed.
- Introduced a stub_open function to log every call to open, including the path, flags, and file descriptor on success or failure.
- Enhanced the pt_once function to log when the function is called and when it returns, aiding in tracing execution flow.
- Added logging for unknown sysconf calls to improve debugging capabilities.
- Skip constructors for the "applovin" library in elfRunCtors to avoid crashes on Switch due to its crash reporting mechanisms.
- Introduce a wrapper for fopen in shim_table to log failed file open attempts, aiding in debugging path requests made by game code.
- Updated `shim_table.d` to include additional headers for networking and polling.
- Modified `shim_table.cpp` to implement new stubs for various POSIX functions including signal handling, process management, filesystem operations, and network operations.
- Introduced new entries in the shim table for functions like `dladdr`, `sigaltstack`, `fork`, `execve`, `accept`, and others to ensure compatibility with missing implementations.
- Added a new `compat_log.txt` file to log compatibility issues, which is currently too large to diff.
- Introduced a new field `strsz` in the `LoadedSo` structure to store the size of the string table (DT_STRSZ).
- Updated the `findSym` method to include a bounds check against `strsz` to prevent dereferencing invalid memory when accessing symbol names.
- Modified the `elfLoad` function to initialize the `strsz` field during the loading of ELF files.
- Enhanced logging to include the `strsz` value for better debugging and tracking of symbol loading.
- Increment build number to 68 and update version string to "v0.1.68 testing-alpha".
- Introduce UserDefaults persistence methods for loading and saving user data.
- Modify audio playback function to include gain parameter for effects.
- Implement logging optimizations to reduce I/O during loading.
- Add network availability check to improve game connectivity handling.
- Prevent multiple game sessions per launch to avoid issues with JIT regions and threads.
- Incremented build number to 60 and updated version string to "v0.1.60 testing-alpha".
- Added `compatAudioWarmup()` function to initialize the audio mixer before the game loop starts, preventing lazy initialization during rendering.
- Enhanced fault logging in `elf_loader.cpp` to provide detailed memory region information for faulting addresses, including type and permissions.
- Updated `runGameOnMainThread()` to call `compatAudioWarmup()` for early audio setup.
- Improved fault handling by logging additional context about the program counter (PC) and fault address (FAR) during unrecovered faults.
- Added audio handling capabilities through SDL2_mixer for music and sound effects.
- Implemented functions for playing, stopping, pausing, and resuming music and sound effects.
- Introduced asset directory management for audio files.
- Added volume control for music and sound effects.
- Implemented caching for sound effects to optimize loading.
- Updated build number and version to 0.1.55.
- Added backtrace logging for exit and abort calls to improve debugging.
- Implemented a virtual file descriptor for /dev/urandom to handle random number generation on Switch.
- Enhanced file I/O logging to capture stdout/stderr messages.
- Introduced screenshot functionality to capture game frames and UI states at specific moments.
- Added README documentation for automatic screenshot captures during gameplay.
- Bump build number to 53 and update version string to "v0.1.53 testing-alpha".
- Improve ELF loader with detailed crash logging, including function addresses.
- Add debug logging for JNI method calls, specifically for "debugStringOnAndroid".
- Enhance shim table to log termination calls with caller addresses.
- Introduce a starfield background with animated elements in the main application.
- Refactor rendering functions to improve visual layout and responsiveness.
- Update footer and header rendering to include dynamic content based on APK count.
- Incremented build number to 50 and updated version string to "testing-alpha-50".
- Added a new function to log unrecovered faults in the ELF loader, capturing relevant context before process termination.
- Modified the exception handler to call the new logging function for better fault diagnostics.
- Updated the shim table to log game-initiated exits and aborts, improving visibility into process terminations.
- Enhanced the game loop to ensure recovery logging occurs during the entire iteration, including event polling and rendering.
- Adjusted color definitions in the main application for improved aesthetics, aligning with the app icon theme.
- Added a new color for the horizon accent line and updated various UI elements to enhance visual consistency.
- Updated BUILD_NUMBER to 47 and BUILD_VERSION to "testing-alpha-47" in build_number.h.
- Added a fake Android TLS block in loader.cpp to ensure valid memory access for thread-local state in homebrew applications.
- Implemented androidTlsInstall function to set up the fake TLS block before any game code execution, preventing faults when accessing Bionic's thread-local state.
- Incremented build number from 43 to 44 in build_number.txt and build_number.h.
- Added detailed instruction logging in elf_loader.cpp and loader.cpp to aid in diagnosing faults during execution.
- Enhanced logging around fault occurrences to include surrounding instructions, improving the ability to trace issues.
- Incremented BUILD_NUMBER to 43 and updated BUILD_VERSION to "testing-alpha-43".
- Modified symbol resolution logic in `elf_loader.cpp` to prioritize shim table entries over loaded libraries, ensuring game-specific implementations take precedence.
- Enhanced `pt_getspecific` in `shim_table.cpp` to return a per-key scratch buffer for uninitialized TLS slots, allowing code that skips null-checks to operate without faulting. This change improves compatibility with certain game libraries.
- Incremented BUILD_NUMBER to 42 and updated BUILD_VERSION to "testing-alpha-42".
- Introduced elfNearestSym function to find the nearest symbol at or before a given ELF virtual address, enhancing symbol resolution capabilities.
- Integrated elfNearestSym into error logging for JNI_OnLoad and Cocos2d-x functions to provide more informative fault messages, including the nearest symbol and offset.
- Added logging for pthread key creation and retrieval to improve debugging of thread-local storage operations.
- Incremented build number to 41 and updated version string to "testing-alpha-41".
- Added `game_so` pointer to `LaunchResult` struct for tracking loaded ELF.
- Introduced `runGameOnMainThread` function to handle game execution on the main thread with SDL2's EGL context.
- Enhanced error handling in ELF constructors by including Fault Address Register (FAR) in logs.
- Modified `launchApk` to store paths for ANativeActivity and facilitate game execution.
- Updated JNI handling to ensure proper initialization and error logging.
- Refactored game loop to support SDL event polling and buffer swapping.
- Incremented BUILD_NUMBER to 39 and updated BUILD_VERSION to "testing-alpha-39".
- Added checks in LoadedSo::findSym to reject garbage entries in the symbol table based on allocation size.
- Implemented probing of the first 5 JMPREL GOT entries in elfLoad to confirm values are correctly reaching data_va_base, enhancing debugging and logging capabilities.
- Incremented build number and version in build_number.txt and build_number.h.
- Modified elf_loader.cpp to improve memory management during ELF loading:
- Introduced a separate write alias for code memory to ensure proper data writing before mapping.
- Enhanced logging for better diagnostics during the loading process.
- Updated memory reservation logic to handle adjacent executable and writable memory regions more effectively.
- Ensured proper cleanup of resources in case of failures during memory mapping.
- Incremented BUILD_NUMBER to 37 and updated BUILD_VERSION to "testing-alpha-37" in build_number.h.
- Added new AndroidHorizonNX.elf file.
- Created new AndroidHorizonNX.nacp file with initial metadata.
- Introduced new AndroidHorizonNX.nro file.
- Added AndroidHorizonNX.lst and AndroidHorizonNX.map files to the build directory.
- Incremented BUILD_NUMBER to 35 and updated BUILD_VERSION to "testing-alpha-35".
- Added D-cache flush calls in elfLoad function to ensure data integrity before kernel ownership.
- Implemented I-cache invalidation to guarantee fresh instruction fetching from physical memory when using split map or JIT.
- Incremented BUILD_NUMBER to 33 and updated BUILD_VERSION to "testing-alpha-33".
- Changed the avatar URL in avatar.cpp to point to a new GitHub account.
- Added compatLogFlush function to immediately flush log messages to disk.
- Integrated compatLogFlush calls in elf_loader and loader to ensure timely logging during ELF loading and constructor execution.
- Improved logging messages for clarity and detail.
- Initialized and exited socket in main application flow for better resource management.
- Incremented build number to 32 and updated version string to "testing-alpha-32".
- Disabled SSL peer verification in avatar.cpp for compatibility with the Switch platform.
- Improved logging in loader.cpp by adding a detail ring buffer for live log output, allowing for real-time display without file I/O.
- Refactored log handling in main.cpp to utilize the in-memory detail log instead of reading from disk, ensuring immediate access to the latest log entries.
- Incremented build number to 30 and updated version string to "testing-alpha-30".
- Removed unnecessary nifm initialization in avatarThreadFunc to avoid permission issues on homebrew.
- Added progress logging during ELF loading to improve user feedback.
- Increased UI log buffer size to 20 entries and width to 128 characters for better logging.
- Enhanced progress screen to include a live tail of compat_log.txt, providing real-time feedback during APK launches.
- Refactored launch process to run in a background thread, improving responsiveness of the UI.
- Updated various UI elements to reflect the new application name "Android Horizon" and improved overall aesthetics.
Progress screen now actually scrolls during loading:
applyRela now calls cb() every 512 entries (triggering a showProgress re-render), so processing libgame.so's ~49,500 RELA entries will show live "RELA N/49533" updates every ~512 steps instead of sitting frozen.
Loop detection:
showProgress tracks when g_ui_head last advanced. After 45 seconds with zero progress, a red banner appears: "No progress for 45s — may be stuck in a loop. Good time to share compat_log.txt with the test environment."
Avatar:
Removed the broken nifmGetInternetConnectionStatus check (which requires NifmServiceType_System but we were passing User, causing the check to always fail and skip the fetch). Now tries curl immediately — curl handles offline gracefully with its own timeout.
- Incremented BUILD_NUMBER to 23 and updated BUILD_VERSION to "testing-alpha-23".
- Changed avatar URL to use GitHub's direct avatar link, eliminating reliance on a third-party API.
- Enhanced ELF loader's relocation logging to provide throttled updates during long operations, improving user feedback.
- Refactored memory mapping logic in the ELF loader to clarify the handling of code and data memory permissions.
- Introduced avatar.h and avatar.cpp to manage fetching the user's GitHub avatar.
- Implemented a worker thread that fetches the avatar every 5 minutes while the app is running.
- Added caching mechanism to store the avatar locally on the SD card.
- Provided functions to start and stop the avatar fetching process, as well as to poll for new images.
- Updated build number and version to 17.
- Refactored ELF loader to support split-VA CodeMemory mapping for improved memory management.
- Allocated separate memory regions for code and data segments, allowing for more efficient access and execution.
- Enhanced logging for memory allocation and mapping operations.
- Adjusted JIT handling to accommodate new memory management strategy, ensuring proper transitions between writable and executable states.
- Improved error handling and fallback mechanisms for memory allocation failures.
- Incremented BUILD_NUMBER to 15 and updated BUILD_VERSION to "testing-alpha-15".
- Improved JIT handling in elf_loader.cpp to check the distance between data and code JIT regions, falling back to single-JIT if necessary.
- Enhanced logging in loader.cpp to include the program counter (PC) in crash recovery logs for better debugging.
- Incremented BUILD_NUMBER to 13 and updated BUILD_VERSION to "testing-alpha-13".
refactor: enhance LoadedSo structure for data segment handling
- Added `data_alloc` pointer to `LoadedSo` structure to manage data segment JIT allocation.
- Updated `data_vaddr` to store the page-aligned base address of the data segment.
fix: improve symbol resolution for data segment
- Modified `findSym` function to return the correct address for symbols in the data segment.
- Implemented `patchAdrpToDataJit` function to redirect ADRP instructions to the new data segment.
refactor: separate code and data JIT allocations
- Allocated separate JIT regions for code and data segments to optimize memory usage.
- Updated memory allocation logic to handle both code and data segments correctly.
chore: enhance logging for JIT memory operations
- Improved logging for JIT memory allocation and transitions to provide better debugging information.
- Incremented build number to 12 and updated build version to "testing-alpha-12".
- Improved logging in loader.cpp to reduce duplicate log messages by collapsing consecutive identical lines into a single entry with a count.
- Added a logFlushDedup function to handle the flushing of logs when duplicates are detected.
- Ensured log flushing occurs before closing the log file in various error handling paths.
- Incremented BUILD_NUMBER to 11 and updated BUILD_VERSION to "testing-alpha-11".
- Improved the JIT memory permission logic in elf_loader.cpp to handle code and data page transitions more effectively.
- Added checks to set memory permissions for code pages to Rx while leaving data pages as Rw, allowing for better memory management and avoiding unnecessary transitions.
- Implemented a fallback mechanism to promote the entire region to executable if the initial transition fails.
- Incremented BUILD_NUMBER to 9 and updated BUILD_VERSION to "testing-alpha-9".
- Removed the patchAdrpDataRefs function which was responsible for redirecting ADRP instructions in the ELF loader.
- Implemented a new approach to downgrade data-segment pages in exec_alloc from Rx to Rw, allowing game code to write to global variables without requiring ADRP patching.
- Enhanced logging for memory permission changes during JIT execution.
- Incremented BUILD_NUMBER to 7 and updated BUILD_VERSION to "testing-alpha-7".
- Added a new member `write_alloc` to the `LoadedSo` struct in loader.h for RW twin allocation.
- Implemented `patchAdrpDataRefs` function in elf_loader.cpp to redirect ADRP instructions from the exec side to the write side of the data segment.
- Modified `elfLoad` function to find the first writable segment and store its virtual address in `data_vaddr`.
- Updated the `LoadedSo` initialization to include the new `data_vaddr` member.
- Enhanced logging in loader.cpp to include the exception syndrome register (esr) during fault handling.
- Incremented BUILD_NUMBER to 6 and updated BUILD_VERSION to "testing-alpha-6".
- Removed JIT write-fault emulation code from elf_loader.cpp, simplifying exception handling.
- Added support for Cocos2d-x in loader.cpp, allowing direct Java_ calls for initialization and rendering.
- Implemented error handling for Cocos2d-x native methods with logging for success and faults.
- Incremented BUILD_NUMBER to 5 and updated BUILD_VERSION to "testing-alpha-5".
- Added a new function `inJitRegion` to check if a given address falls within JIT emulation regions.
- Enhanced the exception handler to handle BadSVC faults when the program counter is within a JIT region, allowing for smoother execution by faking success and advancing the program counter.
- Improved logging in the `elfRunCtors` function to include the program counter in fault messages for better debugging.
- Updated build number and version to 4.
- Implemented a mechanism to emulate write-faults for JIT regions, allowing writes to read-execute memory without crashing.
- Introduced a new structure, JitEmuRegion, to track regions of memory for emulation.
- Modified the exception handler to intercept write-permission faults and redirect writes to a writable address.
- Removed logic for consecutive write-permission fault tracking, simplifying the handling of initialization functions.
- Added logging for JIT emulation regions during memory allocation.
- Incremented BUILD_NUMBER to 3 and updated BUILD_VERSION to "testing-alpha-3".
- Improved exception handling in elf_loader.cpp by capturing the ESR on faults.
- Added logic to track consecutive write-permission faults and bail early to prevent flooding the exception handler.
- Removed unused data segment collection logic that was previously intended for setting memory permissions.
- Added detailed logging for hardware faults in the ELF loader to capture program counter, fault address, and general-purpose registers before recovery.
- Implemented scanning for Java_ native methods in the loaded shared object, logging the found methods for better diagnostics of JNI-only games.
- Updated error messages to clarify when a pure-JNI game is detected, providing guidance on checking the log for entry points.
- Improved overall structure and readability of the logging process during the APK launch sequence.
- Introduced an `installed` flag in `ApkInfo` to track if an APK has been extracted.
- Added `apkIsInstalled` function to check for the presence of an `.installed` marker.
- Implemented `apkInstall` function to handle APK extraction and marker creation.
- Modified `launchApk` to skip extraction if the APK is already installed.
- Updated UI to display an "INSTALLED" badge for installed APKs.
- Enhanced main application logic to handle reinstallation and launching of cached APKs.
- Updated elfRunCtors to accept a callback for progress updates and integrated UI logging for constructor execution.
- Implemented shared crash recovery mechanisms across loader and shim table components to prevent process termination on faults.
- Added UI logging for various stages of APK extraction, library loading, and JNI setup to improve user feedback during initialization.
- Introduced a rolling log display and progress bar in the main application to visually indicate the current launch stage.
- Refactored JNI method stubs to include logging for method calls, aiding in debugging and performance tracking.
This commit introduces the handling of the DT_INIT dynamic tag in the ELF loader. The following changes were made:
- Added definitions for DT_INIT and DT_FINI in `loader.h`.
- Updated the `LoadedSo` structure to include a pointer for the init function (`init_fn`), which will be called before the DT_INIT_ARRAY functions.
- Modified the `elfRunCtors` function to execute the init function if it is defined, ensuring it runs before any constructors in the DT_INIT_ARRAY.
- Enhanced the `elfLoad` function to retrieve the address of the init function from the dynamic section and store it in the `LoadedSo` structure.
These changes align the behavior of the ELF loader with the expected initialization order, similar to the Android linker.
In the elfRunCtors function, the logging of constructor functions has been enhanced to dump the first 32 instructions instead of just 4. This change aims to provide more context for identifying the first data access during execution, which can aid in debugging crashes related to JIT compilation. The log format has been updated to reflect this change, ensuring that developers have better visibility into the initialization process of loaded shared objects.
This change enhances the logging in the elfRunCtors function by dumping the first four instructions of the constructor function being executed. This will help in verifying the JIT copy and identifying the type of crash if one occurs. The previous logging only indicated the execution of the constructor without providing insight into the code being executed.
- Introduced a stub_open function to log every call to open, including the path, flags, and file descriptor on success or failure.
- Enhanced the pt_once function to log when the function is called and when it returns, aiding in tracing execution flow.
- Added logging for unknown sysconf calls to improve debugging capabilities.
- Updated `shim_table.d` to include additional headers for networking and polling.
- Modified `shim_table.cpp` to implement new stubs for various POSIX functions including signal handling, process management, filesystem operations, and network operations.
- Introduced new entries in the shim table for functions like `dladdr`, `sigaltstack`, `fork`, `execve`, `accept`, and others to ensure compatibility with missing implementations.
- Added a new `compat_log.txt` file to log compatibility issues, which is currently too large to diff.
- Introduced a new field `strsz` in the `LoadedSo` structure to store the size of the string table (DT_STRSZ).
- Updated the `findSym` method to include a bounds check against `strsz` to prevent dereferencing invalid memory when accessing symbol names.
- Modified the `elfLoad` function to initialize the `strsz` field during the loading of ELF files.
- Enhanced logging to include the `strsz` value for better debugging and tracking of symbol loading.