mirror of
				https://github.com/N64Recomp/N64Recomp.git
				synced 2025-10-30 08:02:11 +00:00 
			
		
		
		
	Skip internal symbols when dumping context (#116)
This commit is contained in:
		
							parent
							
								
									fc696046da
								
							
						
					
					
						commit
						6dafc108f3
					
				
					 1 changed files with 21 additions and 18 deletions
				
			
		
							
								
								
									
										39
									
								
								src/elf.cpp
									
										
									
									
									
								
							
							
						
						
									
										39
									
								
								src/elf.cpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -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.
 | 
			
		||||
        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.
 | 
			
		||||
            uint16_t target_section_index = section_index;
 | 
			
		||||
            if (section_index == ELFIO::SHN_ABS) {
 | 
			
		||||
                target_section_index = N64Recomp::SectionAbsolute;
 | 
			
		||||
            }
 | 
			
		||||
            else if (section_index >= context.sections.size()) {
 | 
			
		||||
                fmt::print("Symbol \"{}\" not in a valid section ({})\n", name, section_index);
 | 
			
		||||
            }
 | 
			
		||||
                // Place this symbol in the absolute symbol list if it's in the absolute section.
 | 
			
		||||
                uint16_t target_section_index = section_index;
 | 
			
		||||
                if (section_index == ELFIO::SHN_ABS) {
 | 
			
		||||
                    target_section_index = N64Recomp::SectionAbsolute;
 | 
			
		||||
                }
 | 
			
		||||
                else if (section_index >= context.sections.size()) {
 | 
			
		||||
                    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.
 | 
			
		||||
            auto find_bss_it = bss_section_to_target_section.find(target_section_index);
 | 
			
		||||
            if (find_bss_it != bss_section_to_target_section.end()) {
 | 
			
		||||
                target_section_index = find_bss_it->second;
 | 
			
		||||
            }
 | 
			
		||||
                // 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);
 | 
			
		||||
                if (find_bss_it != bss_section_to_target_section.end()) {
 | 
			
		||||
                    target_section_index = find_bss_it->second;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            data_syms[target_section_index].emplace_back(
 | 
			
		||||
                vram,
 | 
			
		||||
                std::move(name)
 | 
			
		||||
            );
 | 
			
		||||
                data_syms[target_section_index].emplace_back(
 | 
			
		||||
                    vram,
 | 
			
		||||
                    std::move(name)
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue