diff --git a/Makefile b/Makefile index 9f30faf..c4a2519 100644 --- a/Makefile +++ b/Makefile @@ -664,8 +664,8 @@ $(core-n) $(core-) $(drivers-n) $(drivers-) \ $(net-n) $(net-) $(libs-n) $(libs-)))) -pbl-common-y := $(patsubst %/, %/built-in-pbl.o, $(common-y)) -common-y := $(patsubst %/, %/built-in.o, $(common-y)) +pbl-common-y := $(patsubst %/, %/built-in.pbl.a, $(common-y)) +common-y := $(patsubst %/, %/built-in.a, $(common-y)) ifeq ($(CONFIG_DEFAULT_COMPRESSION_GZIP),y) DEFAULT_COMPRESSION_SUFFIX := .gz @@ -687,7 +687,7 @@ # Build barebox # --------------------------------------------------------------------------- # barebox is built from the objects selected by $(barebox-init) and -# $(barebox-main). Most are built-in.o files from top-level directories +# $(barebox-main). Most are built-in.a files from top-level directories # in the kernel tree, others are specified in arch/$(SRCARCH)/Makefile. # Ordering when linking is important, and $(barebox-init) must be first. # @@ -700,7 +700,7 @@ # | +--< init/version.o + more # | # +--< $(barebox-main) -# | +--< driver/built-in.o mm/built-in.o + more +# | +--< driver/built-in.a mm/built-in.a + more # | # +-< kallsyms.o (see description in CONFIG_KALLSYMS section) # @@ -719,7 +719,7 @@ quiet_cmd_barebox__ ?= LD $@ cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \ -T $(BAREBOX_LDS) \ - --start-group $(BAREBOX_OBJS) --end-group \ + --whole-archive $(BAREBOX_OBJS) --no-whole-archive \ $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^) # Generate new barebox version diff --git a/arch/kvx/Makefile b/arch/kvx/Makefile index c97cff3..643ef28 100644 --- a/arch/kvx/Makefile +++ b/arch/kvx/Makefile @@ -32,6 +32,6 @@ cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \ -T $(BAREBOX_LDS) \ - --start-group $(BAREBOX_OBJS) --end-group \ + --whole-archive $(BAREBOX_OBJS) --no-while-archive \ -L$(LIBGCC_PATH) -lgcc \ $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^) diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 5604a0a..4eb6ba7 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile @@ -102,7 +102,7 @@ cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \ -T $(BAREBOX_LDS) \ - --start-group $(BAREBOX_OBJS) --end-group \ + --whole-archive $(BAREBOX_OBJS) --no-whole-archive \ $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^); \ $(objtree)/scripts/mips-relocs $@ diff --git a/arch/mips/pbl/Makefile b/arch/mips/pbl/Makefile index 535bb4b..3bd0df1 100644 --- a/arch/mips/pbl/Makefile +++ b/arch/mips/pbl/Makefile @@ -31,7 +31,7 @@ quiet_cmd_zbarebox__ ?= LD $@ cmd_zbarebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \ -T $(zbarebox-lds) \ - --start-group $(zbarebox-common) --end-group \ + --whole-archive $(zbarebox-common) --no-while-archive \ $(filter-out $(zbarebox-lds) $(zbarebox-common) FORCE ,$^) $(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile index 3d2eb5b..3917cad 100644 --- a/arch/sandbox/Makefile +++ b/arch/sandbox/Makefile @@ -53,7 +53,7 @@ endif cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(BAREBOX_LDS) \ - -Wl,--start-group $(BAREBOX_OBJS) -Wl,--end-group \ + -Wl,--whole-archive $(BAREBOX_OBJS) -Wl,--no-whole-archive \ -lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \ $(SANITIZER_LIBS) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 97f6d85..61e51ab 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -73,8 +73,8 @@ cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \ -T $(lds-y) \ -shared -Bsymbolic -nostdlib -znocombreloc \ - --start-group $(BAREBOX_OBJS) \ - --end-group \ + --whole-archive $(BAREBOX_OBJS) \ + --no-whole-archive \ $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^) quiet_cmd_efi_image = EFI-IMG $@ diff --git a/images/Makefile b/images/Makefile index 0aa4676..b8899dc 100644 --- a/images/Makefile +++ b/images/Makefile @@ -57,8 +57,8 @@ cmd_elf__ ?= $(LD) $(LDFLAGS_pbl) --gc-sections \ -e $(2) -Map $@.map $(LDFLAGS_$(@F)) -o $@ \ -T $(pbl-lds) \ - --start-group $(BAREBOX_PBL_OBJS) $(obj)/piggy.o \ - $(obj)/sha_sum.o --end-group + --whole-archive $(BAREBOX_PBL_OBJS) $(obj)/piggy.o \ + $(obj)/sha_sum.o PBL_CPPFLAGS += -fdata-sections -ffunction-sections diff --git a/scripts/Makefile.build b/scripts/Makefile.build index ed2bb28..00f6277 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -60,12 +60,12 @@ endif ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(lib-target) $(pbl-y)),) -builtin-target := $(obj)/built-in.o +builtin-target := $(obj)/built-in.a endif ifeq ($(CONFIG_PBL_IMAGE), y) ifneq ($(strip $(pbl-y) $(builtin-target)),) -pbl-target := $(obj)/built-in-pbl.o +pbl-target := $(obj)/built-in.pbl.a endif endif @@ -186,22 +186,18 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; # -# Rule to compile a set of .o files into one .o file +# Rule to compile a set of .o files into one .a file (without symbol table) # +quiet_cmd_ar_builtin = AR $(quiet_modtag) $@ + cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs) -# If the list of objects to link is empty, just create an empty built-in.o -quiet_cmd_link_o_target = LD $(quiet_modtag) $@ -cmd_link_o_target = $(if $(strip $(real-prereqs)),\ - $(LD) $(ld_flags) -r -o $@ $(real-prereqs),\ - rm -f $@; $(AR) rcs $@) - -$(builtin-target): $(obj-y) FORCE - $(call if_changed,link_o_target) +$(builtin-target): $(real-obj-y) FORCE + $(call if_changed,ar_builtin) targets += $(builtin-target) $(pbl-target): $(pbl-y) FORCE - $(call if_changed,link_o_target) + $(call if_changed,ar_builtin) targets += $(pbl-target) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 55d2518..3799e77 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -22,7 +22,7 @@ # Handle objects in subdirs # --------------------------------------------------------------------------- -# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o +# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a # and add the directory to the list of dirs to descend into: $(subdir-y) # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) # and add the directory to the list of dirs to descend into: $(subdir-m) @@ -46,13 +46,13 @@ __pbl-y := $(filter-out $(pbl-y), $(filter %/, $(obj-y))) pbl-y += $(__pbl-y) -pbl-y := $(sort $(patsubst %/, %/built-in-pbl.o, $(pbl-y))) +pbl-y := $(sort $(patsubst %/, %/built-in.pbl.a, $(pbl-y))) __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) subdir-m += $(__subdir-m) -obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) +obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) obj-m := $(filter-out %/, $(obj-m)) # Subdirectories we need to descend into @@ -73,8 +73,8 @@ # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to # tell kbuild to descend -__subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y)) -subdir-obj-y := $(filter %/built-in.o, $(obj-y)) +__subdir-obj-y := $(filter %/built-in.pbl.a, $(pbl-y)) +subdir-obj-y := $(filter %/built-in.a, $(obj-y)) subdir-obj-y += $(__subdir-obj-y) obj-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y)) @@ -154,7 +154,7 @@ endif part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y) -part-of-pbl = $(if $(filter $(basename $@).o, $(pbl-y) $(pbl-target)),y) +part-of-pbl = $(if $(filter $(basename $@).o, $(pbl-y))$(filter $@, $(pbl-target)),y) quiet_modtag = $(if $(part-of-pbl),[P],$(if $(part-of-module),[M], )) pbl_cppflags = $(if $(part-of-pbl), -D__PBL__ $(PBL_CPPFLAGS))