Syncboot/build.sh

50 lines
2.6 KiB
Bash
Raw Normal View History

set +v
CurrentDir=$PWD
GCC_NAME=x86_64-w64-mingw32
EFI_FOLDER=gnu-efi
Linker="$EFI_FOLDER/gnuefi/elf_x86_64_efi.lds"
cd ./x64
rm objects.list
2019-07-25 21:07:36 +00:00
HeaderFiles="-I$CurrentDir/inc/ -I$CurrentDir/gnu-efi/inc -I$CurrentDir/gnu-efi/inc/x86_64 -I$CurrentDir/gnu-efi/inc/protocol -I$CurrentDir/gnu-efi/lib"
set -v
for f in $CurrentDir/src/*.c; do
2019-07-25 21:07:36 +00:00
echo "$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
"$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
done
set +v
set -v
while read f; do
2019-07-25 21:07:36 +00:00
echo "$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -MMD -MP -Wa,-adhln="$CurrentDir${f%.*}.out" -MT"$CurrentDir${f%.*}.o" -o "$CurrentDir${f%.*}.o" -c "$CurrentDir$f"
"$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -MMD -MP -Wa,-adhln="$CurrentDir${f%.*}.out" -MT"$CurrentDir${f%.*}.o" -o "$CurrentDir${f%.*}.o" -c "$CurrentDir$f"
done < $CurrentDir/c_files.txt
set +v
while read f; do
echo "${f%.*}.o" | tee -a objects.list
done < $CurrentDir/c_files.txt
for f in $CurrentDir/src/*.o; do
echo "$f" | tee -a objects.list
done
set -v
2019-07-25 21:07:36 +00:00
"ld" -T$Linker -nostdlib --warn-common --no-undefined -znocombreloc -shared -Bsymbolic -Map=output.map -o "program.so" @"objects.list"
set +v
rm image/efi/boot/BOOTx64.efi
objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .reloc --target=efi-app-x86_64 "program.so" "image/efi/boot/BOOTx64.efi"
2019-07-25 21:07:36 +00:00
objcopy --only-keep-debug image/efi/boot/BOOTx64.efi BOOTX64.debug
objcopy --add-gnu-debuglink=BOOTX64.debug image/efi/boot/BOOTx64.efi
read -n 1