-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_image
executable file
·61 lines (45 loc) · 1.92 KB
/
make_image
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
#!/bin/bash
# wheatfox 2024
# change to your hvisor source code directory, and use the dev-loongarch branch !
HVISOR_SRC_DIR=../hvisor
if [ ! -d ${HVISOR_SRC_DIR} ]; then
echo "Error: hvisor source code directory not found: ${HVISOR_SRC_DIR}"
echo "Please change the HVISOR_SRC_DIR variable in make_image script to your hvisor source code directory"
exit 1
fi
ARCH=loongarch64
# you can change the log level here which will be passed to hvisor makefile
# trace/debug/info/warn/error
HVISOR_LOG_LEVEL=info
HVISOR_ARGS="ARCH=${ARCH} LOG=${HVISOR_LOG_LEVEL}"
make -C ${HVISOR_SRC_DIR} ${HVISOR_ARGS}
YELLOW_START="\033[1;33m"
YELLOW_END="\033[0m"
GREEN_START="\033[1;32m"
GREEN_END="\033[0m"
BOLD_START="\033[1m"
BOLD_END="\033[0m"
make ARCH=${ARCH} clean
cd lib/gnu-efi && ./build.sh
cd ../..
CMD="make ARCH=${ARCH} V=1"
echo -e "${BOLD_START}${YELLOW_START}Building hvisor UEFI Boot Image, CMD=$CMD${YELLOW_END}${BOLD_END}"
$CMD
echo -e "${BOLD_START}${YELLOW_START}Building hvisor shared object built, now building hvisor UEFI Boot Image${YELLOW_END}${BOLD_END}"
OBJCOPY="${ARCH}-unknown-linux-gnu-objcopy"
READELF="${ARCH}-unknown-linux-gnu-readelf"
OBJDUMP="${ARCH}-unknown-linux-gnu-objdump"
TARGET_SO="main/built-in.o"
TARGET_EFI="hvisor.efi"
rm -f hvisor-uefi-img # this is not a valid file to use, just use built-in.o
CMD2="${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* \
-j .rela.* -j .rel* -j .rela* -j .reloc -O binary ${TARGET_SO} ${TARGET_EFI}"
echo -e "${BOLD_START}${YELLOW_START}Building hvisor UEFI Boot Image, CMD=$CMD2${YELLOW_END}${BOLD_END}"
$CMD2
$READELF -a main/built-in.o >main/built-in.map
$OBJDUMP -d main/built-in.o >main/built-in.dis
cp ${TARGET_EFI} BOOTLOONGARCH64.EFI
# print file info and size of BOOTLOONGARCH64.EFI
ls -lh BOOTLOONGARCH64.EFI
file BOOTLOONGARCH64.EFI
echo -e "${BOLD_START}${GREEN_START}Building hvisor UEFI Boot Image done${GREEN_END}${BOLD_END}"