[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: Wed, 10 Dec 2025 10:01:05 -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=8HdBSoDWVoCeGNZL9em0WXTbkxGGql0y7gGYJFwfo+s=; b=FUKBE2icICzbURkEDuHauFi+EoOVUmHVrDucMniVVHlTT6MzmGXGTgiCN3b6OHdmSeIceuf7saRCE+gh4YOuu5G31Gjsl3YiltPvMauSal8nmNw2RTP0usY1oZ143E1krh/6EIVXPSwiSHScKnh6hN3Eq+Be8B7zRljXGSPOnJcE9h/8d9ApLXYWd90tbLT9gpzeTMJHC0WgwFcpjs8YqyzjYulBInLYmPzuEiW7lkb87RL25HZRvuTYKivhHR3jNS8xXDyDR5hJsON8KFwLvVfGQewWwS4NeF/VteikqkBlXBe7TfF1HnnmF0/pt5z+I03pV0fhoGXqVOtXHn7ZKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vNcm3scEVGQcpEMuXKvxhVwFOz2MefadcV/LSZTNJJGQm4XXfWahzJaiHOczNyHk0xCV44ymDr7qiF1XqYdCY65mNOevjNCQcSmcGSQfKeszm5OrKzDdn8YBaUc7hH+KH0DYdH0G53SqMWfcXSpLk/kS2Jkri5sLjRRUBTWp6/Ldh9CttwWfEsf6LtnOFJTPfsl12rJqq0yBn1rPDzZFA0xbz+hiWabeItgrYLS/lGGfIb30jGZ2tDrzAbkOc20lyHd5xI4IAjh1viOWbFHiU/mPCNPkwzkZPblgGY4w0DiMy6WN8guDHeETalVlmEJV8jKEEgt/L3EJp5PURLTZpw==
  • Cc: 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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 10 Dec 2025 15:01:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-12-10 02:09, Jan Beulich wrote:
On 09.12.2025 22:55, Jason Andryuk wrote:
On 2025-12-08 03:46, Jan Beulich wrote:
On 05.12.2025 23:40, Andrew Cooper wrote:
On 05/12/2025 10:28 pm, Jason Andryuk wrote:
When linking to create xen-syms, add --gc-sections to garbage collect
unused stuff.  Relies on CONFIG_CC_SPLIT_SECTIONS

We need to add KEEP() to the linker script in assorted places to retain
appropriate data - especially the arrays created therein.

Something is off though.  In a test where memory_add() is unreachable,
it is still included.  I'm not sure, but I am wondering if it's the
alternatives somehow keeping a reference to it.

Yes, .altinstructions contains relocations against the origin patch
site, which will cause it to appear to be referenced. The same will be
happening with a bunch of other sections.

We will need to derive helper section names from base section ones. See
e.g. HAVE_AS_SECTNAME_SUBST as introduced by "common: honor
CONFIG_CC_SPLIT_SECTIONS also for assembly functions", controlling the
use of the --sectname-subst asssembler option, to in turn be able to use
%S in section names (available from gas 2.26 onwards).

I tried to add your patch and change ALTERNATIVE to:
".pushsection .altinstructions.%S, \"a\", @progbits\n"
but it fails to build.  One example:
./include/xen/compiler.h:62:21: error: invalid 'asm': operand number
missing after %-letter
     62 | # define asm_inline asm __inline
        |                     ^~~
./arch/x86/include/asm/pdx.h:13:5: note: in expansion of macro ‘asm_inline’
     13 |     asm_inline goto (                               \
        |     ^~~~~~~~~~
./arch/x86/include/asm/pdx.h:22:5: note: in expansion of macro
‘PDX_ASM_GOTO’
     22 |     PDX_ASM_GOTO(skip);
        |     ^~~~~~~~~~~~

".pushsection .altinstructions.%%S, \"a\", @progbits\n" ends up creating
section ".altinstructions.%S" which doesn't helpful.

Is %S expected to work with inline asm, or only standalone?

Both, as long as --sectname-subst is passed to the assembler. My patch adds
that option to AFLAGS only, whereas for inline assembly it would need adding
to CFLAGS. Did you perhaps overlook that?

Yes, you are correct - I had not changed CFLAGS. With that updated, the %%S form creates sections:
.altinstructions..text.set_domain_state_info

Thanks,
Jason



 


Rackspace

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