[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/3] x86/build: Rework binary conversion for boot/{cmdline,reloc}.c


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 20 Apr 2022 12:15:04 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5m3438VyS9HHNrGeG1RmloZAWK7+eBdkG3jaGsrzOzk=; b=gRWr5WxxC9VqjMYPPLlHx14Lskymw9dEzdchv+aklZ28qBUDkD+JIGbROtAYqKD5HbxBVrfNUT7tyTLpp6Uv2peR4cBj4tu5TyTHfp92Fm6KPuL5rqIWLASrSD2XwD5NQjbKwNOGMkP8MHY3bnfp+X2CKVozxv5JP7YBqJ9Vyui0aV7B17h05RIm+mBfhj2mp/6kl+fp+F4ZSKKXTju4CKVi9WBjrrnhX/hGEKWm4Ugkrb//VJPu2ITWFOl15wNgHCfJ3swra1VVHBkfeCVlUWIBWagEwhFFeWGrfCR3JpE9QZK7YUcexBB5opxYB6e8XkcnTyaQCOFqpZNI8kMaig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XMB66/Wh3+E83wOn9L4CizyRyYKXTcCD2SGwLRSUl6TAXmVDgiKdtvgTRlrEjnx8dbZ2HxS7pIsMbioD67CVvMKRf17nE6M7QnLf9fb+ug19Cm9q+lZcKdFohZRoPZCRBls0qN6dP9EM+QvPQD6zN4wxGKra5RXIluZwZVjQzQD/WopcgEq/TJmznm9xjaEpOV5z+uJgeXV7g7stPWVC18AKWUg/OiSkOvY3fUjV4ee7muSaktPGsZuj++xAXck7+rmthFBFyPgKYcOByg2QF9QeSvsjhfh2A6l3j7nt7YNMOGHh3mUa2t9uvBqoz0GaqHEd+t4nPC7oC2hf9xCeSg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 20 Apr 2022 10:15:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.04.2022 13:47, Andrew Cooper wrote:
> --- a/xen/arch/x86/boot/build32.lds
> +++ b/xen/arch/x86/boot/build32.lds
> @@ -31,44 +31,36 @@ SECTIONS
>          *(.bss.*)
>    }
>  
> +  /* Dynamic linkage sections.  Collected simply so we can check they're 
> empty. */
> +  .got : {
> +        *(.got)
> +  }
>    .got.plt : {
> -        /*
> -         * PIC/PIE executable contains .got.plt section even if it is not 
> linked
> -         * with dynamic libraries. In such case it is just placeholder for
> -         * _GLOBAL_OFFSET_TABLE_ symbol and .PLT0. .PLT0 is filled by dynamic
> -         * linker and our code is not supposed to be loaded by dynamic 
> linker.
> -         * So, from our point of view .PLT0 is unused. This means that there 
> is
> -         * pretty good chance that we can safely drop .got.plt as a whole 
> here.
> -         * Sadly this is not true. _GLOBAL_OFFSET_TABLE_ is used as a 
> reference
> -         * for relative addressing (and only for that thing) and ld 
> complains if
> -         * we remove .got.plt section here because it cannot find required 
> symbol.
> -         * However, _GLOBAL_OFFSET_TABLE_ is no longer needed in final 
> output.
> -         * So, drop .got.plt section during conversion to plain binary 
> format.
> -         *
> -         * Please check build32.mk for more details.
> -         */
>          *(.got.plt)
>    }
> -
> -  /*
> -   * Discarding .shstrtab is not supported by LLD (LLVM LD) and will trigger 
> an
> -   * error. Also keep the rest of the control sections to match GNU LD 
> behavior.
> -   */
> -  .shstrtab : {
> -        *(.shstrtab)
> +  .igot.plt : {
> +        *(.igot.plt)
>    }
> -  .strtab : {
> -        *(.strtab)
> +  .iplt : {
> +        *(.iplt)
>    }
> -  .symtab : {
> -        *(.symtab)
> +  .plt : {
> +        *(.plt)
>    }
> -
> -  /DISCARD/ : {
> -        /*
> -         * Discard everything else, to prevent linkers from putting
> -         * orphaned sections ahead of .text, which needs to be first.
> -         */
> -        *(*)
> +  .rela : {
> +        *(.rela.*)
>    }
>  }
> +
> +ASSERT(SIZEOF(.got) == 0,         ".got 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) == 0 ||
> +       SIZEOF(.got.plt) == 3 * 4, "unexpected .got.plt size")

While here you've adjusted for this being 32-bit code, ...

> +ASSERT(SIZEOF(.igot.plt) == 0,    ".igot.plt non-empty")
> +ASSERT(SIZEOF(.iplt) == 0,        ".iplt non-empty")
> +ASSERT(SIZEOF(.plt) == 0,         ".plt non-empty")
> +ASSERT(SIZEOF(.rela) == 0,        "leftover relocations")

... this (and the construct making the section) would need
converting (or amending) too, as 32-bit uses .rel.*. Then

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.