From a2b8da2574586270207c6eb8e7aa8cd19eb74947 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 22 Mar 2022 13:10:59 +0100 Subject: [PATCH] x86/build: work around older GNU ld not leaving .got.plt empty MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The initial three entries in .got.plt are "static", i.e. present independent of actual entries allocation of which is triggered by respective relocations. When no real entries are needed, halfway recent ld discards the "static" portion of the table as well, but older GNU ld fails to do so. Fixes: dedb0aa42c6d ("x86/build: use --orphan-handling linker option if available") Reported-by: Julien Grall Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Tested-by: Julien Grall --- xen/arch/x86/xen.lds.S | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index d33e295320..db2aaf7781 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -497,7 +497,13 @@ ASSERT(IS_ALIGNED(__bss_end, 8), "__bss_end misaligned") #ifndef EFI ASSERT(!SIZEOF(.got), ".got non-empty") -ASSERT(!SIZEOF(.got.plt), ".got.plt non-empty") +/* + * At least GNU ld 2.30 and earlier fail to discard the generic part of + * .got.plt when no actual entries were allocated. Permit this case alongside + * the section being empty. + */ +ASSERT(!SIZEOF(.got.plt) || SIZEOF(.got.plt) == 3 * 8, + "unexpected .got.plt size") ASSERT(!SIZEOF(.igot.plt), ".igot.plt non-empty") ASSERT(!SIZEOF(.iplt), ".iplt non-empty") ASSERT(!SIZEOF(.plt), ".plt non-empty") -- 2.30.2