build: split and unify linking of final image(s)
v3 cover build: split and unify linking of final image(s)
The monolithic rules, largely but not entirely identical between ports, were pretty ugly to fiddle with. They also ended up going out of sync when really they would better have stayed consistent. Break them up, and use (largely) the same rules for all ports (x86'es xen.efi being somewhat special, though).
The final three patches are related only in so far as they address observations made while doing the conversion.
v3 addresses review feedback (patch 1 only; see there for details).
1: x86: split xen-syms/xen.efi linking rules
2: Arm: split xen-syms linking rule
3: RISC-V: split xen-syms linking rule
4: PPC: split xen-syms linking rule
5: build: move $(all-symbols-*)
6: build: move $(compare-symbol-tables)
Jan
PATCH v3 1/6 x86: split xen-syms/xen.efi linking rules
Doing so, besides (hopefully) adding clarity (not the least by way of using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations. For xen-syms move re-usable helper rules to a new scripts/Makefile.link.
While doing so, re-order .map file creation (which can in principle fail) and check-endbr.sh invocation ahead of putting in place the final image (which is now the result of a simple rename).
Also drop --source-name= from the tools/symbols invocation which has --empty passed, for being meaningless there.
---
I'd like to keep the "beautification" part, i.e. transforming to more use of Kbuild.include machinery, separate.
The check-endbr.sh invocation doesn't fit neatly into this model. I was considering to move it into $(TARGET)'s rule, but that's not very nice either (both because it'd be odd [strictly speaking: wrong] for xen.efi, and because it would reduce parallelism).
---
v3: Drop stale part of description. Have $(final-image-check-y) use sites
pass in the intended argument. Drop leftover FORCE from xen.efi logic. Move $(obj)/efi/mkreloc dependency to correct rule.
v2: Mark intermediate files as such. Don't use $(if_changed ...).
xen/arch/x86/Makefile +63 -71
@@ -102,12 +102,6 @@ notes_phdrs = --notes endif endif -syms-warn-dup-y := --warn-dup -syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) := -syms-warn-dup-$(CONFIG_ENFORCE_UNIQUE_SYMBOLS) := --error-dup - -orphan-handling-$(call ld-option,--orphan-handling=warn) += --orphan-handling=warn - $(TARGET): TMP = $(dot-target).elf32 $(TARGET): $(TARGET)-syms $(efi-y) $(obj)/boot/mkelf32 $(obj)/boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TMP) $(XEN_IMG_OFFSET)
@@ -119,31 +113,11 @@ $(TARGET): $(TARGET)-syms $(efi-y) $(obj CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI -$(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(objtree)/tools/symbols $(all_symbols) --empty > $(dot-target).0.S - $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) --strip-debug \ - $(dot-target).0.o -o $(dot-target).0 - $(NM) -pa --format=sysv $(dot-target).0 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).1.S - $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) --strip-debug \ - $(dot-target).1.o -o $(dot-target).1 - $(NM) -pa --format=sysv $(dot-target).1 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ - > $(dot-target).2.S - $(MAKE) $(build)=$(@D) $(dot-target).2.o - $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o) - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(orphan-handling-y) $(dot-target).2.o -o $@ - $(NM) -pa --format=sysv $@ \ - | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ - > [email protected] - rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]* -ifeq ($(CONFIG_XEN_IBT),y) - $(SHELL) $(srctree)/tools/check-endbr.sh $@ -endif +LAST_LINKING_PASS := 2 + +final-image-check-$(CONFIG_XEN_IBT) = $(SHELL) $(srctree)/tools/check-endbr.sh $(1) + +include scripts/Makefile.link $(obj)/note.o: $(TARGET)-syms $(OBJCOPY) -O binary --only-section=.note.gnu.build-id $< [email protected]
@@ -191,51 +165,69 @@ note_file_option ?= $(note_file) extra-$(XEN_BUILD_PE) += efi.lds ifeq ($(XEN_BUILD_PE),y) -$(TARGET).efi: $(obj)/efi/relocs-dummy.o $(obj)/efi/relocs-empty.o $(obj)/efi/mkreloc -$(TARGET).efi: $(objtree)/prelink.o $(note_file) $(obj)/efi.lds + +.INTERMEDIATE: $(addprefix .$(TARGET).efi., \ + $(foreach n, 0 1 2, \ + $(n) alt.$(n) $(n)r.o $(n)s.o $(n)r.S $(n)s.S)) + +.$(TARGET).efi.%.o: .$(TARGET).efi.%.S + $(call cmd,cc_o_S) + +.$(TARGET).efi.1r.S: .$(TARGET).efi.0 $(if $(relocs-dummy),.$(TARGET).efi.alt.0) +.$(TARGET).efi.2r.S: .$(TARGET).efi.1 $(if $(relocs-dummy),.$(TARGET).efi.alt.1) + +.$(TARGET).efi.0r.o: $(obj)/efi/relocs-dummy.o + ln -sf $< $@ + +.$(TARGET).efi.%r.S: $(obj)/efi/mkreloc + $(MKRELOC) $(filter .$(TARGET).efi.%, $^) > $@ + +.$(TARGET).efi.0s.S: + $(objtree)/tools/symbols $(all_symbols) --empty > $@ + +.$(TARGET).efi.1s.S: .$(TARGET).efi.0 +.$(TARGET).efi.2s.S: .$(TARGET).efi.1 + +.$(TARGET).efi.%s.S: + $(NM) -pa --format=sysv $< \ + | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + --source-name=$(TARGET).efi.S \ + > $@ + +# See above for why $(note_file) needs removing here. +efi-objs = $(filter-out $(note_file),$(filter %.o,$^)) + +.$(TARGET).efi.%: $(objtree)/prelink.o .$(TARGET).efi.%r.o \ + .$(TARGET).efi.%s.o $(note_file) $(obj)/efi.lds + $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $(efi-objs) \ + --strip-debug $(note_file_option) -o $@ + +.$(TARGET).efi.alt.%: $(objtree)/prelink.o .$(TARGET).efi.%r.o \ + .$(TARGET).efi.%s.o $(note_file) $(obj)/efi.lds + $(LD) $(call EFI_LDFLAGS,$(ALT_BASE)) -T $(obj)/efi.lds $(efi-objs) \ + --strip-debug $(note_file_option) -o $@ + +.$(TARGET).efi.2: $(objtree)/prelink.o $(obj)/efi/relocs-empty.o \ + .$(TARGET).efi.2r.o .$(TARGET).efi.2s.o $(note_file) \ + $(obj)/efi.lds + $(call compare-symbol-tables, .$(TARGET).efi.1r.o, .$(TARGET).efi.2r.o) + $(call compare-symbol-tables, .$(TARGET).efi.1s.o, .$(TARGET).efi.2s.o) + $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $(efi-objs) \ + $(orphan-handling-y) $(note_file_option) -o $@ + +$(TARGET).efi: .$(TARGET).efi.2 ifeq ($(CONFIG_DEBUG_INFO),y) - $(if $(filter --strip-debug,$(EFI_LDFLAGS)),echo,:) "Will strip debug info from $(@F)" + $(if $(filter --strip-debug,$(EFI_LDFLAGS)),echo,:) "No debug info in $(@F)" endif - $(objtree)/tools/symbols $(all_symbols) --source-name=$(@F).S --empty \ - > $(dot-target).0s.S - $(MAKE) $(build)=$(@D) .$(@F).0s.o - $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ - $(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds $< $(relocs-dummy) \ - $(dot-target).0s.o $(note_file_option) --strip-debug \ - -o $(dot-target).$(base).0 &&) : - $(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(dot-target).$(base).0) \ - > $(dot-target).1r.S - $(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).0 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - --source-name=$(@F).S \ - > $(dot-target).1s.S - $(MAKE) $(build)=$(@D) .$(@F).1r.o .$(@F).1s.o - $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ - $(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds $< --strip-debug \ - $(dot-target).1r.o $(dot-target).1s.o $(note_file_option) \ - -o $(dot-target).$(base).1 &&) : - $(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(dot-target).$(base).1) \ - > $(dot-target).2r.S - $(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).1 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - --source-name=$(@F).S \ - > $(dot-target).2s.S - $(MAKE) $(build)=$(@D) .$(@F).2r.o .$(@F).2s.o - $(call compare-symbol-tables, $(dot-target).1r.o, $(dot-target).2r.o) - $(call compare-symbol-tables, $(dot-target).1s.o, $(dot-target).2s.o) - $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< $(obj)/efi/relocs-empty.o \ - $(dot-target).2r.o $(dot-target).2s.o $(orphan-handling-y) \ - $(note_file_option) -o $@ - $(NM) -pa --format=sysv $@ \ - | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ - > [email protected] + $(NM) -pa --format=sysv $< \ + | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ + > [email protected] ifeq ($(CONFIG_DEBUG_INFO),y) - $(if $(filter --strip-debug,$(EFI_LDFLAGS)),:$(space))$(OBJCOPY) -O elf64-x86-64 $@ [email protected] + $(if $(filter --strip-debug,$(EFI_LDFLAGS)),:$(space))$(OBJCOPY) -O elf64-x86-64 $< [email protected] endif + $(call final-image-check-y, $<) + mv $< $@ rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]* -ifeq ($(CONFIG_XEN_IBT),y) - $(SHELL) $(srctree)/tools/check-endbr.sh $@ -endif else $(TARGET).efi: FORCE rm -f $@
xen/scripts/Makefile.link new file +51 -0
51 lines not on this page · raw message
Re: [PATCH v3 1/6] x86: split xen-syms/xen.efi linking rules
Quoted 5 lines · Jan Beulich
Doing so, besides (hopefully) adding clarity (not the least by way of using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations. For xen-syms move re-usable helper rules to a new
scripts/Makefile.link.
Quoted 8 lines
While doing so, re-order .map file creation (which can in principle fail) and
check-endbr.shinvocation ahead of putting in place the final image (which is now the result of a simple rename).Also drop --source-name= from the
tools/symbolsinvocation which has --empty passed, for being meaningless there.Signed-off-by Jan Beulich <[email protected]>
Thanks,
--
Anthony Perard | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
PATCH v3 2/6 Arm: split xen-syms linking rule
In reply to Jan BeulichDoing so, besides (hopefully) adding clarity (not the least by way of [re-]using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations.
By re-using the generic rules introduced when the respective x86 rule was split,
- the .map file now isn't created after the final binary anymore,
- --strip-debug is passed to $(LD) during early linking passes (for consistency the option is also explicitly added to the optional linking pass rule),
- CONFIG_{SUPPRESS_DUPLICATE_SYMBOL_WARNINGS,ENFORCE_UNIQUE_SYMBOLS} are now properly respected.
Orphan section checking, otoh, is getting suppressed for now, until the about a dozen warnings which would result have been taken care of.
While the 4th linking step continues to be avoided when possible, a redundant invocation of $(NM) and tools/symbols (plus the assembling of the resulting .S file) is hopefully deemed acceptable.
---
As for the x86 patch, I'd like to keep the "beautification" part, i.e. transforming to more use of Kbuild.include machinery, separate.
xen/arch/arm/Makefile +6 -34
@@ -84,40 +84,12 @@ ifeq ($(CONFIG_ARM_64),y) ln -sf $(@F) [email protected] endif -$(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(objtree)/tools/symbols $(all_symbols) --empty > $(dot-target).0.S - $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).0.o -o $(dot-target).0 - $(NM) -pa --format=sysv $(dot-target).0 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).1.S - $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).1.o -o $(dot-target).1 - $(NM) -pa --format=sysv $(dot-target).1 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).2.S - $(MAKE) $(build)=$(@D) $(dot-target).2.o - if ! { $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o) >/dev/null; }; \ - then \ - set -e; \ - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).2.o -o $(dot-target).2; \ - $(NM) -pa --format=sysv $(dot-target).2 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).3.S; \ - $(MAKE) $(build)=$(@D) $(dot-target).3.o; \ - $(call compare-symbol-tables, $(dot-target).2.o, $(dot-target).3.o); \ - else \ - ln -sf $(dot-target).2.o $(dot-target).3.o; \ - fi - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).3.o -o $@ - $(NM) -pa --format=sysv $@ \ - | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ - > [email protected] - rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]* +LAST_LINKING_PASS := 3 + +include scripts/Makefile.link + +# Suppress orphan section checking for the time being. +orphan-handling-y := .PHONY: include include:
xen/scripts/Makefile.link +13 -0
@@ -33,6 +33,19 @@ final-image-check-y ?= true $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $(filter %.o,$^) \ $(build_id_linker) --strip-debug -o $@ +ifneq ($(LAST_LINKING_PASS),2) + +.$(TARGET)-syms.2: $(objtree)/prelink.o .$(TARGET)-syms.2.o $(obj)/xen.lds + if ! { $(call compare-symbol-tables, .$(TARGET)-syms.1.o, .$(TARGET)-syms.2.o) >/dev/null; }; \ + then \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $(filter %.o,$^) \ + $(build_id_linker) --strip-debug -o $@; \ + else \ + ln -sf .$(TARGET)-syms.1 $@; \ + fi + +endif + .$(TARGET)-syms.$(LAST_LINKING_PASS): $(objtree)/prelink.o \ .$(TARGET)-syms.$(LAST_LINKING_PASS).o \ $(obj)/xen.lds
Re: [PATCH v3 2/6] Arm: split xen-syms linking rule
Quoted 15 lines · Jan Beulich
Doing so, besides (hopefully) adding clarity (not the least by way of [re-]using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations.
By re-using the generic rules introduced when the respective x86 rule was split,
- the .map file now isn't created after the final binary anymore,
- --strip-debug is passed to $(LD) during early linking passes (for consistency the option is also explicitly added to the optional linking pass rule),
- CONFIG_{SUPPRESS_DUPLICATE_SYMBOL_WARNINGS,ENFORCE_UNIQUE_SYMBOLS} are now properly respected.
Orphan section checking, otoh, is getting suppressed for now, until the about a dozen warnings which would result have been taken care of.
Quoted 6 lines
While the 4th linking step continues to be avoided when possible, a redundant invocation of $(NM) and
tools/symbols(plus the assembling of the resulting .S file) is hopefully deemed acceptable.Signed-off-by Jan Beulich <[email protected]>Reviewed-by Anthony PERARD <[email protected]>
~Michal
Re: [PATCH v3 2/6] Arm: split xen-syms linking rule
In reply to Jan BeulichQuoted 4 lines · Jan Beulich
Doing so, besides (hopefully) adding clarity (not the least by way of [re-]using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations.
Quoted 10 lines
By re-using the generic rules introduced when the respective x86 rule was split,
- the .map file now isn't created after the final binary anymore,
- --strip-debug is passed to $(LD) during early linking passes (for consistency the option is also explicitly added to the optional linking pass rule),
- CONFIG_{SUPPRESS_DUPLICATE_SYMBOL_WARNINGS,ENFORCE_UNIQUE_SYMBOLS} are now properly respected.
Orphan section checking, otoh, is getting suppressed for now, until the about a dozen warnings which would result have been taken care of.
Similarly, for randconfig, I had to suppress ENFORCE_UNIQUE_SYMBOLS=y for the time being, with the incremental patch below. I'm about to submit a patch to undo that (by first fixing the collisions).
As per
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2870284545
the issues were:
Arm64:
Duplicate symbol 'head.o#fail' (a0000200544 != a0000200178)
Arm32:
Duplicate symbol 'head.o#fail' (200178 != 200650)
Jan
xen/arch/arm/Makefile +3 -0
@@ -91,6 +91,9 @@ include scripts/Makefile.link # Suppress orphan section checking for the time being. orphan-handling-y := +# Downgrade duplicate symbol errors to warnings for the time being. +syms-warn-dup-$(CONFIG_ENFORCE_UNIQUE_SYMBOLS) := --warn-dup + .PHONY: include include:
PATCH v3 3/6 RISC-V: split xen-syms linking rule
In reply to Jan BeulichDoing so, besides (hopefully) adding clarity (not the least by way of [re-]using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations.
By re-using the generic rules introduced when the respective x86 rule was split,
- the .map file now isn't created after the final binary anymore,
- --strip-debug is passed to $(LD) during early linking passes (for consistency the option is also explicitly added to the optional linking pass rule),
- CONFIG_{SUPPRESS_DUPLICATE_SYMBOL_WARNINGS,ENFORCE_UNIQUE_SYMBOLS} are now properly respected.
Orphan section checking, otoh, is getting suppressed for now, until the about a dozen warnings which would result have been taken care of.
While the 4th linking step continues to be avoided when possible, a redundant invocation of $(NM) and tools/symbols (plus the assembling of the resulting .S file) is hopefully deemed acceptable.
xen/arch/riscv/Makefile +6 -34
@@ -31,40 +31,12 @@ obj-y += vtimer.o $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ -$(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(objtree)/tools/symbols $(all_symbols) --empty > $(dot-target).0.S - $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).0.o -o $(dot-target).0 - $(NM) -pa --format=sysv $(dot-target).0 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).1.S - $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).1.o -o $(dot-target).1 - $(NM) -pa --format=sysv $(dot-target).1 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).2.S - $(MAKE) $(build)=$(@D) $(dot-target).2.o - if ! { $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o) >/dev/null; }; \ - then \ - set -e; \ - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).2.o -o $(dot-target).2; \ - $(NM) -pa --format=sysv $(dot-target).2 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).3.S; \ - $(MAKE) $(build)=$(@D) $(dot-target).3.o; \ - $(call compare-symbol-tables, $(dot-target).2.o, $(dot-target).3.o); \ - else \ - ln -sf $(dot-target).2.o $(dot-target).3.o; \ - fi - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).3.o -o $@ - $(NM) -pa --format=sysv $@ \ - | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ - > [email protected] - rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]* +LAST_LINKING_PASS := 3 + +include scripts/Makefile.link + +# Suppress orphan section checking for the time being. +orphan-handling-y := $(obj)/xen.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S)
PATCH v3 4/6 PPC: split xen-syms linking rule
In reply to Jan BeulichDoing so, besides (hopefully) adding clarity (not the least by way of [re-]using pattern rules where possible), also avoids explicit recursive $(MAKE) invocations.
By re-using the generic rules introduced when the respective x86 rule was split,
- the .map file now isn't created after the final binary anymore,
- --strip-debug is passed to $(LD) during early linking passes (for consistency the option is also explicitly added to the optional linking pass rule),
- CONFIG_{SUPPRESS_DUPLICATE_SYMBOL_WARNINGS,ENFORCE_UNIQUE_SYMBOLS} are now properly respected.
Orphan section checking, otoh, is getting suppressed for now, until the about a dozen warnings which would result have been taken care of.
xen/arch/ppc/Makefile +6 -22
@@ -11,28 +11,12 @@ obj-y += tlb-radix.o $(TARGET): $(TARGET)-syms cp -f $< $@ -$(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(objtree)/tools/symbols $(all_symbols) --empty > $(dot-target).0.S - $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).0.o -o $(dot-target).0 - $(NM) -pa --format=sysv $(dot-target).0 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).1.S - $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).1.o -o $(dot-target).1 - $(NM) -pa --format=sysv $(dot-target).1 \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ - > $(dot-target).2.S - $(MAKE) $(build)=$(@D) $(dot-target).2.o - $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o) - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).2.o -o $@ - $(NM) -pa --format=sysv $@ \ - | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ - > [email protected] - rm -f $(dot-target).[0-9]* $(@D)/..$(@F).[0-9]* +LAST_LINKING_PASS := 2 + +include scripts/Makefile.link + +# Suppress orphan section checking for the time being. +orphan-handling-y := $(obj)/xen.lds: $(src)/xen.lds.S FORCE $(call if_changed_dep,cpp_lds_S)
PATCH v3 5/6 build: move $(all-symbols-*)
In reply to Jan BeulichWith the final linking logic now consolidated in scripts/Makefile.link, $(all-symbols-*) also doesn't need setting anymore in (and passing down from) the top level Makefile.
xen/Makefile +1 -6
@@ -465,10 +465,6 @@ ALL_OBJS-$(CONFIG_CRYPTO) += crypto/buil ARCH_LIBS-y := ALL_LIBS-y := lib/lib.a -all-symbols-y := -all-symbols-$(CONFIG_LIVEPATCH) += --all-symbols -all-symbols-$(CONFIG_FAST_SYMBOL_LOOKUP) += --sort-by-name - include $(srctree)/arch/$(SRCARCH)/arch.mk # define new variables to avoid the ones defined in Config.mk
@@ -622,8 +618,7 @@ $(TARGET): outputmakefile asm-generic FO $(Q)$(MAKE) $(build)=arch/$(SRCARCH) include $(Q)$(MAKE) $(build)=. arch/$(SRCARCH)/include/asm/asm-offsets.h $(Q)$(MAKE) $(build)=. MKRELOC=$(MKRELOC) 'ALL_OBJS=$(ALL_OBJS-y)' \ - 'ALL_LIBS=$(ARCH_LIBS-y) $(ALL_LIBS-y)' \ - 'all_symbols=$(all-symbols-y)' $@ + 'ALL_LIBS=$(ARCH_LIBS-y) $(ALL_LIBS-y)' $@ SUBDIRS = xsm arch common crypto drivers lib test define all_sources
xen/arch/x86/Makefile +2 -2
@@ -183,14 +183,14 @@ ifeq ($(XEN_BUILD_PE),y) $(MKRELOC) $(filter .$(TARGET).efi.%, $^) > $@ .$(TARGET).efi.0s.S: - $(objtree)/tools/symbols $(all_symbols) --empty > $@ + $(objtree)/tools/symbols $(all-symbols-y) --empty > $@ .$(TARGET).efi.1s.S: .$(TARGET).efi.0 .$(TARGET).efi.2s.S: .$(TARGET).efi.1 .$(TARGET).efi.%s.S: $(NM) -pa --format=sysv $< \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + | $(objtree)/tools/symbols $(all-symbols-y) --sysv --sort \ --source-name=$(TARGET).efi.S \ > $@
xen/scripts/Makefile.link +6 -2
@@ -3,6 +3,10 @@ # Helper rules for linking xen-syms # ========================================================================== +all-symbols-y := +all-symbols-$(CONFIG_LIVEPATCH) += --all-symbols +all-symbols-$(CONFIG_FAST_SYMBOL_LOOKUP) += --sort-by-name + syms-warn-dup-y := --warn-dup syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) := syms-warn-dup-$(CONFIG_ENFORCE_UNIQUE_SYMBOLS) := --error-dup
@@ -17,7 +21,7 @@ final-image-check-y ?= true $(call cmd,cc_o_S) .$(TARGET)-syms.0.S: - $(objtree)/tools/symbols $(all_symbols) --empty > $@ + $(objtree)/tools/symbols $(all-symbols-y) --empty > $@ .$(TARGET)-syms.1.S: .$(TARGET)-syms.0 .$(TARGET)-syms.2.S: .$(TARGET)-syms.1
@@ -25,7 +29,7 @@ final-image-check-y ?= true .$(TARGET)-syms.%.S: $(NM) -pa --format=sysv $< \ - | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + | $(objtree)/tools/symbols $(all-symbols-y) --sysv --sort \ $(if $(filter $(LAST_LINKING_PASS),$*), $(syms-warn-dup-y)) \ > $@
PATCH v3 6/6 build: move $(compare-symbol-tables)
In reply to Jan BeulichWith the final linking logic now consolidated in scripts/Makefile.link, $(compare-symbol-tables) also doesn't need setting anymore in Kbuild.include.
---
v2: New.
xen/scripts/Kbuild.include +0 -13
@@ -56,19 +56,6 @@ define filechk fi endef -### -# Compare the symbol tables of two object files. As diff's -I option isn't -# standardized, the name difference of the two object files needs abstracting -# out. -define compare-symbol-tables - ln -f $(1) $(@D)/.cst.$$$$; \ - $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(1).sym; \ - ln -f $(2) $(@D)/.cst.$$$$; \ - $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(2).sym; \ - rm -f $(@D)/.cst.$$$$; \ - diff -u $(1).sym $(2).sym -endef - # as-insn: Check whether assembler supports an instruction. # Usage: cflags-y += $(call as-insn,CC FLAGS,"insn",option-yes,option-no) as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \
xen/scripts/Makefile.link +12 -0
@@ -33,6 +33,18 @@ final-image-check-y ?= true $(if $(filter $(LAST_LINKING_PASS),$*), $(syms-warn-dup-y)) \ > $@ +# Compare the symbol tables of two object files. As diff's -I option isn't +# standardized, the name difference of the two object files needs abstracting +# out. +define compare-symbol-tables + ln -f $(1) $(@D)/.cst.$$$$; \ + $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(1).sym; \ + ln -f $(2) $(@D)/.cst.$$$$; \ + $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(2).sym; \ + rm -f $(@D)/.cst.$$$$; \ + diff -u $(1).sym $(2).sym +endef + .$(TARGET)-syms.%: $(objtree)/prelink.o .$(TARGET)-syms.%.o $(obj)/xen.lds $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $(filter %.o,$^) \ $(build_id_linker) --strip-debug -o $@