Skip to contentSkip to conversation

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

PATCH In review Jan Beulich 3 participants 4 messages Mar 21, 2022

lore
Share & tools
lore
#0 lore raw

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

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")
xen/arch/x86/xen.lds.S +7 -1
@@ -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")
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

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?

Quoted 3 lines
Fixes dedb0aa42c6d ("x86/build: use --orphan-handling linker option if available")

Thanks, Roger.

#2 lore raw
Quoted 8 lines · Roger Pau Monné
Quoted 5 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 3 lines
Fixes dedb0aa42c6d ("x86/build: use --orphan-handling linker option if available")

Thanks.

Jan

Tested-by on v1 1/1
#3 lore raw
In reply to Jan Beulich

Hi Jan,

Quoted 9 lines · Jan Beulich

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")

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

Cheers,

Signature · 1 line
Julien Grall