88import argparse
99
1010ENTRY_SYM = "__start64"
11- GCC = "gcc"
12- OBJCOPY = "objcopy"
1311
1412def verbose (msg ):
1513 if args .verbose :
@@ -108,14 +106,14 @@ def build_elf(elf_file):
108106 # + We need pic to enforce that the linker adds no relocations
109107 # + UEFI can take interrupts on our stack, so no red zone
110108 # + UEFI API assumes 16-bit wchar_t
111- cmd = [GCC , "-shared" , "-Wall" , "-Werror" , "-I." ,
109+ cmd = [args . compiler , "-shared" , "-Wall" , "-Werror" , "-I." ,
112110 "-fno-stack-protector" , "-fpic" , "-mno-red-zone" , "-fshort-wchar" ,
113111 "-Wl,-nostdlib" , "-T" , ldscript , "-o" , "zefi.elf" , cfile ]
114112 verbose (" " .join (cmd ))
115113 subprocess .run (cmd , check = True )
116114
117115 # Extract the .data segment and append our extra blob
118- cmd = [OBJCOPY , "-O" , "binary" , "-j" , ".data" , "zefi.elf" , "data.dat" ]
116+ cmd = [args . objcopy , "-O" , "binary" , "-j" , ".data" , "zefi.elf" , "data.dat" ]
119117 verbose (" " .join (cmd ))
120118 subprocess .run (cmd , check = True )
121119
@@ -125,11 +123,11 @@ def build_elf(elf_file):
125123 df .close ()
126124
127125 # FIXME: this generates warnings about our unused trash section having to be moved to make room. Set its address far away...
128- subprocess .run ([OBJCOPY , "--update-section" , ".data=data.dat" ,
126+ subprocess .run ([args . objcopy , "--update-section" , ".data=data.dat" ,
129127 "zefi.elf" ], check = True )
130128
131129 # Convert it to a PE-COFF DLL.
132- cmd = [OBJCOPY , "--target=efi-app-x86_64" ,
130+ cmd = [args . objcopy ,
133131 "-j" , ".text" , "-j" , ".reloc" , "-j" , ".data" ,
134132 "zefi.elf" , "zephyr.efi" ]
135133 verbose (" " .join (cmd ))
@@ -143,6 +141,8 @@ def parse_args():
143141 description = __doc__ ,
144142 formatter_class = argparse .RawDescriptionHelpFormatter )
145143
144+ parser .add_argument ("-c" , "--compiler" , required = True , help = "Compiler to be used" )
145+ parser .add_argument ("-o" , "--objcopy" , required = True , help = "objcopy to be used" )
146146 parser .add_argument ("-f" , "--elf-file" , required = True , help = "Input file" )
147147 parser .add_argument ("-v" , "--verbose" , action = "store_true" , help = "Verbose output" )
148148
0 commit comments