Skip to content

Commit 513b9f5

Browse files
yerabolunashif
authored andcommitted
zefi.py: Use cross compiler while building zephyr
Currently, zefi.py takes host GCC OBJCOPY as default. Fixing the script to use CMAKE_C_COMPILER and CMAKE_OBJCOPY. Fixes: #27047 Signed-off-by: Spoorthy Priya Yerabolu <[email protected]>
1 parent 8216e32 commit 513b9f5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

arch/x86/zefi/zefi.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import argparse
99

1010
ENTRY_SYM = "__start64"
11-
GCC = "gcc"
12-
OBJCOPY = "objcopy"
1311

1412
def 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

boards/x86/ehl_crb/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
if(CONFIG_BOARD_EHL_CRB)
33
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
44
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/arch/x86/zefi/zefi.py
5+
-c ${CMAKE_C_COMPILER}
6+
-o ${CMAKE_OBJCOPY}
57
-f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf
68
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
79
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}

boards/x86/up_squared/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
if(CONFIG_BOARD_UP_SQUARED)
33
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
44
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/arch/x86/zefi/zefi.py
5+
-c ${CMAKE_C_COMPILER}
6+
-o ${CMAKE_OBJCOPY}
57
-f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf
68
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
79
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}

0 commit comments

Comments
 (0)