Commit 6d8962e8 by Sebastien Carlier Committed by Wolfgang Denk

Switch from archive libraries to partial linking

Before this commit, weak symbols were not overridden by non-weak symbols found in archive libraries when linking with recent versions of binutils. As stated in the System V ABI, "the link editor does not extract archive members to resolve undefined weak symbols". This commit changes all Makefiles to use partial linking (ld -r) instead of creating library archives, which forces all symbols to participate in linking, allowing non-weak symbols to override weak symbols as intended. This approach is also used by Linux, from which the gmake function cmd_link_o_target (defined in config.mk and used in all Makefiles) is inspired. The name of each former library archive is preserved except for extensions which change from ".a" to ".o". This commit updates references accordingly where needed, in particular in some linker scripts. This commit reveals board configurations that exclude some features but include source files that depend these disabled features in the build, resulting in undefined symbols. Known such cases include: - disabling CMD_NET but not CMD_NFS; - enabling CONFIG_OF_LIBFDT but not CONFIG_QE. Signed-off-by: 's avatarSebastien Carlier <sebastien.carlier@gmail.com>
parent d7b19700
......@@ -180,90 +180,90 @@ endif
OBJS := $(addprefix $(obj),$(OBJS))
LIBS = lib/libgeneric.a
LIBS += lib/lzma/liblzma.a
LIBS += lib/lzo/liblzo.a
LIBS = lib/libgeneric.o
LIBS += lib/lzma/liblzma.o
LIBS += lib/lzo/liblzo.o
LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
"board/$(VENDOR)/common/lib$(VENDOR).a"; fi)
LIBS += $(CPUDIR)/lib$(CPU).a
"board/$(VENDOR)/common/lib$(VENDOR).o"; fi)
LIBS += $(CPUDIR)/lib$(CPU).o
ifdef SOC
LIBS += $(CPUDIR)/$(SOC)/lib$(SOC).a
LIBS += $(CPUDIR)/$(SOC)/lib$(SOC).o
endif
ifeq ($(CPU),ixp)
LIBS += arch/arm/cpu/ixp/npe/libnpe.a
LIBS += arch/arm/cpu/ixp/npe/libnpe.o
endif
LIBS += arch/$(ARCH)/lib/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 fs/yaffs2/libyaffs2.a \
fs/ubifs/libubifs.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/fpga/libfpga.a
LIBS += drivers/gpio/libgpio.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/onenand/libonenand.a
LIBS += drivers/mtd/ubi/libubi.a
LIBS += drivers/mtd/spi/libspi_flash.a
LIBS += drivers/net/libnet.a
LIBS += drivers/net/phy/libphy.a
LIBS += drivers/pci/libpci.a
LIBS += drivers/pcmcia/libpcmcia.a
LIBS += drivers/power/libpower.a
LIBS += drivers/spi/libspi.a
LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
fs/ubifs/libubifs.o
LIBS += net/libnet.o
LIBS += disk/libdisk.o
LIBS += drivers/bios_emulator/libatibiosemu.o
LIBS += drivers/block/libblock.o
LIBS += drivers/dma/libdma.o
LIBS += drivers/fpga/libfpga.o
LIBS += drivers/gpio/libgpio.o
LIBS += drivers/hwmon/libhwmon.o
LIBS += drivers/i2c/libi2c.o
LIBS += drivers/input/libinput.o
LIBS += drivers/misc/libmisc.o
LIBS += drivers/mmc/libmmc.o
LIBS += drivers/mtd/libmtd.o
LIBS += drivers/mtd/nand/libnand.o
LIBS += drivers/mtd/onenand/libonenand.o
LIBS += drivers/mtd/ubi/libubi.o
LIBS += drivers/mtd/spi/libspi_flash.o
LIBS += drivers/net/libnet.o
LIBS += drivers/net/phy/libphy.o
LIBS += drivers/pci/libpci.o
LIBS += drivers/pcmcia/libpcmcia.o
LIBS += drivers/power/libpower.o
LIBS += drivers/spi/libspi.o
ifeq ($(CPU),mpc83xx)
LIBS += drivers/qe/qe.a
LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.a
LIBS += drivers/qe/libqe.o
LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
endif
ifeq ($(CPU),mpc85xx)
LIBS += drivers/qe/qe.a
LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.a
LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.a
LIBS += drivers/qe/libqe.o
LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
endif
ifeq ($(CPU),mpc86xx)
LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.a
LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.a
LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
endif
LIBS += drivers/rtc/librtc.a
LIBS += drivers/serial/libserial.a
LIBS += drivers/twserial/libtws.a
LIBS += drivers/usb/gadget/libusb_gadget.a
LIBS += drivers/usb/host/libusb_host.a
LIBS += drivers/usb/musb/libusb_musb.a
LIBS += drivers/usb/phy/libusb_phy.a
LIBS += drivers/video/libvideo.a
LIBS += drivers/watchdog/libwatchdog.a
LIBS += common/libcommon.a
LIBS += lib/libfdt/libfdt.a
LIBS += api/libapi.a
LIBS += post/libpost.a
LIBS += drivers/rtc/librtc.o
LIBS += drivers/serial/libserial.o
LIBS += drivers/twserial/libtws.o
LIBS += drivers/usb/gadget/libusb_gadget.o
LIBS += drivers/usb/host/libusb_host.o
LIBS += drivers/usb/musb/libusb_musb.o
LIBS += drivers/usb/phy/libusb_phy.o
LIBS += drivers/video/libvideo.o
LIBS += drivers/watchdog/libwatchdog.o
LIBS += common/libcommon.o
LIBS += lib/libfdt/libfdt.o
LIBS += api/libapi.o
LIBS += post/libpost.o
ifeq ($(SOC),omap3)
LIBS += $(CPUDIR)/omap-common/libomap-common.a
LIBS += $(CPUDIR)/omap-common/libomap-common.o
endif
ifeq ($(SOC),omap4)
LIBS += $(CPUDIR)/omap-common/libomap-common.a
LIBS += $(CPUDIR)/omap-common/libomap-common.o
endif
ifeq ($(SOC),s5pc1xx)
LIBS += $(CPUDIR)/s5p-common/libs5p-common.a
LIBS += $(CPUDIR)/s5p-common/libs5p-common.o
endif
ifeq ($(SOC),s5pc2xx)
LIBS += $(CPUDIR)/s5p-common/libs5p-common.a
LIBS += $(CPUDIR)/s5p-common/libs5p-common.o
endif
LIBS := $(addprefix $(obj),$(LIBS))
.PHONY : $(LIBS) $(TIMESTAMP_FILE) $(VERSION_FILE)
LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a
LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o
LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
# Add GCC lib
......
......@@ -22,7 +22,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)libapi.a
LIB = $(obj)libapi.o
COBJS-$(CONFIG_API) += api.o api_net.o api_storage.o api_platform-$(ARCH).o
......@@ -31,7 +31,7 @@ SRCS := $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS))
$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(CPU).a
LIB = $(obj)lib$(CPU).o
START = start.o
COBJS = cpu.o
......@@ -35,7 +35,7 @@ START := $(addprefix $(obj),$(START))
all: $(obj).depend $(START) $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
COBJS += generic.o
COBJS += timer.o
......@@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
SOBJS = reset.o
......@@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -26,7 +26,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(CPU).a
LIB = $(obj)lib$(CPU).o
START = start.o
COBJS = cpu.o
......@@ -38,7 +38,7 @@ START := $(addprefix $(obj),$(START))
all: $(obj).depend $(START) $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -26,7 +26,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
SOBJS = reset.o
......@@ -38,7 +38,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
all: $(obj).depend $(START) $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -19,7 +19,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
COBJS += aemif.o clock.o init.o mux.o timer.o wdt.o
SOBJS += lowlevel_init.o
......@@ -32,7 +32,7 @@ START := $(addprefix $(obj),$(START))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(CPU).a
LIB = $(obj)lib$(CPU).o
START = start.o
COBJS = interrupts.o cpu.o
......@@ -35,7 +35,7 @@ START := $(addprefix $(obj),$(START))
all: $(obj).depend $(START) $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
COBJS = flash.o mmc.o mmc_hw.o spi.o
SOBJS = $(obj)iap_entry.o
......@@ -34,7 +34,7 @@ OBJS := $(addprefix $(obj),$(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS) $(SOBJS)
$(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
$(call cmd_link_o_target, $(OBJS) $(SOBJS))
# this MUST be compiled as thumb code!
$(SOBJS):
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
COBJS-y += cache.o
......@@ -33,7 +33,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(CPU).a
LIB = $(obj)lib$(CPU).o
START = start.o
......@@ -37,7 +37,7 @@ START := $(addprefix $(obj),$(START))
all: $(obj).depend $(START) $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
SOBJS += reset.o
COBJS += timer.o
......@@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
SOBJS += lowlevel_init.o
COBJS += reset.o
......@@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
SOBJS += lowlevel_init.o
......@@ -44,7 +44,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS) $(COBJS-y))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -32,7 +32,7 @@
#
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
COBJS = cpu.o led.o speed.o timer.o
SOBJS = lowlevel_init.o
......@@ -43,7 +43,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a
LIB = $(obj)lib$(SOC).o
COBJS += generic.o
COBJS += speed.o
......@@ -35,7 +35,7 @@ OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
all: $(obj).depend $(LIB)
$(LIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(call cmd_link_o_target, $(OBJS))
#########################################################################
......
......@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a