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: Sebastien Carlier <sebastien.carlier@gmail.com>
diff --git a/drivers/bios_emulator/Makefile b/drivers/bios_emulator/Makefile
index feba4da..d94a144 100644
--- a/drivers/bios_emulator/Makefile
+++ b/drivers/bios_emulator/Makefile
@@ -1,6 +1,6 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libatibiosemu.a
+LIB := $(obj)libatibiosemu.o
X86DIR = x86emu
@@ -28,7 +28,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 64dcf4e..e27175b 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libblock.a
+LIB := $(obj)libblock.o
COBJS-$(CONFIG_SCSI_AHCI) += ahci.o
COBJS-$(CONFIG_ATA_PIIX) += ata_piix.o
@@ -45,7 +45,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index 36d99f9..9d945a0 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libdma.a
+LIB := $(obj)libdma.o
COBJS-$(CONFIG_FSLDMAFEC) += MCD_tasksInit.o MCD_dmaApi.o MCD_tasks.o
COBJS-$(CONFIG_FSL_DMA) += fsl_dma.o
@@ -35,7 +35,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
index 9ecdc5e..b48f623 100644
--- a/drivers/fpga/Makefile
+++ b/drivers/fpga/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libfpga.a
+LIB := $(obj)libfpga.o
ifdef CONFIG_FPGA
COBJS-y += fpga.o
@@ -47,7 +47,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index a0f4552..398024c 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libgpio.a
+LIB := $(obj)libgpio.o
COBJS-$(CONFIG_AT91_GPIO) += at91_gpio.o
COBJS-$(CONFIG_KIRKWOOD_GPIO) += kw_gpio.o
@@ -38,7 +38,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 59302fa..f04cd69 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -28,7 +28,7 @@
#CFLAGS += -DDEBUG
-LIB = $(obj)libhwmon.a
+LIB = $(obj)libhwmon.o
COBJS-$(CONFIG_DTT_ADM1021) += adm1021.o
COBJS-$(CONFIG_DTT_ADT7460) += adt7460.o
@@ -47,7 +47,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 8921ff9..052fe36 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libi2c.a
+LIB := $(obj)libi2c.o
COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o
@@ -48,7 +48,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index 9a14407..1f4dad3 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libinput.a
+LIB := $(obj)libinput.o
COBJS-$(CONFIG_I8042_KBD) += i8042.o
ifdef CONFIG_PS2KBD
@@ -38,7 +38,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 5d668f8..a76bd4e 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libmisc.a
+LIB := $(obj)libmisc.o
COBJS-$(CONFIG_ALI152X) += ali512x.o
COBJS-$(CONFIG_DS4510) += ds4510.o
@@ -42,7 +42,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 2ead634..68afd30 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libmmc.a
+LIB := $(obj)libmmc.o
COBJS-$(CONFIG_ATMEL_MCI) += atmel_mci.o
COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o
@@ -43,7 +43,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index cbf6f15..999431c 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libmtd.a
+LIB := $(obj)libmtd.o
COBJS-$(CONFIG_MTD_DEVICE) += mtdcore.o
COBJS-$(CONFIG_MTD_PARTITIONS) += mtdpart.o
@@ -43,7 +43,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 28f27da..8b598f6 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libnand.a
+LIB := $(obj)libnand.o
ifdef CONFIG_CMD_NAND
COBJS-y += nand.o
@@ -59,7 +59,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/mtd/onenand/Makefile b/drivers/mtd/onenand/Makefile
index 2571df0..b984bd4 100644
--- a/drivers/mtd/onenand/Makefile
+++ b/drivers/mtd/onenand/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libonenand.a
+LIB := $(obj)libonenand.o
COBJS-$(CONFIG_CMD_ONENAND) := onenand_uboot.o onenand_base.o onenand_bbt.o
COBJS-$(CONFIG_SAMSUNG_ONENAND) += samsung.o
@@ -35,7 +35,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile
index a082ca7..3d607c0 100644
--- a/drivers/mtd/spi/Makefile
+++ b/drivers/mtd/spi/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libspi_flash.a
+LIB := $(obj)libspi_flash.o
COBJS-$(CONFIG_SPI_FLASH) += spi_flash.o
COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o
@@ -42,7 +42,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/mtd/ubi/Makefile b/drivers/mtd/ubi/Makefile
index 8bd82c3..b2e6014 100644
--- a/drivers/mtd/ubi/Makefile
+++ b/drivers/mtd/ubi/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libubi.a
+LIB := $(obj)libubi.o
ifdef CONFIG_CMD_UBI
COBJS-y += build.o vtbl.o vmt.o upd.o kapi.o eba.o io.o wl.o scan.o crc32.o
@@ -39,7 +39,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 79eb66b..5393955 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libnet.a
+LIB := $(obj)libnet.o
COBJS-$(CONFIG_DRIVER_3C589) += 3c589.o
COBJS-$(CONFIG_PPC4xx_EMAC) += 4xx_enet.o
@@ -87,7 +87,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 3b92614..bba8901 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libphy.a
+LIB := $(obj)libphy.o
COBJS-$(CONFIG_BITBANGMII) += miiphybb.o
COBJS-$(CONFIG_MV88E61XX_SWITCH) += mv88e61xx.o
@@ -35,7 +35,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 0c4fa80..ee0c64d 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libpci.a
+LIB := $(obj)libpci.o
COBJS-$(CONFIG_FSL_PCI_INIT) += fsl_pci_init.o
COBJS-$(CONFIG_PCI) += pci.o pci_auto.o pci_indirect.o
@@ -41,7 +41,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index babe3ec..0349508 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libpcmcia.a
+LIB := $(obj)libpcmcia.o
COBJS-$(CONFIG_I82365) += i82365.o
COBJS-$(CONFIG_8xx) += mpc8xx_pcmcia.o
@@ -40,7 +40,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index db53173..c9ba1ae 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libpower.a
+LIB := $(obj)libpower.o
COBJS-$(CONFIG_TWL4030_POWER) += twl4030.o
COBJS-$(CONFIG_TWL6030_POWER) += twl6030.o
@@ -35,7 +35,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/qe/Makefile b/drivers/qe/Makefile
index 18fe9ce..8e9a035 100644
--- a/drivers/qe/Makefile
+++ b/drivers/qe/Makefile
@@ -22,7 +22,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)qe.a
+LIB := $(obj)libqe.o
COBJS-$(CONFIG_OF_LIBFDT) += fdt.o
COBJS-$(CONFIG_QE) += qe.o uccf.o uec.o uec_phy.o
@@ -34,7 +34,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 98734db..f810fca 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -25,7 +25,7 @@
#CFLAGS += -DDEBUG
-LIB = $(obj)librtc.a
+LIB = $(obj)librtc.o
COBJS-$(CONFIG_RTC_AT91SAM9_RTT) += at91sam9_rtt.o
COBJS-$(CONFIG_RTC_BFIN) += bfin_rtc.o
@@ -71,7 +71,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 6d45a8e..7d221fc 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libserial.a
+LIB := $(obj)libserial.o
COBJS-$(CONFIG_ALTERA_UART) += altera_uart.o
COBJS-$(CONFIG_ALTERA_JTAG_UART) += altera_jtag_uart.o
@@ -64,7 +64,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index dfcbb8b..117ab19 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libspi.a
+LIB := $(obj)libspi.o
COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o
COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
@@ -44,7 +44,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/twserial/Makefile b/drivers/twserial/Makefile
index 0b059f3..6c9a987 100644
--- a/drivers/twserial/Makefile
+++ b/drivers/twserial/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libtws.a
+LIB := $(obj)libtws.o
COBJS-$(CONFIG_SOFT_TWS) += soft_tws.o
@@ -34,7 +34,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 8e6b26e..f137817 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libusb_gadget.a
+LIB := $(obj)libusb_gadget.o
# new USB gadget layer dependencies
ifdef CONFIG_USB_ETHER
@@ -48,7 +48,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 0e7c9db..51b2494 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libusb_host.a
+LIB := $(obj)libusb_host.o
# ohci
COBJS-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o
@@ -54,7 +54,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 7d23e06..20b5503 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libusb_musb.a
+LIB := $(obj)libusb_musb.o
COBJS-$(CONFIG_MUSB_HCD) += musb_hcd.o musb_core.o
COBJS-$(CONFIG_MUSB_UDC) += musb_udc.o musb_core.o
@@ -40,7 +40,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index f09e55f..5547570 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -20,7 +20,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libusb_phy.a
+LIB := $(obj)libusb_phy.o
COBJS-$(CONFIG_TWL4030_USB) += twl4030.o
@@ -31,7 +31,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 5b7b261..83274c3 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libvideo.a
+LIB := $(obj)libvideo.o
COBJS-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o videomodes.o
COBJS-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o
@@ -48,7 +48,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 200968de..6ab4d52 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -23,7 +23,7 @@
include $(TOPDIR)/config.mk
-LIB := $(obj)libwatchdog.a
+LIB := $(obj)libwatchdog.o
COBJS-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o
@@ -34,7 +34,7 @@
all: $(LIB)
$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
#########################################################################