Compare commits

...

6 Commits

Author SHA1 Message Date
Techflash
43fec34868
Merge b2a57f4391 into 0fdf1cc386 2025-11-15 16:40:02 +00:00
JosJuice
0fdf1cc386
Merge pull request #14112 from Simonx22/android/remove-unused-bimap-class
Android: Remove unused BiMap class
2025-11-15 16:22:17 +01:00
JosJuice
999e13b3b3
Merge pull request #14109 from OatmealDome/analytics-deadlock
DolphinAnalytics: Only call ReloadConfig in config changed callback when analytics enabled value changes
2025-11-15 14:44:54 +01:00
techflashYT
b2a57f4391 Core/Boot: Fix ELF load address semantics
Tested with a binary that has VMA != (LMA | 0x80000000), unlike most
libogc binaries.  This is indeed a valid setup for ELFs, and one that is
generally expected to work properly.

Test code: https://github.com/Wii-Linux/NPLL/tree/reloc

In either case, you still need to set the PC in the debugger to get it
to boot properly, though that is a different issue that I will be fixing
in a future patch.
Without this patch, the code to be runtime-relocated ends up already
loaded at the desired final address, and then when the code tries to
relocate from what it thinks is the source address (where the code
should be, where the LMA is) to the destination address (the VMA, where
Dolphin mistakenly already put the code), it ends up overwriting the
code that it is about to execute with garbage, and then promptly
crashing.
After this patch is applied, the behavior now matches the GameCube with
Swiss (assuming a [recent patch](bb4a57186c)
is applied), and the Wii with the Homebrew Channel.
2025-11-13 06:20:21 -07:00
Simonx22
d1526157df Android: Remove unused BiMap class 2025-11-12 17:26:05 -05:00
OatmealDome
df5f351add
DolphinAnalytics: Only call ReloadConfig in config changed callback when analytics enabled value changes
Co-authored-by: Simonx22 <simon@oatmealdome.me>
2025-11-12 00:09:41 -05:00
4 changed files with 22 additions and 35 deletions

View File

@ -1,29 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.utils;
import java.util.HashMap;
import java.util.Map;
public class BiMap<K, V>
{
private Map<K, V> forward = new HashMap<>();
private Map<V, K> backward = new HashMap<>();
public synchronized void add(K key, V value)
{
forward.put(key, value);
backward.put(value, key);
}
public synchronized V getForward(K key)
{
return forward.get(key);
}
public synchronized K getBackward(V key)
{
return backward.get(key);
}
}

View File

@ -143,17 +143,23 @@ bool ElfReader::LoadIntoMemory(Core::System& system, bool only_in_mem1) const
{
Elf32_Phdr* p = segments + i;
INFO_LOG_FMT(BOOT, "Type: {} Vaddr: {:08x} Filesz: {} Memsz: {}", p->p_type, p->p_vaddr,
p->p_filesz, p->p_memsz);
INFO_LOG_FMT(BOOT, "Type: {} Vaddr: {:08x} Paddr: {:08x} Filesz: {} Memsz: {}", p->p_type,
p->p_vaddr, p->p_paddr, p->p_filesz, p->p_memsz);
if (p->p_type == PT_LOAD)
{
u32 writeAddr = p->p_vaddr;
// Check LMA (paddr) first - some are nonsense, so fall back to VMA (vaddr) if invalid
u32 writeAddr = p->p_paddr;
if (writeAddr)
writeAddr |= 0x80000000; // map to virtual address
else
writeAddr = p->p_vaddr; // LMA is empty, fall back to VMA
const u8* src = GetSegmentPtr(i);
u32 srcSize = p->p_filesz;
u32 dstSize = p->p_memsz;
if (only_in_mem1 && p->p_vaddr >= memory.GetRamSizeReal())
if (only_in_mem1 && writeAddr >= memory.GetRamSizeReal())
continue;
memory.CopyToEmu(writeAddr, src, srcSize);

View File

@ -57,10 +57,19 @@ void DolphinAnalytics::AndroidSetGetValFunc(std::function<std::string(std::strin
DolphinAnalytics::DolphinAnalytics()
{
m_last_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
ReloadConfig();
MakeBaseBuilder();
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { ReloadConfig(); });
m_config_changed_callback_id = Config::AddConfigChangedCallback([this] {
bool current_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
if (m_last_analytics_enabled != current_analytics_enabled)
{
m_last_analytics_enabled = current_analytics_enabled;
ReloadConfig();
}
});
}
DolphinAnalytics::~DolphinAnalytics()
@ -80,7 +89,7 @@ void DolphinAnalytics::ReloadConfig()
// Install the HTTP backend if analytics support is enabled.
std::unique_ptr<Common::AnalyticsReportingBackend> new_backend;
if (Config::Get(Config::MAIN_ANALYTICS_ENABLED))
if (m_last_analytics_enabled)
{
new_backend = std::make_unique<Common::HttpAnalyticsBackend>(ANALYTICS_ENDPOINT);
}

View File

@ -203,4 +203,5 @@ private:
std::mutex m_reporter_mutex;
Common::AnalyticsReporter m_reporter;
Config::ConfigChangedCallbackID m_config_changed_callback_id{};
bool m_last_analytics_enabled = false;
};