diff --git a/arch/x86/zefi/zefi.py b/arch/x86/zefi/zefi.py index 9ab07c975a4..1e95958bff2 100755 --- a/arch/x86/zefi/zefi.py +++ b/arch/x86/zefi/zefi.py @@ -13,7 +13,7 @@ def verbose(msg): if args.verbose: print(msg) -def build_elf(elf_file, include_dir): +def build_elf(elf_file, include_dirs): base_dir = os.path.dirname(os.path.abspath(__file__)) cfile = os.path.join(base_dir, "zefi.c") @@ -106,9 +106,12 @@ def build_elf(elf_file, include_dir): # + We need pic to enforce that the linker adds no relocations # + UEFI can take interrupts on our stack, so no red zone # + UEFI API assumes 16-bit wchar_t - cmd = [args.compiler, "-shared", "-Wall", "-Werror", "-I.", - "-I", include_dir, "-fno-stack-protector", "-fpic", "-mno-red-zone", - "-fshort-wchar", "-Wl,-nostdlib", "-T", ldscript, "-o", "zefi.elf", cfile] + includes = [] + for include_dir in include_dirs: + includes.extend(["-I", include_dir]) + cmd = ([args.compiler, "-shared", "-Wall", "-Werror", "-I."] + includes + + ["-fno-stack-protector", "-fpic", "-mno-red-zone", "-fshort-wchar", + "-Wl,-nostdlib", "-T", ldscript, "-o", "zefi.elf", cfile]) verbose(" ".join(cmd)) subprocess.run(cmd, check = True) @@ -145,12 +148,13 @@ def parse_args(): parser.add_argument("-o", "--objcopy", required=True, help="objcopy to be used") parser.add_argument("-f", "--elf-file", required=True, help="Input file") parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output") - parser.add_argument("-i", "--include", required=True,help="Zephyr base include directory") + parser.add_argument("-i", "--includes", required=True, nargs="+", + help="Zephyr base include directories") return parser.parse_args() if __name__ == "__main__": args = parse_args() - verbose(f"Working on {args.elf_file} with {args.include}...") - build_elf(args.elf_file, args.include) + verbose(f"Working on {args.elf_file} with {args.includes}...") + build_elf(args.elf_file, args.includes) diff --git a/boards/x86/ehl_crb/CMakeLists.txt b/boards/x86/ehl_crb/CMakeLists.txt index 9bef6803cfd..cdf8c9e097b 100644 --- a/boards/x86/ehl_crb/CMakeLists.txt +++ b/boards/x86/ehl_crb/CMakeLists.txt @@ -5,8 +5,7 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands -c ${CMAKE_C_COMPILER} -o ${CMAKE_OBJCOPY} -i ${ZEPHYR_BASE}/include - $<$:-i> - $<$:${ZEPHYR_BASE}/include/zephyr> + $<$:${ZEPHYR_BASE}/include/zephyr> -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf $<$:--verbose> WORKING_DIRECTORY ${PROJECT_BINARY_DIR} diff --git a/boards/x86/qemu_x86/CMakeLists.txt b/boards/x86/qemu_x86/CMakeLists.txt index d731fcfe8c1..8d227f8b267 100644 --- a/boards/x86/qemu_x86/CMakeLists.txt +++ b/boards/x86/qemu_x86/CMakeLists.txt @@ -3,8 +3,7 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/arch/x86/zefi/zefi.py -c ${CMAKE_C_COMPILER} -i ${ZEPHYR_BASE}/include - $<$:-i> - $<$:${ZEPHYR_BASE}/include/zephyr> + $<$:${ZEPHYR_BASE}/include/zephyr> -o ${CMAKE_OBJCOPY} -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf $<$:--verbose> diff --git a/boards/x86/up_squared/CMakeLists.txt b/boards/x86/up_squared/CMakeLists.txt index e3b5827b381..b867282d606 100644 --- a/boards/x86/up_squared/CMakeLists.txt +++ b/boards/x86/up_squared/CMakeLists.txt @@ -5,8 +5,7 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands -c ${CMAKE_C_COMPILER} -o ${CMAKE_OBJCOPY} -i ${ZEPHYR_BASE}/include - $<$:-i> - $<$:${ZEPHYR_BASE}/include/zephyr> + $<$:${ZEPHYR_BASE}/include/zephyr> -f ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.elf $<$:--verbose> WORKING_DIRECTORY ${PROJECT_BINARY_DIR}