forked from kakaroto/PL3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (75 loc) · 2.15 KB
/
Makefile
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
B2HTARGET = $(CURDIR)/tools/bin2header
CFLAGS = -Wall -O3
CC = gcc
PPU_CC = ppu-gcc
PPU_OBJCOPY = ppu-objcopy
PPU_CFLAGS =
# This isn't enough, you must also add rules for the filename_fw with the -D define
SUPPORTED_FIRMWARES = 3.41
#3.41_kiosk 3.40 3.30 3.21 3.15 3.10 3.01 2.76
PAYLOADS = shellcode_egghunt.bin \
shellcode_panic.bin \
dump_lv2.bin
FW_PAYLOADS = \
default_payload.bin \
payload_dev.bin \
payload_no_unauth_syscall.bin \
payload_dump_elfs.bin
FIRMWARES_2=$(SUPPORTED_FIRMWARES:2.%=2_%)
FIRMWARES=$(FIRMWARES_2:3.%=3_%)
FW_PAYLOADS_EXT = $(foreach fw,$(FIRMWARES), \
$(foreach pl,$(FW_PAYLOADS),$(pl:%.bin=%_$(fw).bin)))
ALL_PAYLOADS = $(PAYLOADS) $(FW_PAYLOADS_EXT)
HEADERS = $(ALL_PAYLOADS:%.bin=%.h)
MAX_PAYLOAD_SIZE=3808
all: tools $(ALL_PAYLOADS) $(HEADERS) check_sizes
tools:
$(MAKE) -C tools
$(B2HTARGET): tools
@true
check_sizes: $(ALL_PAYLOADS)
@error=0; \
for f in $+; do \
size=`ls -l $$f | awk '{print $$5}'`; \
if [ $$size -gt $(MAX_PAYLOAD_SIZE) ]; then \
echo "File $$f has a size of $$size."; \
false; \
error=1; \
fi; \
done; \
if [ $$error -eq 1 ]; then \
echo ""; \
echo "The maximum allowed size for a payload is $(MAX_PAYLOAD_SIZE)"; \
exit 1; \
fi; \
true
$(ALL_PAYLOADS): *.h.S config.h
%_2_76.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_76 -c $< -o $@
%_3_01.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_01 -c $< -o $@
%_3_10.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_10 -c $< -o $@
%_3_15.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_15 -c $< -o $@
%_3_21.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_21 -c $< -o $@
%_3_30.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_30 -c $< -o $@
%_3_40.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_40 -c $< -o $@
%_3_41.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_41 -c $< -o $@
%_3_41_kiosk.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_41 -DKIOSK -c $< -o $@
%.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -c $< -o $@
%.bin : %.o
$(PPU_OBJCOPY) -O binary $< $@
%.h : %.bin $(B2HTARGET)
$(B2HTARGET) $< $@ $(*F)
# Target: clean project.
clean:
$(MAKE) -C tools/ clean
rm -f *~ *.bin $(ALL_PAYLOADS) $(HEADERS)
.PHONY: all clean tools check_sizes