All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/build: make linking work again with ld incapable of generating build ID
@ 2022-04-21 10:40 Jan Beulich
  2022-04-21 10:46 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2022-04-21 10:40 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Roger Pau Monné

The retaining of .note.* in a PT_NOTE segment requires a matching
program header to be present in the first place. Drop the respective
conditional and adjust mkelf32 to deal with (ignore) the potentially
present but empty extra segment (but have the new code be generic by
dropping any excess trailing entirely empty segments).

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

--- a/xen/arch/x86/boot/mkelf32.c
+++ b/xen/arch/x86/boot/mkelf32.c
@@ -320,6 +320,19 @@ int main(int argc, char **argv)
                 (int)in64_ehdr.e_phentsize, (int)sizeof(in64_phdr));
         return 1;
     }
+
+    /* Ignore entirely empty trailing program headers. */
+    while ( in64_ehdr.e_phnum > num_phdrs )
+    {
+        (void)lseek(infd,
+                    in64_ehdr.e_phoff + in64_ehdr.e_phnum * sizeof(in64_phdr),
+                    SEEK_SET);
+        do_read(infd, &in64_phdr, sizeof(in64_phdr));
+        endianadjust_phdr64(&in64_phdr);
+        if ( in64_phdr.p_memsz )
+            break;
+        --in64_ehdr.e_phnum;
+    }
     if ( in64_ehdr.e_phnum != num_phdrs )
     {
         fprintf(stderr, "Expect precisly %d program header; found %d.\n",
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -40,9 +40,7 @@ OUTPUT_ARCH(i386:x86-64)
 PHDRS
 {
   text PT_LOAD ;
-#if defined(BUILD_ID) || defined(CONFIG_PVH_GUEST)
   note PT_NOTE ;
-#endif
 }
 #define PHDR(x) :x
 #else



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/build: make linking work again with ld incapable of generating build ID
  2022-04-21 10:40 [PATCH] x86/build: make linking work again with ld incapable of generating build ID Jan Beulich
@ 2022-04-21 10:46 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2022-04-21 10:46 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Wei Liu, Roger Pau Monne

On 21/04/2022 11:40, Jan Beulich wrote:
> The retaining of .note.* in a PT_NOTE segment requires a matching
> program header to be present in the first place. Drop the respective
> conditional and adjust mkelf32 to deal with (ignore) the potentially
> present but empty extra segment (but have the new code be generic by
> dropping any excess trailing entirely empty segments).
>
> Fixes: dedb0aa42c6d ("x86/build: use --orphan-handling linker option if available")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-21 10:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 10:40 [PATCH] x86/build: make linking work again with ld incapable of generating build ID Jan Beulich
2022-04-21 10:46 ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.