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)
|
override CFLAGS += -I$(DATA)
|
||||||
include $(DATA)/Makefile.common
|
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
|
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)" ""
|
#ifneq "$(GXX)" ""
|
||||||
BINS += $(OUTDIR)/grapher
|
#BINS += $(OUTDIR)/grapher
|
||||||
endif
|
#endif
|
||||||
|
|
||||||
all: .data $(OUTDIR) $(BINS)
|
all: .data $(OUTDIR) $(BINS)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ int main(int argc, char **argv) {
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
memcpy((char *) kernel.start + range_to_off_range((range_t) {&binary, addr, size}, MUST_FIND).start, stuff, size);
|
||||||
|
25
dump.c
25
dump.c
@ -9,28 +9,43 @@ int main(int argc, char **argv) {
|
|||||||
if(argc < 2) goto usage;
|
if(argc < 2) goto usage;
|
||||||
struct binary binary;
|
struct binary binary;
|
||||||
b_init(&binary);
|
b_init(&binary);
|
||||||
b_load_macho(&binary, argv[1]);
|
for(int pass = 1; pass <= 2; pass++) {
|
||||||
char **arg = &argv[2];
|
for(char **arg = &argv[1]; *arg;) {
|
||||||
while(*arg) {
|
|
||||||
if(!strcmp(*arg, "-a")) {
|
if(!strcmp(*arg, "-a")) {
|
||||||
if(!arg[1] || !arg[2]) goto usage;
|
if(!arg[1] || !arg[2]) goto usage;
|
||||||
|
if(pass == 2) {
|
||||||
dump((range_t) {&binary, parse_hex_uint32(arg[1]), parse_hex_uint32(arg[2])});
|
dump((range_t) {&binary, parse_hex_uint32(arg[1]), parse_hex_uint32(arg[2])});
|
||||||
|
}
|
||||||
arg += 3;
|
arg += 3;
|
||||||
} else if(!strcmp(*arg, "-A")) {
|
} else if(!strcmp(*arg, "-A")) {
|
||||||
if(!arg[1] || !arg[2]) goto usage;
|
if(!arg[1] || !arg[2]) goto usage;
|
||||||
|
if(pass == 2) {
|
||||||
uint32_t start = parse_hex_uint32(arg[1]);
|
uint32_t start = parse_hex_uint32(arg[1]);
|
||||||
dump((range_t) {&binary, start, parse_hex_uint32(arg[2]) - start});
|
dump((range_t) {&binary, start, parse_hex_uint32(arg[2]) - start});
|
||||||
|
}
|
||||||
arg += 3;
|
arg += 3;
|
||||||
} else if(!strcmp(*arg, "-s")) {
|
} else if(!strcmp(*arg, "-s")) {
|
||||||
if(!arg[1]) goto usage;
|
if(!arg[1]) goto usage;
|
||||||
|
if(pass == 2) {
|
||||||
dump(b_macho_segrange(&binary, arg[1]));
|
dump(b_macho_segrange(&binary, arg[1]));
|
||||||
arg += 2;
|
|
||||||
}
|
}
|
||||||
|
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;
|
return 0;
|
||||||
|
|
||||||
usage:
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
4
nm.c
4
nm.c
@ -37,13 +37,13 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
|
|
||||||
if(argv[optind + 1]) {
|
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 {
|
} else {
|
||||||
struct data_sym *syms;
|
struct data_sym *syms;
|
||||||
uint32_t nsyms;
|
uint32_t nsyms;
|
||||||
b_copy_syms(&binary, &syms, &nsyms, flags);
|
b_copy_syms(&binary, &syms, &nsyms, flags);
|
||||||
while(nsyms--) {
|
while(nsyms--) {
|
||||||
printf("%8x %s\n", syms->address, syms->name);
|
printf("%8llx %s\n", (long long) syms->address, syms->name);
|
||||||
syms++;
|
syms++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user