[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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Tue, 9 Dec 2025 16:55:27 -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=ljPcFsM1w6z3CzY33a53vnO6kqU6x5YfFzdVBmB98a4=; b=Qy+5L8wbIYWCAGVBwBuVZogGJbYoL/5/E3p9DP+LgmW/7fBSMF6tS9OpocsoJepjJMO9dIID/K0jaS57VHtuUMZvefHrUfS/KYFS1k98bK7PekNCdmIjIgax3b35Brl0mHei4vAju4HVaeVqXExkVGBoqqPB0z457ExuemmD89D6Ei28azChzIKRyn72QdZ/QouFuTvqNveP2m6QeaNDnxX1ViPtFvFneQ2CvQIDVBAGzAJyD0ZAm4u8qf98hp3jWxn8aLo9ipSbjQtD6CV59BcurehxE5X3IPcREbLvrw3CL5J/Eg2kPMwTllVEzQ2sFu+9Ep5US6pHoSV07uwXng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wOpIMYflyva+HnDTm+iyy9PeIAThhHikZB4uytRQbQLZikwb+5xzPHqhTuSZqW/iWG6HGOav4YcNiQzbPw1hHo/kz/lfxDr6UchPDmcb4kGx/ZhvCVKAcnPtstGEnmuNbcn0c3pnQJ5ZZx9zXyOPUWxOYhohM5SVQ8/pnrMrWb2j2UrG7AOIR7zwiaG31ma0KZGbe/CIwdbKVzViV4ZWqVodwKcIK/W7wen58d1nbhCB9XXZ4MnradugBr45ocwIRgq1g48u8UgG2QPkajJ8dHqqv0o7lVg2Ko9uLcd87VD22E64jpYSS1fkUfTuuL+Ootd8trVSJ1Y64pyUnWLziw==
  • 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>
  • Delivery-date: Tue, 09 Dec 2025 21:55:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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?

Regards,
Jason



 


Rackspace

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