This commit is contained in:
comex 2011-05-02 15:12:05 -04:00
commit f2b86d1f60
3 changed files with 21 additions and 3 deletions

View File

@ -2,16 +2,17 @@ DATA = $(word 1,$(wildcard ./data ../data))
CFLAGS += -I$(DATA)
include $(DATA)/Makefile.common
BINS := $(OUTDIR)/check_sanity $(OUTDIR)/make_kernel_patchfile $(OUTDIR)/apply_patchfile sandboxc.c
BINS := $(OUTDIR)/check_sanity $(OUTDIR)/make_kernel_patchfile $(OUTDIR)/apply_patchfile $(OUTDIR)/dump_range sandboxc.c
all: .data $(OUTDIR) $(BINS)
.data:
make -C $(DATA)
$(OUTDIR):
mkdir $(OUTDIR)
sandbox.o: sandbox.S
$(SDK_GCC) -c -o $@ $<
$(SDK_GCC) -arch armv6 -c -o $@ $<
sandboxc.c: sandbox.o
xxd -i sandbox.o > sandboxc.c
@ -21,6 +22,8 @@ $(OUTDIR)/apply_patchfile: $(OUTDIR)/apply_patchfile.o $(DATA)/$(OUTDIR)/libdata
$(GCC) -o $@ $^
$(OUTDIR)/make_kernel_patchfile: $(OUTDIR)/make_kernel_patchfile.o $(OUTDIR)/sandboxc.o $(DATA)/$(OUTDIR)/libdata.a
$(GCC) -o $@ $^
$(OUTDIR)/dump_range: $(OUTDIR)/dump_range.o $(DATA)/$(OUTDIR)/libdata.a
$(GCC) -o $@ $^
clean: .clean
rm -f sandbox.o sandboxc.c

View File

@ -52,7 +52,7 @@ int main(int argc, char **argv) {
goto retry;
}
} else {
printf("%s\n", name);
printf("%s (0x%x)\n", name, addr);
}
memcpy((char *) kernel.start + range_to_off_range((range_t) {&binary, addr, size}).start, stuff, size);

15
dump_range.c Normal file
View File

@ -0,0 +1,15 @@
#include <data/common.h>
#include <data/binary.h>
int main(int argc, char **argv) {
if(argc != 4) {
fprintf(stderr, "Usage: dump_range binary start len\n");
return 1;
}
struct binary binary;
b_init(&binary);
b_load_macho(&binary, argv[1], false);
prange_t pr = rangeconv((range_t) {&binary, parse_hex_uint32(argv[2]), parse_hex_uint32(argv[3])});
write(1, pr.start, pr.size);
return 0;
}