This commit is contained in:
Anghelo Carvajal 2024-07-31 19:31:04 +00:00 committed by GitHub
commit 1199a86a9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View file

@ -732,7 +732,7 @@ bool read_symbols(RecompPort::Context& context, const ELFIO::elfio& elf_file, EL
continue; continue;
} }
if (section_index < context.sections.size()) { if (section_index < context.sections.size()) {
// Check if this symbol is the entrypoint // Check if this symbol is the entrypoint
if (has_entrypoint && value == entrypoint && type == ELFIO::STT_FUNC) { if (has_entrypoint && value == entrypoint && type == ELFIO::STT_FUNC) {
if (found_entrypoint_func) { if (found_entrypoint_func) {
@ -795,13 +795,18 @@ bool read_symbols(RecompPort::Context& context, const ELFIO::elfio& elf_file, EL
} }
} }
if (!ignored && type == ELFIO::STT_FUNC && num_instructions == 0 && bind != ELFIO::STB_WEAK) {
// TODO: functions ignored on the toml file do not silence this warning
fmt::print(stderr, "[WARN] Function '{}' has zero size.\n", name);
}
// Suffix local symbols to prevent name conflicts. // Suffix local symbols to prevent name conflicts.
if (bind == ELFIO::STB_LOCAL) { if (bind == ELFIO::STB_LOCAL) {
name = fmt::format("{}_{:08X}", name, rom_address); name = fmt::format("{}_{:08X}", name, rom_address);
} }
if (num_instructions > 0) { if (num_instructions > 0) {
context.section_functions[section_index].push_back(context.functions.size()); context.section_functions[section_index].push_back(context.functions.size());
recorded_symbol = true; recorded_symbol = true;
} }
context.functions_by_name[name] = context.functions.size(); context.functions_by_name[name] = context.functions.size();

View file

@ -247,7 +247,7 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
// FIXME: how to deal with static functions? // FIXME: how to deal with static functions?
if (context.functions_by_vram.find(branch_target) != context.functions_by_vram.end()) { if (context.functions_by_vram.find(branch_target) != context.functions_by_vram.end()) {
fmt::print(output_file, "{{\n "); fmt::print(output_file, "{{\n ");
fmt::print("Tail call in {} to 0x{:08X}\n", func.name, branch_target); fmt::print("[INFO] Tail call in {} to 0x{:08X}\n", func.name, branch_target);
print_func_call(branch_target, false, true); print_func_call(branch_target, false, true);
print_line(" return"); print_line(" return");
fmt::print(output_file, " }}\n"); fmt::print(output_file, " }}\n");
@ -612,7 +612,7 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
// ``` // ```
// FIXME: how to deal with static functions? // FIXME: how to deal with static functions?
else if (context.functions_by_vram.find(branch_target) != context.functions_by_vram.end()) { else if (context.functions_by_vram.find(branch_target) != context.functions_by_vram.end()) {
fmt::print("Tail call in {} to 0x{:08X}\n", func.name, branch_target); fmt::print("[INFO] Tail call in {} to 0x{:08X}\n", func.name, branch_target);
print_func_call(branch_target, false); print_func_call(branch_target, false);
print_line("return"); print_line("return");
} }
@ -667,13 +667,13 @@ bool process_instruction(const RecompPort::Context& context, const RecompPort::C
bool is_tail_call = instr_vram == func_vram_end - 2 * sizeof(func.words[0]); bool is_tail_call = instr_vram == func_vram_end - 2 * sizeof(func.words[0]);
if (is_tail_call) { if (is_tail_call) {
fmt::print("Indirect tail call in {}\n", func.name); fmt::print("[INFO] Indirect tail call in {}\n", func.name);
print_unconditional_branch("LOOKUP_FUNC({}{})(rdram, ctx)", ctx_gpr_prefix(rs), rs); print_unconditional_branch("LOOKUP_FUNC({}{})(rdram, ctx)", ctx_gpr_prefix(rs), rs);
print_line("return"); print_line("return");
break; break;
} }
fmt::print(stderr, "No jump table found for jr at 0x{:08X} and not tail call\n", instr_vram); fmt::print(stderr, "[WARN] No jump table found for jr at 0x{:08X} and not tail call\n", instr_vram);
} }
break; break;
case InstrId::cpu_syscall: case InstrId::cpu_syscall: