diff --git a/compile.py b/compile.py index a6072ea..c750bd2 100644 --- a/compile.py +++ b/compile.py @@ -24,7 +24,7 @@ with open('c_files.txt') as file: if line == "gnu-efi/lib/x86_64/setjmp" or line == "gnu-efi/lib/x86_64/efi_stub": print(f'Assembling file {line}.s') - subprocess.run([f'{GCC_FOLDER}/bin/as.exe', '-64', '-I/inc/', '-g', '-o', f'{line}.o', f'{line}.s'], shell=True) + subprocess.run([f'{GCC_FOLDER}/bin/gcc.exe', '-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', '-Iinc/', '-Ignu-efi/inc', '-Ignu-efi/inc/x86_64', '-Ignu-efi/inc/protocol', '-Ignu-efi/lib', '-Og', '-g3', '-Wall', '-Wextra', '-Wdouble-promotion', '-Wpedantic', '-fmessage-length=0', '-c', '-MMD', '-MP', f'-Wa,-adghlmns={line}.out', f'-MT{line}.o', '-o', f'{line}.o', f'{line}.S'], shell=True) else: print(f'Compiling file {line}.c') subprocess.run([f'{GCC_FOLDER}/bin/gcc.exe', '-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', '-Iinc/', '-Ignu-efi/inc', '-Ignu-efi/inc/x86_64', '-Ignu-efi/inc/protocol', '-Ignu-efi/lib', '-Og', '-g3', '-Wall', '-Wextra', '-Wdouble-promotion', '-Wpedantic', '-fmessage-length=0', '-c', '-MMD', '-MP', f'-Wa,-adghlmns={line}.out', f'-MT{line}.o', '-o', f'{line}.o', f'{line}.c'], shell=True) @@ -38,8 +38,11 @@ with open('c_files.txt') as file: objectsfile.write(ofile + "\n") line = file.readline().strip() - -subprocess.run([f'{GCC_FOLDER}/bin/ld.exe', f'-T{LinkScript}', "-nostdlib", "--warn-common", "--no-undefined", "-shared", "--subsystem", '10', "-Bsymbolic", "--gc-sections", "-Map=output.map" , "-o Syncboot.efi", "@objects.list"]) -subprocess.run(['objcopy', '-j .text', '-j .sdata', '-j .data', '-j .dynamic', '-j .dynsym', '-j .rel', '-j .rela', '-j .rel.*', '-j .rel*', '-j .reloc', '--target=efi-app-x86_64', 'Syncboot.efi', 'image/efi/boot/BOOTX64.efi']) -subprocess.run(['objcopy', '--only-keep-debug', 'image/efi/boot/BOOTX64.efi', 'BOOTX64.debug']) -subprocess.run(['--add-gnu-debuglink=BOOTX64.debug', 'image/efi/boot/BOOTX64.efi']) \ No newline at end of file +print("Linking EFI.") +subprocess.run([f'{GCC_FOLDER}/bin/gcc.exe', "-nostdlib", "-Wl,--warn-common", "-Wl,--no-undefined", "-Wl,-dll", "-shared", "-Wl,--subsystem,10", "-e", "efi_main", "-Wl,-Map=output.map", "-o", "Syncboot.efi", "@objects.list"]) +print("Generating binary and debug symbols.") +subprocess.run([f'{GCC_FOLDER}/bin/objcopy.exe', '--only-keep-debug', 'Syncboot.efi', 'BOOTX64.debug']) +subprocess.run([f'{GCC_FOLDER}/bin/objcopy.exe', '--strip-debug', 'Syncboot.efi']) +subprocess.run([f'{GCC_FOLDER}/bin/objcopy.exe', '--add-gnu-debuglink=BOOTX64.debug', 'Syncboot.efi']) +print("Copying file to virtual hard disk") +os.system('copy Syncboot.efi image/efi/boot/BOOTX64.EFI')