-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisasm.c
30 lines (24 loc) · 835 Bytes
/
disasm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "disasm.h"
#include "log.h"
#include "util.h"
#include <stdlib.h>
void objdump_debug_disasm(const char *filename, const char *output) {
// static const char COMMAND[] = "objdump --macho --no-show-raw-insn -d ";
// macho mode causes some instructions to show wrongly (half instructions)
static const char COMMAND[] = "objdump --no-show-raw-insn -d ";
char *command;
if (output) {
command = nonnull_malloc(sizeof COMMAND + strlen(filename) + strlen(" > ") + strlen(output) + 1);
strcpy(command, COMMAND);
strcat(command, filename);
strcat(command, " > ");
strcat(command, output);
} else {
command = nonnull_malloc(sizeof COMMAND + strlen(filename) + 1);
strcpy(command, COMMAND);
strcat(command, filename);
}
if (system(command)) {
warn("`debug_disasm` failed");
}
}