#
# (C) Copyright 2000-2008
# Wolfgang Denk, DENX Software Engineering, [email protected].
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundatio; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
VERSION = 1
PATCHLEVEL = 3
SUBLEVEL = 4
EXTRAVERSION =
# 這裏U_BOOT_VERSION = 1.3.4
U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
VERSION_FILE = $(obj)include/version_autogenerated.h
# 打印機器硬件名。
# 將“i.86”(.表示一個任意字符)轉換爲“i386”;
# 將“sun4u”轉換爲“sparc64”;
# 將“arm.*”(.*表示零個或多個字符任意)轉換爲“arm”;
# 將“sa110”轉換爲“arm”;
# 將“powerpc”轉換爲“ppc”;
# 將“ppc64”轉換爲“ppc”;
# 將“macppc”轉換爲“ppc”;
# 筆者的電腦是“x86_64”,不符合替換規則,不替換。
HOSTARCH := $(shell uname -m | \
sed -e s/i.86/i386/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ \
-e s/sa110/arm/ \
-e s/powerpc/ppc/ \
-e s/ppc64/ppc/ \
-e s/macppc/ppc/)
# 打印內核名。
# 將所有大寫字母轉換爲小寫字母;
# 將“(cygwin).*”(.*表示零個或多個字符任意)轉換爲“cygwin”;
# 筆者的電腦是“Linux”,替換爲“linux”。
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed -e 's/\(cygwin\).*/cygwin/')
export HOSTARCH HOSTOS
# Deal with colliding definitions from tcsh etc.
VENDOR=
#########################################################################
# Allow for silent builds
# 假如在MAKEFLAGS變量中發現字符s
ifeq (,$(findstring s,$(MAKEFLAGS)))
# 有回顯
XECHO = echo
else
# 無回顯
XECHO = :
endif
#########################################################################
#
# U-boot build supports producing a object files to the separate external
# directory. Two use cases are supported:
#
# 1) Add O= to the make command line
# 'make O=/tmp/build all'
#
# 2) Set environement variable BUILD_DIR to point to the desired location
# 'export BUILD_DIR=/tmp/build'
# 'make'
#
# The second approach can also be used with a MAKEALL script
# 'export BUILD_DIR=/tmp/build'
# './MAKEALL'
#
# Command line 'O=' setting overrides BUILD_DIR environent variable.
#
# When none of the above methods is used the local build is performed and
# the object files are placed in the source directory.
#
# 假如定義了O
ifdef O
# 假如O來源於命令行
ifeq ("$(origin O)", "command line")
# 展開再複製,即將O裏面的一些變量之類的展開,BUILD_DIR的值爲一個定值字符串,不會再變化,除非修改它。
BUILD_DIR := $(O)
endif
endif
# 假如BUILD_DIR不等於空,或BUILD_DIR未定義
ifneq ($(BUILD_DIR),)
# saved-output等於BUILD_DIR擴展後的值
saved-output := $(BUILD_DIR)
# Attempt to create a output directory.
# 判斷是否存在目錄${BUILD_DIR},如果不存在,則創建目錄${BUILD_DIR}
$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
# Verify if it was successful.
# 進入目錄$(BUILD_DIR),並打印出絕對地址
BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
# 假如$(BUILD_DIR)爲空或未定義,則輸出錯誤信息
$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
endif # ifneq ($(BUILD_DIR),)
# 假如$(BUILD_DIR)值不爲空,則OBJTREE:=$(BUILD_DIR),否則$(BUILD_DIR):=$(CURDIR)
# 這裏是$(BUILD_DIR):=$(CURDIR)
OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
SRCTREE := $(CURDIR)
TOPDIR := $(SRCTREE)
LNDIR := $(OBJTREE)
# 導出變量,使其它makefile文件可以使用導出的變量
export TOPDIR SRCTREE OBJTREE
MKCONFIG := $(SRCTREE)/mkconfig
export MKCONFIG
# 假如$(OBJTREE)和$(SRCTREE)不相等。平時編譯都沒有設置變量O,因此,這裏是相等的,都爲$(CURDIR)
ifneq ($(OBJTREE),$(SRCTREE))
REMOTE_BUILD := 1
export REMOTE_BUILD
endif
# $(obj) and (src) are defined in config.mk but here in main Makefile
# we also need them before config.mk is included which is the case for
# some targets like unconfig, clean, clobber, distclean, etc.
# 假如$(OBJTREE)和$(SRCTREE)不相等。平時編譯都沒有設置變量O,因此,這裏是相等的,都爲$(CURDIR)
ifneq ($(OBJTREE),$(SRCTREE))
obj := $(OBJTREE)/
src := $(SRCTREE)/
else
# 上面比較的兩個是相等的,所以這下面兩個變量爲空值。
obj :=
src :=
endif
export obj src
# Make sure CDPATH settings don't interfere
# 不導出變量CDPATH,防止干擾到其它makefile文件中的這個變量
unexport CDPATH
#########################################################################
# 假如$(obj)include/config.mk和$(wildcard $(obj)include/config.mk)相等
# `$(wildcard PATTERN)' 爲擴展後面跟隨的字符串裏面的通配符
ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
# load ARCH, BOARD, and CPU configuration
# 包含$(obj)include/config.mk,這裏是包含include/config.mk。如果沒有找到這個文件,會生成一條警告消息。
include $(obj)include/config.mk
# 上面的makefile文件包含下面幾個變量的值:
# ARCH = arm
# CPU = s5pc11x
# BOARD = smdkc110
# VENDOR = samsung
# SOC = s5pc110
export ARCH CPU BOARD VENDOR SOC
# 交叉編譯器的路徑,根據自己交叉編譯器所在路徑進行適當修改
CROSS_COMPILE = /home/shq/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_Linux/bin/arm-none-linux-gnueabi-
export CROSS_COMPILE
# load other configuration
# 包含$(TOPDIR)/config.mk,這裏是包含config.mk。如果沒有找到這個文件,會生成一條警告消息。
include $(TOPDIR)/config.mk
#########################################################################
# U-Boot objects....order is important (i.e. start must be first)
OBJS = cpu/$(CPU)/start.o
OBJS := $(addprefix $(obj),$(OBJS))
LIBS = lib_generic/libgeneric.a
LIBS += cpu/$(CPU)/lib$(CPU).a
LIBS += cpu/$(CPU)/$(SOC)/lib$(SOC).a
LIBS += lib_$(ARCH)/lib$(ARCH).a
LIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \
fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
LIBS += net/libnet.a
LIBS += disk/libdisk.a
LIBS += drivers/bios_emulator/libatibiosemu.a
LIBS += drivers/block/libblock.a
LIBS += drivers/dma/libdma.a
LIBS += drivers/hwmon/libhwmon.a
LIBS += drivers/i2c/libi2c.a
LIBS += drivers/input/libinput.a
LIBS += drivers/misc/libmisc.a
LIBS += drivers/mmc/libmmc.a
LIBS += drivers/mtd/libmtd.a
LIBS += drivers/mtd/nand/libnand.a
LIBS += drivers/mtd/nand_legacy/libnand_legacy.a
LIBS += drivers/mtd/onenand/libonenand.a
LIBS += drivers/mtd/ubi/libubi.a
LIBS += drivers/mtd/spi/libspi_flash.a
LIBS += drivers/net/libnet.a
LIBS += drivers/net/sk98lin/libsk98lin.a
LIBS += drivers/pci/libpci.a
LIBS += drivers/pcmcia/libpcmcia.a
LIBS += drivers/spi/libspi.a
LIBS += drivers/rtc/librtc.a
LIBS += drivers/serial/libserial.a
LIBS += drivers/usb/libusb.a
LIBS += drivers/video/libvideo.a
LIBS += common/libcommon.a
#LIBS += libfdt/libfdt.a
#LIBS += api/libapi.a
#LIBS += post/libpost.a
# `$(addprefix PREFIX,NAMES...)' 添加前綴
LIBS := $(addprefix $(obj),$(LIBS))
.PHONY : $(LIBS) $(VERSION_FILE)
LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a
LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
# Add GCC lib
# -print-libgcc-file-name 輸出libgcc.a的完整絕對路徑
# -L DIRECTORY 將DIRECTORY添加到庫搜索路徑
# -lgcc 當連接時不使用標準庫
# ‘-lgcc’, use with ‘-nodefaultlibs’
# ‘-lgcc’, use with ‘-nostdlib’
PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
# The "tools" are needed early, so put this first
# Don't include stuff already done in $(LIBS)
SUBDIRS = tools \
examples \
#api_examples
.PHONY : $(SUBDIRS)
# `$(subst FROM,TO,TEXT)' 將TEXT中的東西從FROM變爲TO
__OBJS := $(subst $(obj),,$(OBJS))
__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))
#########################################################################
#########################################################################
ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BOOT_ONENAND) $(obj)u-boot.dis
all: $(ALL)
# -O srec 創建一個輸出文件,用srec格式
# $< 第一個依賴的文件名
# #@ 規則的目標文件名
$(obj)u-boot.srec: $(obj)u-boot
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
# -O binary 創建一個輸出文件,用binary格式
$(obj)u-boot.bin: $(obj)u-boot
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
# -d 顯示可執行部分的彙編內容
$(obj)u-boot.dis: $(obj)u-boot
$(OBJDUMP) -d $< > $@
# -x 顯示所有頭文件的目錄
# sed -n 無聲模式
# -e 將腳本添加作爲執行的命令
# --start-group archives --end-group 指定的存檔(archives)會被重複搜索直到沒有新創建的未定義引用。
# -Map=mapfile 打印一個mapfile文件的規劃圖
# -o output 用output作爲ld程序生成的文件名
$(obj)u-boot: depend $(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT)
UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-Map u-boot.map -o u-boot
# -C dir, --directory=dir 切換到dir目錄前,讀取makefile或做其它事情
# `$(notdir NAMES...)' 抽取‘NAMES’中每一個文件名中除路徑部分外一切字符(真正的文件名)。
$(OBJS): depend $(obj)include/autoconf.mk
$(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@))
$(LIBS): depend $(obj)include/autoconf.mk
$(MAKE) -C $(dir $(subst $(obj),,$@))
$(LIBBOARD): depend $(LIBS) $(obj)include/autoconf.mk
$(MAKE) -C $(dir $(subst $(obj),,$@))
$(SUBDIRS): depend $(obj)include/autoconf.mk
$(MAKE) -C $@ all
$(LDSCRIPT): depend $(obj)include/autoconf.mk
$(MAKE) -C $(dir $@) $(notdir $@)
$(NAND_SPL): $(VERSION_FILE) $(obj)include/autoconf.mk
$(MAKE) -C nand_spl/board/$(BOARDDIR) all
$(U_BOOT_NAND): $(NAND_SPL) $(obj)u-boot.bin $(obj)include/autoconf.mk
cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
$(ONENAND_IPL): $(VERSION_FILE) $(obj)include/autoconf.mk
$(MAKE) -C $(obj)onenand_bl1/$(BOARD) all
$(U_BOOT_ONENAND): $(ONENAND_IPL) $(obj)u-boot.bin $(obj)include/autoconf.mk
cat $(obj)onenand_bl1/$(BOARD)/BL1.bin.padding $(obj)u-boot.bin > $(U_BOOT_ONENAND)
# cmp -s 禁止一切正常輸出
# rm -f 忽略不存在的文件,不提示
# mv -f 在覆蓋之前不提示
$(VERSION_FILE):
@( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \
'$(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion $(TOPDIR))' \
) > [email protected]
@cmp -s $@ [email protected] && rm -f [email protected] || mv -f [email protected] $@
gdbtools:
$(MAKE) -C tools/gdb all || exit 1
updater:
$(MAKE) -C tools/updater all || exit 1
env:
$(MAKE) -C tools/env all MTD_VERSION=${MTD_VERSION} || exit 1
depend dep: $(VERSION_FILE)
for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir _depend ; done
TAG_SUBDIRS += include
TAG_SUBDIRS += lib_generic board/$(BOARDDIR)
TAG_SUBDIRS += cpu/$(CPU)
TAG_SUBDIRS += lib_$(ARCH)
TAG_SUBDIRS += fs/cramfs
TAG_SUBDIRS += fs/fat
TAG_SUBDIRS += fs/fdos
TAG_SUBDIRS += fs/jffs2
TAG_SUBDIRS += net
TAG_SUBDIRS += disk
TAG_SUBDIRS += common
TAG_SUBDIRS += drivers/bios_emulator
TAG_SUBDIRS += drivers/block
TAG_SUBDIRS += drivers/hwmon
TAG_SUBDIRS += drivers/i2c
TAG_SUBDIRS += drivers/input
TAG_SUBDIRS += drivers/misc
TAG_SUBDIRS += drivers/mmc
TAG_SUBDIRS += drivers/mtd
TAG_SUBDIRS += drivers/mtd/nand
TAG_SUBDIRS += drivers/mtd/nand_legacy
TAG_SUBDIRS += drivers/mtd/onenand
TAG_SUBDIRS += drivers/mtd/spi
TAG_SUBDIRS += drivers/net
TAG_SUBDIRS += drivers/net/sk98lin
TAG_SUBDIRS += drivers/pci
TAG_SUBDIRS += drivers/pcmcia
TAG_SUBDIRS += drivers/qe
TAG_SUBDIRS += drivers/rtc
TAG_SUBDIRS += drivers/serial
TAG_SUBDIRS += drivers/spi
TAG_SUBDIRS += drivers/usb
TAG_SUBDIRS += drivers/video
tags ctags:
ctags -w -o $(obj)ctags `find $(SUBDIRS) $(TAG_SUBDIRS) \
-name '*.[ch]' -print`
etags:
etags -a -o $(obj)etags `find $(SUBDIRS) $(TAG_SUBDIRS) \
-name '*.[ch]' -print`
cscope:
find $(SUBDIRS) $(TAG_SUBDIRS) -name '*.[ch]' -print \
> cscope.files
cscope -b -q -k
$(obj)System.map: $(obj)u-boot
@$(NM) $< | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(obj)System.map
#
# Auto-generate the autoconf.mk file (which is included by all makefiles)
#
# This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
# the dep file is only include in this top level makefile to determine when
# to regenerate the autoconf.mk file.
$(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
@$(XECHO) Generating $@ ; \
set -e ; \
: Generate the dependancies ; \
$(CC) -x c -DDO_DEPS_ONLY -M $(HOST_CFLAGS) $(CPPFLAGS) \
-MQ $(obj)include/autoconf.mk include/common.h > $@
$(obj)include/autoconf.mk: $(obj)include/config.h
@$(XECHO) Generating $@ ; \
set -e ; \
: Extract the config macros ; \
$(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \
sed -n -f tools/scripts/define2mk.sed > $@
sinclude $(obj)include/autoconf.mk.dep
#########################################################################
else # !config.mk
all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
$(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
$(SUBDIRS) $(VERSION_FILE) gdbtools updater env depend \
dep tags ctags etags cscope $(obj)System.map:
@echo "System not configured - see README" >&2
@ exit 1
endif # config.mk
#########################################################################
unconfig:
@rm -f $(obj)include/config.h $(obj)include/config.mk \
$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
$(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \
$(obj)board/$(VENDOR)/$(BOARD)/config.mk
# $(@:_config=) 將$@即目標名,_config替換爲空
smdkv210single_config : unconfig
@$(MKCONFIG) $(@:_config=) arm s5pc11x smdkc110 samsung s5pc110
@echo "TEXT_BASE = 0xc3e00000" > $(obj)board/samsung/smdkc110/config.mk
#########################################################################
#########################################################################
#########################################################################
clean:
@rm -f $(obj)examples/82559_eeprom $(obj)examples/eepro100_eeprom \
$(obj)examples/hello_world $(obj)examples/interrupt \
$(obj)examples/mem_to_mem_idma2intr \
$(obj)examples/sched $(obj)examples/smc91111_eeprom \
$(obj)examples/test_burst $(obj)examples/timer
@rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \
$(obj)tools/env/{fw_printenv,fw_setenv} \
$(obj)tools/envcrc \
$(obj)tools/gdb/{astest,gdbcont,gdbsend} \
$(obj)tools/gen_eth_addr $(obj)tools/img2srec \
$(obj)tools/mkimage $(obj)tools/mpc86x_clk \
$(obj)tools/ncb $(obj)tools/ubsha1
@rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image} \
$(obj)board/netstar/{eeprom,crcek,crcit,*.srec,*.bin} \
$(obj)board/trab/trab_fkt $(obj)board/voiceblue/eeprom \
$(obj)board/{integratorap,integratorcp}/u-boot.lds \
$(obj)board/{bf533-ezkit,bf533-stamp,bf537-stamp,bf561-ezkit}/u-boot.lds \
$(obj)cpu/blackfin/bootrom-asm-offsets.[chs]
@rm -f $(obj)include/bmp_logo.h
@rm -f $(obj)nand_spl/{u-boot-spl,u-boot-spl.map,System.map}
@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map}
@rm -f $(obj)api_examples/demo $(VERSION_FILE)
@find $(OBJTREE) -type f \
\( -name 'core' -o -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.a' \) -print \
| xargs rm -f
clobber: clean
@find $(OBJTREE) -type f \( -name .depend \
-o -name '*.srec' -o -name '*.bin' -o -name u-boot.img \) \
-print0 \
| xargs -0 rm -f
@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
$(obj)cscope.* $(obj)*.*~
@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
@rm -f $(obj)tools/{crc32.c,environment.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
@rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
@rm -f $(obj)include/regs.h
@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -lname "*" -print | xargs rm -f
@[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -lname "*" -print | xargs rm -f
@[ ! -d $(obj)api_examples ] || find $(obj)api_examples -lname "*" -print | xargs rm -f
ifeq ($(OBJTREE),$(SRCTREE))
mrproper \
distclean: clobber unconfig
else
mrproper \
distclean: clobber unconfig
rm -rf $(obj)*
endif
backup:
F=`basename $(TOPDIR)` ; cd .. ; \
gtar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
#########################################################################
-print-libgcc-file-name
Same as ‘-print-file-name=libgcc.a’.
This is useful when you use ‘-nostdlib’ or ‘-nodefaultlibs’ but you do want
to link with ‘libgcc.a’. You can do
gcc -nostdlib files ... ‘gcc -print-libgcc-file-name‘
-print-file-name=library
Print the full absolute name of the library file library that would be used when
linking—and don’t do anything else. With this option, GCC does not compile
or link anything; it just prints the file name.
-L DIRECTORY, --library-path DIRECTORY
Add DIRECTORY to library search path
-nodefaultlibs
Do not use the standard system libraries when linking. Only the libraries you
specify will be passed to the linker, options specifying linkage of the system
libraries, such as -static-libgcc or -shared-libgcc, will be ignored. The
standard startup files are used normally, unless ‘-nostartfiles’ is used. The
compiler may generate calls to memcmp, memset, memcpy and memmove. These
entries are usually resolved by entries in libc. These entry points should be
supplied through some other mechanism when this option is specified.
-nostdlib
Do not use the standard system startup files or libraries when linking. No
startup files and only the libraries you specify will be passed to the linker,
options specifying linkage of the system libraries, such as -static-libgcc or
-shared-libgcc, will be ignored. The compiler may generate calls to memcmp,
memset, memcpy and memmove. These entries are usually resolved by entries in
libc. These entry points should be supplied through some other mechanism
when this option is specified.
One of the standard libraries bypassed by ‘-nostdlib’ and ‘-nodefaultlibs’
is ‘libgcc.a’, a library of internal subroutines which GCC uses to overcome
shortcomings of particular machines, or special needs for some languages. (See
Section “Interfacing to GCC Output” in GNU Compiler Collection (GCC) In-
ternals, for more discussion of ‘libgcc.a’.) In most cases, you need ‘libgcc.a’
even when you want to avoid other standard libraries. In other words, when you
specify ‘-nostdlib’ or ‘-nodefaultlibs’ you should usually specify ‘-lgcc’ as
well. This ensures that you have no unresolved references to internal GCC
library subroutines. (For example, ‘__main’, used to ensure C++ constructors
will be called; see Section “collect2” in GNU Compiler Collection (GCC)
Internals.)
-O --output-target <bfdname>
Create an output file in format <bfdname>
-d, --disassemble
Display assembler contents of executable sections
-x, --all-headers
Display the contents of all headers
-n, --quiet, --silent
suppress automatic printing of pattern space
-e script, --expression=script
add the script to the commands to be executed
--start-group archives --end-group
The archives should be a list of archive files. They may be either explicit file
names, or ‘-l’ options.
The specified archives are searched repeatedly until no new undefined references
are created. Normally, an archive is searched only once in the order that it is
specified on the command line. If a symbol in that archive is needed to resolve
an undefined symbol referred to by an object in an archive that appears later
on the command line, the linker would not be able to resolve that reference.
By grouping the archives, they all be searched repeatedly until all possible
references are resolved.
Using this option has a significant performance cost. It is best to use it only
when there are unavoidable circular references between two or more archives.
-Map=mapfile
Print a link map to the file mapfile. See the description of the ‘-M’ option,
above.
-o output
--output=output
Use output as the name for the program produced by ld; if this option is not
specified, the name ‘a.out’ is used by default. The script command OUTPUT
can also specify the output file name.
-C dir, --directory=dir
Change to directory dir before reading the makefiles or doing
anything else. If multiple -C options are specified, each is interpreted
relative to the previous one: -C / -C etc is equivalent to -C /etc.
This is typically used with recursive invocations of make.