[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] RFC: xen/x86: Enable --gc-sections


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 8 Dec 2025 18:00:35 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1n+5BTEIBK43FX2PyPfouKdwJV5ikhIWV/5npraqfv4=; b=GFY0w9pqCqyy3m4PA2BCB9ZOu5cPAjXjxcDmQ/MvNZzlqOgDM5V1rfDjPHvqDNI1MivECpIQwMRUEzLgt2VldsNemesTO0un+jBcEVt/5LlTGlSyrd2j9m7LyJr/gXzjaSJNy1ov9G4od4MgkZ/JJuO3ArgWnMwLWo7Lpbazl6EYNmG3hDFDUmCVi7nRCwNmEiJkjZpJVyLqxndYuw4SRqYvFAfxHQImptxO2UfrjvBoK+7u0vFJwqf9ahVknGP6DcNi9J6LBQt734VYPVwexBhJcqBcWOj/JHvlGDF01uPx/SlyBWV3GPVM8QvEWBLB75QTRtstzUcVLTIJMUc7hg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nVHoineSCpGhZmWYIj7Z+zT0TeRHQ3EapA7kWEkli3LbEt/YgeE2yVCXUKJNJYk8RqTsGOx6OiZd7Iif39y79ubeuaKwVQSKNd1lMxpRFiMr2JhGOgk8ttoIFCENaOiDmT7wmpok9MGEz78ZnnP0NoN/2g5cCMAH7aA0/CYVTvxNIX/UF1cG0ITmkx81cIcFEF7hK6773bzJKcHZrjYEO2BUS4oZVuSg6NMJ11mnn9GIvVoqtxo7ICe6iZiYC8hKN1wP3GlTvKvVSbq896AzX2vZO4lI78yVn5+WeYph3rpbJq+vV5fw7xLJZefAgkOczkfGDXUdq9HbYD/WXIJLGQ==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Grygorii Strashko" <grygorii_strashko@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 08 Dec 2025 23:01:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-12-08 03:56, Jan Beulich wrote:
On 05.12.2025 23:28, Jason Andryuk wrote:
When linking to create xen-syms, add --gc-sections to garbage collect
unused stuff.

What about xen.efi?

I tried briefly and it fails to link. The GCC manual says it is considered experimental for PE and COFF.

I just added into EFI_LDFLAGS:
  CC      .xen.efi.0s.o
ld -mi386pep --no-warn-rwx-segments --subsystem=10 --enable-long-section-names --disable-high-entropy-va --dynamicbase --image-base=0xffff82d040000000 --stack=0,0 --heap=0,0 --section-alignment=0x200000 --file-alignment=0x20 --major-image-version=4 --minor-image-version=22 --major-os-version=2 --minor-os-version=0 --major-subsystem-version=2 --minor-subsystem-version=0 --gc-sections --print-gc-sections --build-id=sha1 -T arch/x86/efi.lds prelink.o ./.xen.efi.0s.o -b pe-x86-64 arch/x86/efi/buildid.o -o ./.xen.efi.0xffff82d040000000.0 && :
ld: kexec_reloc is too large
ld: kexec_reloc is too large
ld: prelink.o:/home/jandryuk/xen/xen/arch/x86/boot/head.S:60:(.text.header+0x48): undefined reference to `start'


  Relies on CONFIG_CC_SPLIT_SECTIONS

Yet still ...

--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -137,18 +137,21 @@ $(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) \
+             --gc-sections \

... you pass the option unconditionally. Which may be fine from a functional
perspective (little if anything will be saved), but besides being a little
inconsistent with the description I also wonder whether the option won't have
unwanted side effects (longer linking time, bigger working set).

              $(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) \
+             --gc-sections \
            $(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
        $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \
+             --gc-sections \
            $(orphan-handling-y) $(dot-target).2.o -o $@
        $(NM) -pa --format=sysv $@ \

Rather than having to alter three locations (plus another three for xen.efi,
plus another three for every other architecture that would want to follow
suit), should we perhaps introduce $(XEN_FINAL_LDFLAGS) or some such? That
could then have --gc-sections conditionally upon CONFIG_CC_SPLIT_SECTIONS.

Yes, I thought something like thiat would be better after posting.

I further wonder whether the use of the option wouldn't want gating by its
own Kconfig control (dependent upon CC_SPLIT_SECTIONS). If nothing else than
to have an easy workaround if either we had a usage bug (e.g. a missing
KEEP() somewhere in a linker script) or there was a related bug in the
linker that we end up being affected by.
Makes sense.

Thanks,
Jason



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.