Skip internal symbols when dumping context (#116)

This commit is contained in:
Wiseguy 2025-01-02 20:50:46 -05:00 committed by GitHub
parent fc696046da
commit 6dafc108f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -165,27 +165,30 @@ bool read_symbols(N64Recomp::Context& context, const ELFIO::elfio& elf_file, ELF
// The symbol wasn't detected as a function, so add it to the data symbols if the context is being dumped. // The symbol wasn't detected as a function, so add it to the data symbols if the context is being dumped.
if (!recorded_symbol && dumping_context && !name.empty()) { if (!recorded_symbol && dumping_context && !name.empty()) {
uint32_t vram = static_cast<uint32_t>(value); // Skip internal symbols.
if (ELF_ST_VISIBILITY(other) != ELFIO::STV_INTERNAL) {
uint32_t vram = static_cast<uint32_t>(value);
// Place this symbol in the absolute symbol list if it's in the absolute section. // Place this symbol in the absolute symbol list if it's in the absolute section.
uint16_t target_section_index = section_index; uint16_t target_section_index = section_index;
if (section_index == ELFIO::SHN_ABS) { if (section_index == ELFIO::SHN_ABS) {
target_section_index = N64Recomp::SectionAbsolute; target_section_index = N64Recomp::SectionAbsolute;
} }
else if (section_index >= context.sections.size()) { else if (section_index >= context.sections.size()) {
fmt::print("Symbol \"{}\" not in a valid section ({})\n", name, section_index); fmt::print("Symbol \"{}\" not in a valid section ({})\n", name, section_index);
} }
// Move this symbol into the corresponding non-bss section if it's in a bss section. // Move this symbol into the corresponding non-bss section if it's in a bss section.
auto find_bss_it = bss_section_to_target_section.find(target_section_index); auto find_bss_it = bss_section_to_target_section.find(target_section_index);
if (find_bss_it != bss_section_to_target_section.end()) { if (find_bss_it != bss_section_to_target_section.end()) {
target_section_index = find_bss_it->second; target_section_index = find_bss_it->second;
} }
data_syms[target_section_index].emplace_back( data_syms[target_section_index].emplace_back(
vram, vram,
std::move(name) std::move(name)
); );
}
} }
} }