stuff
This commit is contained in:
parent
ed360a9a0d
commit
39158cce51
9
Makefile
9
Makefile
@ -1,11 +1,12 @@
|
||||
DATA = $(word 1,$(wildcard ./data ../data))
|
||||
DATA := $(word 1,$(wildcard ./data ../data))
|
||||
EXTRA_DEPS := $(wildcard $(DATA)/*.h $(DATA)/*/*.h)
|
||||
override CFLAGS += -I$(DATA)
|
||||
include $(DATA)/Makefile.common
|
||||
|
||||
BINS := $(OUTDIR)/check_sanity $(OUTDIR)/make_kernel_patchfile $(OUTDIR)/apply_patchfile $(OUTDIR)/dump $(OUTDIR)/nm $(OUTDIR)/extract_syms $(OUTDIR)/unpack sandboxc-armv6.c sandboxc-armv7.c
|
||||
ifneq "$(GXX)" ""
|
||||
BINS += $(OUTDIR)/grapher
|
||||
endif
|
||||
#ifneq "$(GXX)" ""
|
||||
#BINS += $(OUTDIR)/grapher
|
||||
#endif
|
||||
|
||||
all: .data $(OUTDIR) $(BINS)
|
||||
|
||||
|
@ -51,7 +51,7 @@ int main(int argc, char **argv) {
|
||||
goto retry;
|
||||
}
|
||||
} else {
|
||||
printf("%s (0x%x)\n", name, addr);
|
||||
printf("%s (0x%llx)\n", name, (long long) addr);
|
||||
}
|
||||
|
||||
memcpy((char *) kernel.start + range_to_off_range((range_t) {&binary, addr, size}, MUST_FIND).start, stuff, size);
|
||||
|
49
dump.c
49
dump.c
@ -9,28 +9,43 @@ int main(int argc, char **argv) {
|
||||
if(argc < 2) goto usage;
|
||||
struct binary binary;
|
||||
b_init(&binary);
|
||||
b_load_macho(&binary, argv[1]);
|
||||
char **arg = &argv[2];
|
||||
while(*arg) {
|
||||
if(!strcmp(*arg, "-a")) {
|
||||
if(!arg[1] || !arg[2]) goto usage;
|
||||
dump((range_t) {&binary, parse_hex_uint32(arg[1]), parse_hex_uint32(arg[2])});
|
||||
arg += 3;
|
||||
} else if(!strcmp(*arg, "-A")) {
|
||||
if(!arg[1] || !arg[2]) goto usage;
|
||||
uint32_t start = parse_hex_uint32(arg[1]);
|
||||
dump((range_t) {&binary, start, parse_hex_uint32(arg[2]) - start});
|
||||
arg += 3;
|
||||
} else if(!strcmp(*arg, "-s")) {
|
||||
if(!arg[1]) goto usage;
|
||||
dump(b_macho_segrange(&binary, arg[1]));
|
||||
arg += 2;
|
||||
for(int pass = 1; pass <= 2; pass++) {
|
||||
for(char **arg = &argv[1]; *arg;) {
|
||||
if(!strcmp(*arg, "-a")) {
|
||||
if(!arg[1] || !arg[2]) goto usage;
|
||||
if(pass == 2) {
|
||||
dump((range_t) {&binary, parse_hex_uint32(arg[1]), parse_hex_uint32(arg[2])});
|
||||
}
|
||||
arg += 3;
|
||||
} else if(!strcmp(*arg, "-A")) {
|
||||
if(!arg[1] || !arg[2]) goto usage;
|
||||
if(pass == 2) {
|
||||
uint32_t start = parse_hex_uint32(arg[1]);
|
||||
dump((range_t) {&binary, start, parse_hex_uint32(arg[2]) - start});
|
||||
}
|
||||
arg += 3;
|
||||
} else if(!strcmp(*arg, "-s")) {
|
||||
if(!arg[1]) goto usage;
|
||||
if(pass == 2) {
|
||||
dump(b_macho_segrange(&binary, arg[1]));
|
||||
}
|
||||
arg += 2;
|
||||
} else if((*arg)[0] == '-') {
|
||||
goto usage;
|
||||
} else {
|
||||
if(pass == 1) {
|
||||
if(binary.valid) goto usage;
|
||||
b_load_macho(&binary, *arg);
|
||||
}
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
if(!binary.valid) goto usage;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
usage:
|
||||
fprintf(stderr, "Usage: dump_range binary [-a start len] [-A start end] [-s segname]\n");
|
||||
fprintf(stderr, "Usage: dump binary [-a start len] [-A start end] [-s segname]\n");
|
||||
return 1;
|
||||
}
|
||||
|
4
nm.c
4
nm.c
@ -37,13 +37,13 @@ int main(int argc, char **argv) {
|
||||
|
||||
|
||||
if(argv[optind + 1]) {
|
||||
printf("%8x\n", b_sym(&binary, argv[optind + 1], flags));
|
||||
printf("%8llx\n", (long long) b_sym(&binary, argv[optind + 1], flags));
|
||||
} else {
|
||||
struct data_sym *syms;
|
||||
uint32_t nsyms;
|
||||
b_copy_syms(&binary, &syms, &nsyms, flags);
|
||||
while(nsyms--) {
|
||||
printf("%8x %s\n", syms->address, syms->name);
|
||||
printf("%8llx %s\n", (long long) syms->address, syms->name);
|
||||
syms++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user