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

Re: [PATCH v2] Arm: do a 4th linking pass if necessary


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 21 May 2026 16:42:05 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=suse.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=fail (48)
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=+SdlPMyloHC0VrrtOvIDK8uAYHwMZWx5pkK7oS8qsZM=; b=kNtXzW+offceVo1Mf3lujNsRJXruNib79kQFrpdVxdWVCIaeGpI7mD+F5ui7WZNLL8Q/fVGIHLJNYLsi/51tVPdNyOp2NbS1W/6FBBXqWg1pP92WFDyrI/u4K+/IAMPlNnacxicpzxVmomZM3SEgGS9K4yqX90e32lqNTLnrmitrlZ8EDBQTf2yRfl15rS0s+ELdPUFRz/Lip0ulOuwXvUPsV0FIxsRY5sNBj9+aEwJbZoOgOl+VnRY2C1aGjPaGDqx4pv4sAnZe1UvOita/Agf1VokvetENoY6pAs6OZnO5K8rfR6ohnBng8/isuf/gr+11F2HwlI4pXf63hs+lbQ==
  • 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=+SdlPMyloHC0VrrtOvIDK8uAYHwMZWx5pkK7oS8qsZM=; b=C2bk5ZPLuuyE4nwsafFgQJI/3zNY0Lq4bZ3Ko83ouTaICy3v3nLAT0wqfnwM9ylwzNZ2UGrpXwGElFzfkz4ICwQ1TaIHtVsTTtMo9We6uGe9GDwUEqdGkr2J/O9RC/m+PaDryfRxXG5zQw786TG+MjSFiGxvEHWDJftIkEZYZqqXkIvMss0SaKtvZh6x2UHTULsUHxLxiUG6gwxjiCkFV5Z1+cl8SByfRbdyxf8SdNOg5ALdB7anOTGtNp7umyeY3hB0a3jD28/IZXxhBIq5v8yPffag4Ca8R0NvFXmR7pOxl0KGI5NQKU0GM6jW9EVxn2geKiuW5fDo/wBkbDKq8Q==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=fail; b=Ywx4axVu1ee8yeBk/f5u4CKMJ2PbqH+JX7w8jD0+AqlQ6PcSUc/q1wQ7pcbL1IPrAOecDfM3LICCXj5u4sYTb2jerlG3QFBaPK3vPdRif31lutdUJeSMPcO8dQwXTQ+RnWqXoC2irWYYSq4ngJGppELKLgnIhsq8Vr+yLXCAXk1cXJhoU6dceugoWBmquV3HV9wtDNK+2yxHSPBtnAdp9HGCpcRPMzlotn3xtg/V+tqBcajtAhJJCTs9faHpGLcRecuxzfqod2GDcHnSQZB4mqdcoAn6vf/lGNjS8CAI2pfVdoWip18Ib5GDxv7IowNRHYe1PDnJUpwRaZ1Ntj58ZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T7eMa4dGjP0mCEGT93/SknJc80pcAdggzAd+Al+jhnA2hRKEqtpEGlRhfe0Ha7ezUgmV+i8zGe0tWLvMNETuooFHTnbTeQe5rS9+cbEeAYUzxmrtNxVvh3i43nxpD8EEgqrHGZTdRMiYiYukNI0ZZ7LcS+6cpdBb1aQqVLnn1ESjUNzv0hyFP5sz8BIgyVLRe5ps05UudMYcr6eF7RXwtKcrxxoJBfQvSL8LbctSXbu1T565/Umo6NSxDEkut9sl7wc2xvzUdQKuHX6Mae4zNKD8vTC/0hUg5iTYv9AB6bI7pfs5bbryfQgCMxkrVtvjSBSW4OJEupwyCJHBaRE2qA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
  • Delivery-date: Thu, 21 May 2026 16:43:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHc6RnGu1utUAlrJk+sIf0YXyTZG7YYr0OA
  • Thread-topic: [PATCH v2] Arm: do a 4th linking pass if necessary

Hi Jan,

> On 21 May 2026, at 14:02, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> The .rodata growth between 1st and 2nd linking passes may affect the
> number of stubs the linker wants to insert, which in turn affects the
> number of symbols. If symbol table sizes change after the 2nd linking
> pass, insert another one before the final one. (As a comment in Linux puts
> it, "In theory it's possible this results in even more stubs, but
> unlikely.")
> 
> To use the $(compare-symbol-tables) macro in a shell "if", it needs
> slightly adjusting (and then wrapping to be run in a sub-shell).
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>

Cheers
Bertrand

> ---
> There's imo no good Fixes: tag, since (aiui) stubs (veneers) may also be
> inserted for reasons other than errata workarounds.
> 
> For context: The Cortex A53 erratum 843419 workaround in GNU ld comes in
> two flavors: In the general case a stub is inserted, but if the problem
> ADRP can be replaced by ADR (i.e. the target symbol is within ±1Mb), then
> that's preferred and no stub is needed. The addition of the symbol table
> data is what then results in the stub-less form to no longer be usable in
> affected configurations. A possible countermeasure could be to move
> .rodata ahead of .text. (Also, from looking at generated code, it may well
> be that newer gcc simply avoids producing problematic insn sequences.)
> 
> Linux simply compares object file sizes, but I consider that fragile: A
> change in size of one of the symbol table constituents may not necessarily
> change the object file size, due to padding which may be in use.
> 
> Once we generalize linking, we may want to introduce an equivalent of
> Linux'es KALLSYMS_EXTRA_PASS as well. I don't think doing this right here
> would make overly much sense, though.
> ---
> v2: Add "set -e".
> 
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -99,9 +99,21 @@ $(TARGET)-syms: $(objtree)/prelink.o $(o
> | $(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)
> + 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).2.o -o $@
> +    $(dot-target).3.o -o $@
> $(NM) -pa --format=sysv $@ \
> | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \
> > $@.map
> --- a/xen/scripts/Kbuild.include
> +++ b/xen/scripts/Kbuild.include
> @@ -65,7 +65,7 @@ define compare-symbol-tables
>     $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(1).sym; \
>     ln -f $(2) $(@D)/.cst.$$$$; \
>     $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(2).sym; \
> -    rm -f $(@D)/.cst.$$$$
> +    rm -f $(@D)/.cst.$$$$; \
>     diff -u $(1).sym $(2).sym
> endef
> 


 


Rackspace

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