From nobody Sat May 18 08:35:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1647936223915439.82781643096166; Tue, 22 Mar 2022 01:03:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.293307.498223 (Exim 4.92) (envelope-from ) id 1nWZTj-0000n3-Ot; Tue, 22 Mar 2022 08:02:55 +0000 Received: by outflank-mailman (output) from mailman id 293307.498223; Tue, 22 Mar 2022 08:02:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nWZTj-0000mw-LV; Tue, 22 Mar 2022 08:02:55 +0000 Received: by outflank-mailman (input) for mailman id 293307; Tue, 22 Mar 2022 08:02:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nWZTh-0000XO-UN for xen-devel@lists.xenproject.org; Tue, 22 Mar 2022 08:02:53 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 795cc9fd-a9b6-11ec-a405-831a346695d4; Tue, 22 Mar 2022 09:02:52 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 39E4E153B; Tue, 22 Mar 2022 01:02:52 -0700 (PDT) Received: from e129167.arm.com (unknown [10.57.5.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BD50D3F73D; Tue, 22 Mar 2022 01:02:49 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 795cc9fd-a9b6-11ec-a405-831a346695d4 From: Michal Orzel To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 1/2] xen: Introduce a header to store common linker scripts content Date: Tue, 22 Mar 2022 09:02:32 +0100 Message-Id: <20220322080233.53134-2-michal.orzel@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220322080233.53134-1-michal.orzel@arm.com> References: <20220322080233.53134-1-michal.orzel@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1647936225331100001 Content-Type: text/plain; charset="utf-8" Both x86 and arm linker scripts share quite a lot of common content. It is difficult to keep syncing them up, thus introduce a new header in include/xen called xen.lds.h to store the internals mutual to all the linker scripts. Include this header in linker scripts for x86 and arm. This patch serves as an intermediate step before populating xen.lds.h and making use of its content in the linker scripts later on. Signed-off-by: Michal Orzel Acked-by: Jan Beulich --- Changes since v1: -rename header to xen.lds.h to be coherent with Linux kernel -include empty header in linker scripts --- xen/arch/arm/xen.lds.S | 1 + xen/arch/x86/xen.lds.S | 1 + xen/include/xen/xen.lds.h | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 xen/include/xen/xen.lds.h diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 7921d8fa28..c666fc3e69 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -3,6 +3,7 @@ /* Modified for ARM Xen by Ian Campbell */ =20 #include +#include #include #undef ENTRY #undef ALIGN diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index d33e295320..4e3a9a2789 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -2,6 +2,7 @@ /* Modified for i386/x86-64 Xen by Keir Fraser */ =20 #include +#include #include #undef ENTRY #undef ALIGN diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h new file mode 100644 index 0000000000..dd292fa7dc --- /dev/null +++ b/xen/include/xen/xen.lds.h @@ -0,0 +1,8 @@ +#ifndef __XEN_LDS_H__ +#define __XEN_LDS_H__ + +/* + * Common macros to be used in architecture specific linker scripts. + */ + +#endif /* __XEN_LDS_H__ */ --=20 2.25.1 From nobody Sat May 18 08:35:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1647936224526336.56776904350795; Tue, 22 Mar 2022 01:03:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.293308.498235 (Exim 4.92) (envelope-from ) id 1nWZTn-000143-1M; Tue, 22 Mar 2022 08:02:59 +0000 Received: by outflank-mailman (output) from mailman id 293308.498235; Tue, 22 Mar 2022 08:02:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nWZTm-00013w-U4; Tue, 22 Mar 2022 08:02:58 +0000 Received: by outflank-mailman (input) for mailman id 293308; Tue, 22 Mar 2022 08:02:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nWZTl-0000XI-E3 for xen-devel@lists.xenproject.org; Tue, 22 Mar 2022 08:02:57 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7b245567-a9b6-11ec-8fbc-03012f2f19d4; Tue, 22 Mar 2022 09:02:55 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 32248106F; Tue, 22 Mar 2022 01:02:55 -0700 (PDT) Received: from e129167.arm.com (unknown [10.57.5.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A00E03F73D; Tue, 22 Mar 2022 01:02:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7b245567-a9b6-11ec-8fbc-03012f2f19d4 From: Michal Orzel To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros Date: Tue, 22 Mar 2022 09:02:33 +0100 Message-Id: <20220322080233.53134-3-michal.orzel@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220322080233.53134-1-michal.orzel@arm.com> References: <20220322080233.53134-1-michal.orzel@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1647936225505100004 Content-Type: text/plain; charset="utf-8" Populate header file xen.lds.h with the first portion of macros storing constructs common to x86 and arm linker scripts. Replace the original constructs with these helpers. No functional improvements to x86 linker script. Making use of common macros improves arm linker script with: -explicit list of debug sections that otherwise are seen as "orphans" by the linker. This will allow to fix issues after enabling linker option --orphan-handling one day -extended list of discarded section to include: .discard, desctructors related sections, .fini_array which can reference .text.exit -sections not related to debugging that are placed by ld.lld. Even though Xen on arm compilation with LLVM support is not ready yet, these sections do not cause problem to GNU ld. Please note that this patch does not aim to perform the full sync up between the linker scripts. It creates a base for further work. Signed-off-by: Michal Orzel --- Changes since v1: -merge x86 and arm changes into single patch -do not propagate issues by generalizing CTORS -extract sections not related to debugging into separate macro -get rid of _SECTION suffix in favor of using more meaningful suffixes --- xen/arch/arm/xen.lds.S | 37 +++++--------- xen/arch/x86/xen.lds.S | 78 +++-------------------------- xen/include/xen/xen.lds.h | 100 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 96 deletions(-) diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index c666fc3e69..e8ce7ad5f1 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -69,10 +69,7 @@ SECTIONS __proc_info_end =3D .; =20 #ifdef CONFIG_HAS_VPCI - . =3D ALIGN(POINTER_ALIGN); - __start_vpci_array =3D .; - *(SORT(.data.vpci.*)) - __end_vpci_array =3D .; + VPCI_ARRAY #endif } :text =20 @@ -110,10 +107,7 @@ SECTIONS __end_schedulers_array =3D .; =20 #ifdef CONFIG_HYPFS - . =3D ALIGN(8); - __paramhypfs_start =3D .; - *(.data.paramhypfs) - __paramhypfs_end =3D .; + HYPFS_PARAM #endif =20 *(.data .data.*) @@ -179,10 +173,7 @@ SECTIONS __alt_instructions_end =3D .; =20 #ifdef CONFIG_DEBUG_LOCK_PROFILE - . =3D ALIGN(POINTER_ALIGN); - __lock_profile_start =3D .; - *(.lockprofile.data) - __lock_profile_end =3D .; + LOCK_PROFILE_DATA #endif =20 *(.init.data) @@ -222,22 +213,18 @@ SECTIONS /* Section for the device tree blob (if any). */ .dtb : { *(.dtb) } :text =20 + /* + * Explicitly list debug sections, to avoid these sections being viewed = as + * "orphan" by the linker. + */ + DWARF_DEBUG_SECTIONS + /* Sections to be discarded */ - /DISCARD/ : { - *(.exit.text) - *(.exit.data) - *(.exitcall.exit) - *(.eh_frame) - } + DISCARD_SECTIONS =20 /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } + STABS_DEBUG_SECTIONS + ELF_DETAILS_SECTIONS } =20 /* diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 4e3a9a2789..65efbf9d0c 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -13,13 +13,6 @@ #undef __XEN_VIRT_START #define __XEN_VIRT_START __image_base__ #define DECL_SECTION(x) x : -/* - * Use the NOLOAD directive, despite currently ignored by (at least) GNU ld - * for PE output, in order to record that we'd prefer these sections to not - * be loaded into memory. - */ -#define DECL_DEBUG(x, a) #x ALIGN(a) (NOLOAD) : { *(x) } -#define DECL_DEBUG2(x, y, a) #x ALIGN(a) (NOLOAD) : { *(x) *(y) } =20 ENTRY(efi_start) =20 @@ -27,8 +20,6 @@ ENTRY(efi_start) =20 #define FORMAT "elf64-x86-64" #define DECL_SECTION(x) #x : AT(ADDR(#x) - __XEN_VIRT_START) -#define DECL_DEBUG(x, a) #x 0 : { *(x) } -#define DECL_DEBUG2(x, y, a) #x 0 : { *(x) *(y) } =20 ENTRY(start_pa) =20 @@ -160,10 +151,7 @@ SECTIONS __note_gnu_build_id_end =3D .; #endif #ifdef CONFIG_HAS_VPCI - . =3D ALIGN(POINTER_ALIGN); - __start_vpci_array =3D .; - *(SORT(.data.vpci.*)) - __end_vpci_array =3D .; + VPCI_ARRAY #endif } PHDR(text) =20 @@ -279,10 +267,7 @@ SECTIONS __alt_instructions_end =3D .; =20 #ifdef CONFIG_DEBUG_LOCK_PROFILE - . =3D ALIGN(POINTER_ALIGN); - __lock_profile_start =3D .; - *(.lockprofile.data) - __lock_profile_end =3D .; + LOCK_PROFILE_DATA #endif =20 . =3D ALIGN(8); @@ -336,10 +321,7 @@ SECTIONS __end_schedulers_array =3D .; =20 #ifdef CONFIG_HYPFS - . =3D ALIGN(8); - __paramhypfs_start =3D .; - *(.data.paramhypfs) - __paramhypfs_end =3D .; + HYPFS_PARAM #endif } PHDR(text) =20 @@ -396,24 +378,7 @@ SECTIONS * _end here, so if these sections get loaded they'll be discarded at ru= ntime * anyway. */ - DECL_DEBUG(.debug_abbrev, 1) - DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) - DECL_DEBUG(.debug_types, 1) - DECL_DEBUG(.debug_str, 1) - DECL_DEBUG2(.debug_line, .debug_line.*, 1) - DECL_DEBUG(.debug_line_str, 1) - DECL_DEBUG(.debug_names, 4) - DECL_DEBUG(.debug_frame, 4) - DECL_DEBUG(.debug_loc, 1) - DECL_DEBUG(.debug_loclists, 4) - DECL_DEBUG(.debug_macinfo, 1) - DECL_DEBUG(.debug_macro, 1) - DECL_DEBUG(.debug_ranges, 8) - DECL_DEBUG(.debug_rnglists, 4) - DECL_DEBUG(.debug_addr, 8) - DECL_DEBUG(.debug_aranges, 1) - DECL_DEBUG(.debug_pubnames, 1) - DECL_DEBUG(.debug_pubtypes, 1) + DWARF_DEBUG_SECTIONS =20 #ifdef EFI /* Trick the linker into setting the image size to no less than 16Mb. */ @@ -428,41 +393,12 @@ SECTIONS #endif =20 /* Sections to be discarded */ - /DISCARD/ : { - *(.text.exit) - *(.exit.text) - *(.exit.data) - *(.exitcall.exit) - *(.discard) - *(.discard.*) - *(.eh_frame) - *(.dtors) - *(.dtors.*) - *(.fini_array) - *(.fini_array.*) -#ifdef EFI - *(.comment) - *(.comment.*) - *(.note.*) -#endif - } + DISCARD_SECTIONS =20 #ifndef EFI /* Stabs debugging sections. */ - .stab 0 : { *(.stab) } - .stabstr 0 : { *(.stabstr) } - .stab.excl 0 : { *(.stab.excl) } - .stab.exclstr 0 : { *(.stab.exclstr) } - .stab.index 0 : { *(.stab.index) } - .stab.indexstr 0 : { *(.stab.indexstr) } - .comment 0 : { *(.comment) } - /* - * LLVM ld also wants .symtab, .strtab, and .shstrtab placed. These look= to - * be benign to GNU ld, so we can have them here unconditionally. - */ - .symtab 0 : { *(.symtab) } - .strtab 0 : { *(.strtab) } - .shstrtab 0 : { *(.shstrtab) } + STABS_DEBUG_SECTIONS + ELF_DETAILS_SECTIONS #endif } =20 diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h index dd292fa7dc..ad1d199021 100644 --- a/xen/include/xen/xen.lds.h +++ b/xen/include/xen/xen.lds.h @@ -5,4 +5,104 @@ * Common macros to be used in architecture specific linker scripts. */ =20 +/* Macros to declare debug sections. */ +#ifdef EFI +/* + * Use the NOLOAD directive, despite currently ignored by (at least) GNU ld + * for PE output, in order to record that we'd prefer these sections to not + * be loaded into memory. + */ +#define DECL_DEBUG(x, a) #x ALIGN(a) (NOLOAD) : { *(x) } +#define DECL_DEBUG2(x, y, a) #x ALIGN(a) (NOLOAD) : { *(x) *(y) } +#else +#define DECL_DEBUG(x, a) #x 0 : { *(x) } +#define DECL_DEBUG2(x, y, a) #x 0 : { *(x) *(y) } +#endif + +/* DWARF debug sections. */ +#define DWARF_DEBUG_SECTIONS \ + DECL_DEBUG(.debug_abbrev, 1) \ + DECL_DEBUG2(.debug_info, .gnu.linkonce.wi.*, 1) \ + DECL_DEBUG(.debug_types, 1) \ + DECL_DEBUG(.debug_str, 1) \ + DECL_DEBUG2(.debug_line, .debug_line.*, 1) \ + DECL_DEBUG(.debug_line_str, 1) \ + DECL_DEBUG(.debug_names, 4) \ + DECL_DEBUG(.debug_frame, 4) \ + DECL_DEBUG(.debug_loc, 1) \ + DECL_DEBUG(.debug_loclists, 4) \ + DECL_DEBUG(.debug_macinfo, 1) \ + DECL_DEBUG(.debug_macro, 1) \ + DECL_DEBUG(.debug_ranges, 8) \ + DECL_DEBUG(.debug_rnglists, 4) \ + DECL_DEBUG(.debug_addr, 8) \ + DECL_DEBUG(.debug_aranges, 1) \ + DECL_DEBUG(.debug_pubnames, 1) \ + DECL_DEBUG(.debug_pubtypes, 1) + +/* Stabs debug sections. */ +#define STABS_DEBUG_SECTIONS \ + .stab 0 : { *(.stab) } \ + .stabstr 0 : { *(.stabstr) } \ + .stab.excl 0 : { *(.stab.excl) } \ + .stab.exclstr 0 : { *(.stab.exclstr) } \ + .stab.index 0 : { *(.stab.index) } \ + .stab.indexstr 0 : { *(.stab.indexstr) } + +/* + * Required sections not related to debugging. + * + * LLVM ld also wants .symtab, .strtab, and .shstrtab placed. These look to + * be benign to GNU ld, so we can have them here unconditionally. + */ +#define ELF_DETAILS_SECTIONS \ + .comment 0 : { *(.comment) } \ + .symtab 0 : { *(.symtab) } \ + .strtab 0 : { *(.strtab) } \ + .shstrtab 0 : { *(.shstrtab) } + +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \ + *(.comment.*) \ + *(.note.*) +#else +#define DISCARD_EFI_SECTIONS +#endif + +/* Sections to be discarded. */ +#define DISCARD_SECTIONS \ + /DISCARD/ : { \ + *(.text.exit) \ + *(.exit.text) \ + *(.exit.data) \ + *(.exitcall.exit) \ + *(.discard) \ + *(.discard.*) \ + *(.eh_frame) \ + *(.dtors) \ + *(.dtors.*) \ + *(.fini_array) \ + *(.fini_array.*) \ + DISCARD_EFI_SECTIONS \ + } + +#define VPCI_ARRAY \ + . =3D ALIGN(POINTER_ALIGN); \ + __start_vpci_array =3D .; \ + *(SORT(.data.vpci.*)) \ + __end_vpci_array =3D .; + +#define HYPFS_PARAM \ + . =3D ALIGN(8); \ + __paramhypfs_start =3D .; \ + *(.data.paramhypfs) \ + __paramhypfs_end =3D .; + +#define LOCK_PROFILE_DATA \ + . =3D ALIGN(POINTER_ALIGN); \ + __lock_profile_start =3D .; \ + *(.lockprofile.data) \ + __lock_profile_end =3D .; + #endif /* __XEN_LDS_H__ */ --=20 2.25.1