Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trunk] n64sym: check objdump exit status #620

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tools/n64sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void symbol_add(const char *elf, uint32_t addr, bool is_func)
getline(&line_buf, &line_buf_size, addr2line_r);
}

void elf_find_callsites(const char *elf)
bool elf_find_callsites(const char *elf)
{
// Start objdump to parse the disassembly of the ELF file
char *cmd = NULL;
Expand All @@ -236,8 +236,13 @@ void elf_find_callsites(const char *elf)
}
}
free(line);
pclose(disasm);
free(cmd);
int status = pclose(disasm);
#ifdef __MINGW32__
return status == 0;
#else
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
#endif
}

void compute_function_offsets(void)
Expand Down Expand Up @@ -281,7 +286,10 @@ void process(const char *infn, const char *outfn)

// First, find all functions and call sites. We do this by disassembling
// the ELF file and grepping it.
elf_find_callsites(infn);
if (!elf_find_callsites(infn)) {
fprintf(stderr, "Error: objdump failed\n");
exit(1);
}
verbose("Found %d callsites\n", stbds_arrlen(symtable));

// Sort the symbole table by symbol length. We want longer symbols
Expand Down