-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·54 lines (47 loc) · 1.68 KB
/
build.sh
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
#!/bin/bash
set -e
C_FILES=(main lib file config)
for file in "${C_FILES[@]}"; do
gcc "$file.c" \
-c \
-fno-stack-protector \
-fpic \
-fshort-wchar \
-mno-red-zone \
-Wall -Wextra \
-Werror \
-I /usr/include/efi \
-I /usr/include/efi/x86_64 \
-DEFI_FUNCTION_WRAPPER \
-o "$file.o"
done
obj_files=$(for f in "${C_FILES[@]}"; do echo "$f.o"; done)
ld ${obj_files[*]} \
/usr/lib/crt0-efi-x86_64.o \
-nostdlib \
-znocombreloc \
-T /usr/lib/elf_x86_64_efi.lds \
-shared \
-Bsymbolic \
-L /usr/lib \
-l:libgnuefi.a \
-l:libefi.a \
-o main.so
objcopy -j .text \
-j .sdata \
-j .data \
-j .dynamic \
-j .dynsym \
-j .rel \
-j .rela \
-j .reloc \
--target=efi-app-x86_64 \
main.so \
main.efi
dd if=/dev/zero of=fat.img bs=1k count=102400
mformat -i fat.img -v test -F ::
mmd -i fat.img ::/EFI
mmd -i fat.img ::/EFI/BOOT
mcopy -i fat.img main.efi ::/EFI/BOOT/BOOTX64.EFI
mcopy -i fat.img config.conf ::/EFI/BOOT/config.conf
qemu-system-x86_64 -cpu qemu64 -bios /usr/share/ovmf/OVMF.fd -drive file=fat.img,if=ide,format=raw -net none