diff mbox series

x86/build: work around older GNU ld not leaving .got.plt empty

Message ID 057172d5-437a-347b-b5bb-d102b6b37f0a@suse.com (mailing list archive)
State New, archived
Headers show
Series x86/build: work around older GNU ld not leaving .got.plt empty | expand

Commit Message

Jan Beulich March 21, 2022, 11:46 a.m. UTC
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 <jgrall@amazon.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Roger Pau Monné March 21, 2022, 11:57 a.m. UTC | #1
On Mon, Mar 21, 2022 at 12:46:54PM +0100, Jan Beulich wrote:
> 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.

Do you know what this 'static' entries refer to?

> Fixes: dedb0aa42c6d ("x86/build: use --orphan-handling linker option if available")
> Reported-by: Julien Grall <jgrall@amazon.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.
Jan Beulich March 21, 2022, 12:18 p.m. UTC | #2
On 21.03.2022 12:57, Roger Pau Monné wrote:
> On Mon, Mar 21, 2022 at 12:46:54PM +0100, Jan Beulich wrote:
>> 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.
> 
> Do you know what this 'static' entries refer to?

I didn't take the time to look this up, and I don't know off the top of
my head.

>> Fixes: dedb0aa42c6d ("x86/build: use --orphan-handling linker option if available")
>> Reported-by: Julien Grall <jgrall@amazon.com>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks.

Jan
Julien Grall March 21, 2022, 1:12 p.m. UTC | #3
Hi Jan,

On 21/03/2022 11:46, Jan Beulich wrote:
> 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 <jgrall@amazon.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Thanks for the patch. I applied the patch and can confirm the build 
issue is gone.

Tested-by: Julien Grall <jgrall@amazon.com>

Cheers,
diff mbox series

Patch

--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -497,7 +497,13 @@  ASSERT(IS_ALIGNED(__bss_end,        8),
 
 #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")