-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildaa64.sh
executable file
·52 lines (44 loc) · 1.04 KB
/
buildaa64.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
#!/bin/bash
set -xeo pipefail
[ ! -d "${POSIX_UEFI_PATH}" ] && echo "POSIX_UEFI_PATH not set" && exit 1
CFLAGS=(
-target arm64-unknown-windows
-ffreestanding
-fshort-wchar
-mno-red-zone
-Ofast
-Wall
-I/usr/include/efi
-I/usr/include/efi/protocol
"-I${POSIX_UEFI_PATH}/uefi"
-Wframe-larger-than=8192
)
LDFLAGS=(
-target arm64-unknown-windows
-nostdlib
'-Wl,-entry:uefi_init'
'-Wl,-subsystem:efi_application'
-fuse-ld=lld-link
'-Wl,-DEBUG'
)
build_efi()
{
target="$1"
shift
sources="$*"
objs=()
for x in $sources
do
clang "${CFLAGS[@]}" -g -c -o "${x%.*}.o" "$x"
objs+=("${x%.*}.o")
done
clang "${LDFLAGS[@]}" -v -o "${target}.efi" \
"${objs[@]}" \
"${POSIX_UEFI_PATH}/uefi/crt_aarch64.o" \
"${POSIX_UEFI_PATH}/uefi/stdio.o" \
"${POSIX_UEFI_PATH}/uefi/stdlib.o" \
"${POSIX_UEFI_PATH}/uefi/string.o" \
"${POSIX_UEFI_PATH}/uefi/time.o"
}
build_efi tablesfix tablesfix.c
build_efi readnor readnor.c