mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2026-04-28 04:51:43 +00:00
Add option to control unpaired LO16 warnings
This commit is contained in:
parent
388c16c13f
commit
c28507de2a
3 changed files with 21 additions and 8 deletions
|
|
@ -68,6 +68,7 @@ namespace RecompPort {
|
|||
bool uses_mips3_float_mode;
|
||||
bool single_file_output;
|
||||
bool use_absolute_symbols;
|
||||
bool unpaired_lo16_warnings;
|
||||
std::filesystem::path elf_path;
|
||||
std::filesystem::path symbols_file_path;
|
||||
std::filesystem::path func_reference_syms_file_path;
|
||||
|
|
|
|||
|
|
@ -390,6 +390,7 @@ RecompPort::Config::Config(const char* path) {
|
|||
manual_functions = get_manual_funcs(array);
|
||||
}
|
||||
|
||||
// Output binary path when using an elf file input, includes patching reference symbol MIPS32 relocs (optional)
|
||||
std::optional<std::string> output_binary_path_opt = input_data["output_binary_path"].value<std::string>();
|
||||
if (output_binary_path_opt.has_value()) {
|
||||
output_binary_path = concat_if_not_empty(basedir, output_binary_path_opt.value());
|
||||
|
|
@ -398,6 +399,15 @@ RecompPort::Config::Config(const char* path) {
|
|||
output_binary_path = "";
|
||||
}
|
||||
|
||||
// Control whether the recompiler warns about unpaired LO16 relocs (optional, defaults to true)
|
||||
std::optional<bool> unpaired_lo16_warnings_opt = input_data["unpaired_lo16_warnings"].value<bool>();
|
||||
if (unpaired_lo16_warnings_opt.has_value()) {
|
||||
unpaired_lo16_warnings = unpaired_lo16_warnings_opt.value();
|
||||
}
|
||||
else {
|
||||
unpaired_lo16_warnings = true;
|
||||
}
|
||||
|
||||
// Patches section (optional)
|
||||
toml::node_view patches_data = config_data["patches"];
|
||||
if (patches_data.is_table()) {
|
||||
|
|
|
|||
18
src/main.cpp
18
src/main.cpp
|
|
@ -1183,17 +1183,19 @@ ELFIO::section* read_sections(RecompPort::Context& context, const RecompPort::Co
|
|||
}
|
||||
else {
|
||||
// Orphaned LO16 reloc warnings.
|
||||
if (prev_lo) {
|
||||
// Don't warn if multiple LO16 in a row reference the same symbol, as some linkers will use this behavior.
|
||||
if (prev_hi_symbol != rel_symbol) {
|
||||
fmt::print(stderr, "[WARN] LO16 reloc index {} in section {} referencing symbol {} with offset 0x{:08X} follows LO16 with different symbol\n",
|
||||
if (config.unpaired_lo16_warnings) {
|
||||
if (prev_lo) {
|
||||
// Don't warn if multiple LO16 in a row reference the same symbol, as some linkers will use this behavior.
|
||||
if (prev_hi_symbol != rel_symbol) {
|
||||
fmt::print(stderr, "[WARN] LO16 reloc index {} in section {} referencing symbol {} with offset 0x{:08X} follows LO16 with different symbol\n",
|
||||
i, section_out.name, reloc_out.symbol_index, reloc_out.address);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fmt::print(stderr, "[WARN] Unpaired LO16 reloc index {} in section {} referencing symbol {} with offset 0x{:08X}\n",
|
||||
i, section_out.name, reloc_out.symbol_index, reloc_out.address);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fmt::print(stderr, "[WARN] Unpaired LO16 reloc index {} in section {} referencing symbol {} with offset 0x{:08X}\n",
|
||||
i, section_out.name, reloc_out.symbol_index, reloc_out.address);
|
||||
}
|
||||
// Even though this is an orphaned LO16 reloc, the previous calculation for the addend still follows the MIPS System V ABI documentation:
|
||||
// "R_MIPS_LO16 entries without an R_MIPS_HI16 entry immediately preceding are orphaned and the previously defined
|
||||
// R_MIPS_HI16 is used for computing the addend."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue