この記事で関係するターゲット
linker.cmd ターゲット
[zephyr_base]/Makefile
linker.cmd: $(zephyr-deps) $(Q)$(CC) -x assembler-with-cpp -nostdinc -undef -E -P \ $(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) -I$(srctree)/include \ -I$(objtree)/include/generated $(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@
$(zephyr-deps)
TODO$(Q)
[zephyr_base]/Makefile
ifeq ("$(origin V)", "command line") KBUILD_VERBOSE = $(V) endif ifndef KBUILD_VERBOSE KBUILD_VERBOSE = 0 endif ifeq ($(KBUILD_VERBOSE),1) quiet = Q = else quiet=quiet_ Q = @ endif ... export quiet Q KBUILD_VERBOSEmake V=1 などとすると、環境変数 Q は"" となる(or 未定義?)。それ以外では、Q は @ となる。
$(Q)$(CC) が gcc となる場合、実行する gcc ... というコマンドが表示されるが、@gcc となる場合、コマンドは表示されない。
5.2 Recipe Echoing 参照。
$(CC)
前の記事 参照。$(LDFLAG_LINKERCMD)
未定義$(LD_TOOLCHAIN)
[zephyr_base]/Makefile
LD_TOOLCHAIN ?= -D__GCC_LINKER_CMD__LD_TOOLCHAIN が未定義の場合、-D__GCC_LINKER_CMD__ とする。
$(srctree)
[zephyr_base]/Makefile
ifeq ($(KBUILD_SRC),) # building in the source tree srctree := . else ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) # building in a subdirectory of the source tree srctree := .. else srctree := $(KBUILD_SRC) endif endif objtree := . (省略) export srctree objtree VPATHTODO 後で検討
KBUILD_SRC は、[zephyr_base] (sub-makeターゲット時にセットされる)。
srctree は [zephyr_base]となる。
objtree は . (カレントディレクトリ)となる。
$(objtree)
上記参照$(EXTRA_LINKER_CMD_OPT)
未定義$(KBUILD_LDS)
[zephyr_base]/Makefile
ifdef CONFIG_HAVE_CUSTOM_LINKER_SCRIPT KBUILD_LDS := $(subst $(DQUOTE),,$(CONFIG_CUSTOM_LINKER_SCRIPT)) else # Try a board specific linker file KBUILD_LDS := $(srctree)/boards/$(BOARD_NAME)/linker.ld # If not available, try an SoC specific linker file ifeq ($(wildcard $(KBUILD_LDS)),) KBUILD_LDS := $(srctree)/arch/$(ARCH)/soc/$(SOC_PATH)/linker.ld endif endif export LD_TOOLCHAIN KBUILD_LDSKBUILD_LDS は [zephyr_base]/arch/x86/soc/ia32/linker.ld -o linker.cmd となる。
BOARD_NAME は qemu_x86。
[zephyr_base]/Makefile
BOARD_NAME = $(subst $(DQUOTE),,$(CONFIG_BOARD))
[zephyr_base]/samples/hello_world/microkernel/outdir/.config
CONFIG_BOARD="qemu_x86"
SOC_PATH は ia32。
[zephyr_base]/Makefile
SOC_NAME = $(subst $(DQUOTE),,$(CONFIG_SOC)) SOC_SERIES = $(subst $(DQUOTE),,$(CONFIG_SOC_SERIES)) (省略) ifeq ($(SOC_SERIES),) SOC_PATH = $(SOC_NAME) else SOC_PATH = $(SOC_FAMILY)/$(SOC_SERIES) endif
[zephyr_base]/samples/hello_world/microkernel/outdir/.config
CONFIG_SOC="ia32"CONFIG_SOC_SERIES は未定義。
[zephyr_base]/samples/hello_world/microkernel/outdir/.config
# CONFIG_HAVE_CUSTOM_LINKER_SCRIPT is not set
$(Q)$(CC) -x assembler-with-cpp -nostdinc -undef -E -P $(LDFLAG_LINKERCMD) $(LD_TOOLCHAIN) -I$(srctree)/include -I$(objtree)/include/generated $(EXTRA_LINKER_CMD_OPT) $(KBUILD_LDS) -o $@
/Volumes/CrossToolNG/x-tools/i586-pc-elf/bin/i586-pc-elf-gcc -x assembler-with-cpp -nostdinc -undef -E -P \ -D__GCC_LINKER_CMD__ -I[zephyr_base]/include \ -I./include/generated [zephyr_base]/arch/x86/soc/ia32/linker.ld -o linker.cmd
-x assembler-with-cpp
3.2 Options Controlling the Kind of Output-x language Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next -x option. Possible values for language are: c c-header cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header objective-c-cpp-output objective-c++ objective-c++-header objective-c++-cpp-output assembler assembler-with-cpp ada f77 f77-cpp-input f95 f95-cpp-input go java
-nostdinc
2.3 Search PathYou can prevent GCC from searching any of the default directories with the -nostdinc option. This is useful when you are compiling an operating system kernel or some other program that does not use the standard C library facilities, or the standard C library itself. -I options are not ignored as described above when -nostdinc is in effect.
-undef
3.12 Options Controlling the Preprocessor-undef Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined.
-E
3.2 Options Controlling the Kind of Output-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files that don't require preprocessing are ignored.3.14 Options for Linking
-c -S -E If any of these options is used, then the linker is not run, and object file names should not be used as arguments.
-P
3.12 Options Controlling the Preprocessor-P Inhibit generation of linemarkers in the output from the preprocessor. This might be useful when running the preprocessor on something that is not C code, and will be sent to a program which might be confused by the linemarkers.
-D__GCC_LINKER_CMD__
3.12 Options Controlling the Preprocessor-D name Predefine name as a macro, with definition 1.
-I[zephyr_base]/include
3.15 Options for Directory Search-Idir Add the directory dir to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. However, you should not use this option to add directories that contain vendor-supplied system header files (use -isystem for that). If you use more than one -I option, the directories are scanned in left-to-right order; the standard system directories come after.
-I./include/generated
同上 see above[zephyr_base]/arch/x86/soc/ia32/linker.ld
プロプロセス元のファイル。(略) MEMORY { #ifdef CONFIG_XIP ROM (rx) : ORIGIN = PHYS_LOAD_ADDR, LENGTH = CONFIG_ROM_SIZE*1K RAM (wx) : ORIGIN = PHYS_RAM_ADDR, LENGTH = CONFIG_RAM_SIZE*1K #else /* !CONFIG_XIP */ RAM (wx) : ORIGIN = PHYS_LOAD_ADDR, LENGTH = CONFIG_RAM_SIZE*1K #endif /* CONFIG_XIP */ (略)
-o linker.cmd
linker.ld をプリプロセスした結果を出力するファイル。[zephyr_base]/samples/hello_world/microkernel/outdir に生成される。
(略) MEMORY { RAM (wx) : ORIGIN = 0x00100000, LENGTH = 192*1K (略)Invocation
-o file Write output to file. This is the same as specifying file as the second non-option argument to cpp. gcc has a different interpretation of a second non-option argument, so you must use -o to specify the output file.
コメント