| 292 | } |
| 293 | |
| 294 | int main(int argc, char** argv) { |
| 295 | auto exit_failure = [] (const std::string& error_str) { |
| 296 | fmt::vprint(stderr, error_str, fmt::make_format_args()); |
| 297 | std::exit(EXIT_FAILURE); |
| 298 | }; |
| 299 | |
| 300 | bool dumping_context = false; |
| 301 | |
| 302 | if (argc < 2) { |
| 303 | fmt::print("Usage: {} <config file> [--dump-context]\n", argv[0]); |
| 304 | return EXIT_SUCCESS; |
| 305 | } |
| 306 | |
| 307 | const char* config_path = argv[1]; |
| 308 | |
| 309 | for (size_t i = 2; i < argc; i++) { |
| 310 | std::string_view cur_arg = argv[i]; |
| 311 | if (cur_arg == "--dump-context") { |
| 312 | dumping_context = true; |
| 313 | } |
| 314 | else { |
| 315 | fmt::print("Unknown argument \"{}\"\n", cur_arg); |
| 316 | return EXIT_FAILURE; |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | N64Recomp::Config config{ config_path }; |
| 321 | if (!config.good()) { |
| 322 | exit_failure(fmt::format("Failed to load config file: {}\n", config_path)); |
| 323 | } |
| 324 | |
| 325 | RabbitizerConfig_Cfg.pseudos.pseudoMove = false; |
| 326 | RabbitizerConfig_Cfg.pseudos.pseudoBeqz = false; |
| 327 | RabbitizerConfig_Cfg.pseudos.pseudoBnez = false; |
| 328 | RabbitizerConfig_Cfg.pseudos.pseudoNot = false; |
| 329 | RabbitizerConfig_Cfg.pseudos.pseudoBal = false; |
| 330 | |
| 331 | std::vector<std::string> relocatable_sections_ordered{}; |
| 332 | |
| 333 | if (!config.relocatable_sections_path.empty()) { |
| 334 | if (!read_list_file(config.relocatable_sections_path, relocatable_sections_ordered)) { |
| 335 | exit_failure(fmt::format("Failed to load the relocatable section list file: {}\n", (const char*)config.relocatable_sections_path.u8string().c_str())); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | std::unordered_set<std::string> relocatable_sections{}; |
| 340 | relocatable_sections.insert(relocatable_sections_ordered.begin(), relocatable_sections_ordered.end()); |
| 341 | |
| 342 | std::unordered_set<std::string> ignored_syms_set{}; |
| 343 | ignored_syms_set.insert(config.ignored_funcs.begin(), config.ignored_funcs.end()); |
| 344 | |
| 345 | N64Recomp::Context context{}; |
| 346 | |
| 347 | if (!config.elf_path.empty() && !config.symbols_file_path.empty()) { |
| 348 | exit_failure("Config file cannot provide both an elf and a symbols file\n"); |
| 349 | } |
| 350 | |
| 351 | // Build a context from the provided elf file. |
nothing calls this directly
no test coverage detected