-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
135 lines (101 loc) · 3.17 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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.85 2.76 2.70 2.60 2.53 2.43
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 \
payload_trace_syscalls.bin \
payload_trace_hypercalls.bin \
payload_trace_all_sc_calls.bin \
payload_trace_vuart.bin
STANDALONE_FIRMWARES = 3.55
STANDALONE_PAYLOADS = \
default_payload.bin \
payload_no_unauth_syscall.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)))
ST_FIRMWARES=$(STANDALONE_FIRMWARES:3.%=3_%)
STANDALONE_PAYLOADS_EXT = $(foreach fw,$(ST_FIRMWARES), \
$(foreach pl,$(STANDALONE_PAYLOADS),$(pl:%.bin=%_$(fw).bin)))
SIZE_LIMITED_PAYLOADS = $(PAYLOADS) $(FW_PAYLOADS_EXT)
ALL_PAYLOADS = $(SIZE_LIMITED_PAYLOADS) $(STANDALONE_PAYLOADS_EXT)
HEADERS = $(ALL_PAYLOADS:%.bin=%.h)
MAX_PAYLOAD_SIZE=4064
all: tools $(ALL_PAYLOADS) $(HEADERS) check_sizes
echo "PAYLOADS: $(ALL_PAYLOADS)"
echo "ST_PAYLOADS: $(STANDALONE_PAYLOADS_EXT)"
echo "HEADERS: $(HEADERS)"
tools:
$(MAKE) -C tools
$(B2HTARGET): tools
@true
check_sizes: $(SIZE_LIMITED_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_43.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_43 -c $< -o $@
%_2_53.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_53 -c $< -o $@
%_2_60.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_60 -c $< -o $@
%_2_70.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_70 -c $< -o $@
%_2_76.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_76 -c $< -o $@
%_2_85.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_2_85 -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 $@
%_3_55.o : %.S
$(PPU_CC) $(PPU_CFLAGS) -DFIRMWARE_3_55 -DSTANDALONE -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