diff --git a/xen/arch/x86/boot/mkelf32.c b/xen/arch/x86/boot/mkelf32.c index bcbde1a056..3d639c2e08 100644 --- 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", diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 68501c7186..6e4abbc1ce 100644 --- 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