xen: Linker scripts synchronization
v2 cover xen: Linker scripts synchronization
This patch series aims to do the first step towards linker scripts synchronization. Linker scripts for arm and x86 share a lot of common sections and in order to make the process of changing/improving/syncing them, these sections shall be defined in just one place.
The first patch creates an empty header file xen.lds.h to store the constructs mutual to both x86 and arm linker scripts. It also includes this header in the scripts.
The second patch populates xen.lds.h with the first portion of common macros and replaces the original contructs with these helpers.
Michal Orzel (2):
xen: Introduce a header to store common linker scripts content
xen: Populate xen.lds.h and make use of its macros
xen/arch/arm/xen.lds.S | 38 +++++--------- xen/arch/x86/xen.lds.S | 79 +++------------------------- xen/include/xen/xen.lds.h | 108 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 96 deletions(-) create mode 100644 xen/include/xen/xen.lds.h
Signature · 1 line
2.25.1
PATCH v2 1/2 xen: Introduce a header to store common linker scripts content
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.
---
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
xen/arch/arm/xen.lds.S +1 -0
@@ -3,6 +3,7 @@ /* Modified for ARM Xen by Ian Campbell */ #include <xen/cache.h> +#include <xen/xen.lds.h> #include <asm/page.h> #undef ENTRY #undef ALIGN
xen/arch/x86/xen.lds.S +1 -0
@@ -2,6 +2,7 @@ /* Modified for i386/x86-64 Xen by Keir Fraser */ #include <xen/cache.h> +#include <xen/xen.lds.h> #include <asm/page.h> #undef ENTRY #undef ALIGN
xen/include/xen/xen.lds.h new file +8 -0
@@ -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__ */
Signature · 1 line
2.25.1
Re: [PATCH v2 1/2] xen: Introduce a header to store common linker scripts content
Quoted 10 lines · Michal Orzel
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/xencalledxen.lds.hto 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.hand making use of its content in the linker scripts later on.Signed-off-by Michal Orzel <[email protected]>
PATCH v2 2/2 xen: Populate xen.lds.h and make use of its macros
In reply to Michal OrzelPopulate 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.
---
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(-)
xen/arch/arm/xen.lds.S +12 -25
@@ -69,10 +69,7 @@ SECTIONS __proc_info_end = .; #ifdef CONFIG_HAS_VPCI - . = ALIGN(POINTER_ALIGN); - __start_vpci_array = .; - *(SORT(.data.vpci.*)) - __end_vpci_array = .; + VPCI_ARRAY #endif } :text
@@ -110,10 +107,7 @@ SECTIONS __end_schedulers_array = .; #ifdef CONFIG_HYPFS - . = ALIGN(8); - __paramhypfs_start = .; - *(.data.paramhypfs) - __paramhypfs_end = .; + HYPFS_PARAM #endif *(.data .data.*)
@@ -179,10 +173,7 @@ SECTIONS __alt_instructions_end = .; #ifdef CONFIG_DEBUG_LOCK_PROFILE - . = ALIGN(POINTER_ALIGN); - __lock_profile_start = .; - *(.lockprofile.data) - __lock_profile_end = .; + LOCK_PROFILE_DATA #endif *(.init.data)
@@ -222,22 +213,18 @@ SECTIONS /* Section for the device tree blob (if any). */ .dtb : { *(.dtb) } :text + /* + * 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 /* 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 } /*
xen/arch/x86/xen.lds.S +7 -71
123 lines not on this page · raw message
xen/include/xen/xen.lds.h +100 -0
104 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
xen/arch/arm/xen.lds.S SECTIONS · line 73
Quoted 12 lines · Michal Orzel
xen/arch/arm/xen.lds.S +1
-4@@ -69,10 +69,7 @@ SECTIONS __proc_info_end = .; #ifdef CONFIG_HAS_VPCI - . = ALIGN(POINTER_ALIGN); - __start_vpci_array = .; - *(SORT(.data.vpci.*)) - __end_vpci_array = .; + VPCI_ARRAY #endif
Here and elsewhere I think the #ifdef should move as well, or to be precise VPCI_ARRAY (in the specific case here) should simply expand to nothing when CONFIG_HAS_VPCI is not defined.
xen/arch/arm/xen.lds.S SECTIONS · line 220
Quoted 9 lines
xen/arch/arm/xen.lds.S +5
-0@@ -222,22 +213,18 @@ SECTIONS /* Section for the device tree blob (if any). */ .dtb : { *(.dtb) } :text + /* + * Explicitly list debug sections, to avoid these sections being viewed as + * "orphan" by the linker. + */ + DWARF_DEBUG_SECTIONS
Considering the comment, perhaps better to move ...
Quoted 8 lines
xen/arch/arm/xen.lds.S +1
-6/* Sections to be discarded */ - /DISCARD/ : { - *(.exit.text) - *(.exit.data) - *(.exitcall.exit) - *(.eh_frame) - } + DISCARD_SECTIONS
xen/arch/arm/xen.lds.S SECTIONS · line 226
Quoted 10 lines
xen/arch/arm/xen.lds.S +1
-7/* 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
... this up there?
Quoted 12 lines
xen/include/xen/xen.lds.h +6
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* 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.
xen/include/xen/xen.lds.h line 23
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+*/ +#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 \
May I suggest to call this DWARF2_DEBUG_SECTIONS, to make clear no Dwarf1 section is included here (and we also don't mean to support such debug info)?
Quoted 64 lines
xen/include/xen/xen.lds.h +64
-0+ 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 \
xen/include/xen/xen.lds.h line 97
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ } + +#define VPCI_ARRAY \ + . = ALIGN(POINTER_ALIGN); \ + __start_vpci_array = .; \ + *(SORT(.data.vpci.*)) \ + __end_vpci_array = .; + +#define HYPFS_PARAM \ + . = ALIGN(8); \
Since you're generalizing this, you mean POINTER_ALIGN here, not 8.
xen/include/xen/xen.lds.h line 106
Quoted 9 lines
xen/include/xen/xen.lds.h +9
-0+ __paramhypfs_start = .; \ + *(.data.paramhypfs) \ + __paramhypfs_end = .; + +#define LOCK_PROFILE_DATA \ + . = ALIGN(POINTER_ALIGN); \ + __lock_profile_start = .; \ + *(.lockprofile.data) \ + __lock_profile_end = .;
While for *_SECTIONS I don't care as much, for these last three items I think it would be good if we (maybe just informally) established an ordering rule, such that we can ask further additions here to not occur randomly. Once we've grown a few more of these, this would also help quickly locating the perhaps just one construct of interest when looking up things. Personally I think the only sensible ordering criteria is the name of the construct being defined. This could be mentioned in a comment ahead of them, and that comment would then at the same time serve as separator between *_SECTIONS and any constructs also defining (enclosing) symbols.
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Hi Jan,
Thanks for review.
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Michal Orzel
xen/arch/arm/xen.lds.S +0
-0@@ -69,10 +69,7 @@ SECTIONS __proc_info_end = .;
Quoted 12 lines
xen/arch/arm/xen.lds.S SECTIONS · line 73
Quoted 7 lines
xen/arch/arm/xen.lds.S +1
-4#ifdef CONFIG_HAS_VPCI - . = ALIGN(POINTER_ALIGN); - __start_vpci_array = .; - *(SORT(.data.vpci.*)) - __end_vpci_array = .; + VPCI_ARRAY #endifHere and elsewhere I think the #ifdef should move as well, or to be precise
VPCI_ARRAY(in the specific case here) should simply expand to nothing whenCONFIG_HAS_VPCIis not defined.
I was thinking about it at the beginning so I'm ok with your solution.
Quoted 31 lines
xen/arch/arm/xen.lds.S SECTIONS · line 220
Quoted 9 lines
xen/arch/arm/xen.lds.S +5
-0@@ -222,22 +213,18 @@ SECTIONS /* Section for the device tree blob (if any). */ .dtb : { *(.dtb) } :text + /* + * Explicitly list debug sections, to avoid these sections being viewed as + * "orphan" by the linker. + */ + DWARF_DEBUG_SECTIONSConsidering the comment, perhaps better to move ...
Quoted 8 lines
xen/arch/arm/xen.lds.S +1
-6/* Sections to be discarded */ - /DISCARD/ : { - *(.exit.text) - *(.exit.data) - *(.exitcall.exit) - *(.eh_frame) - } + DISCARD_SECTIONSxen/arch/arm/xen.lds.S SECTIONS · line 226
Quoted 10 lines
xen/arch/arm/xen.lds.S +1
-7/* 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
Quoted 1 line
... this up there?
That makes sense. Ok.
Quoted 19 lines
Quoted 19 lines
xen/include/xen/xen.lds.h +12
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* 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) }
Quoted 9 lines
xen/include/xen/xen.lds.h line 23
Quoted 4 lines
xen/include/xen/xen.lds.h +4
-0+#endif + +/* DWARF debug sections. */ +#define DWARF_DEBUG_SECTIONS \May I suggest to call this
DWARF2_DEBUG_SECTIONS, to make clear no Dwarf1 section is included here (and we also don't mean to support such debug info)?
As this list is not full I thought we are going to add DWARF1 sections one day. DWARF2_DEBUG_SECTIONS would mean that we list sections only from DWARF2 which is not true as we have sections from DWARF3,5, etc.
Maybe we should leave it as it is but modify the comment to state:
/* DWARF2+ debug sections */
Quoted 28 lines
Quoted 28 lines
xen/include/xen/xen.lds.h +28
-0+ 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) } +
Quoted 8 lines
xen/include/xen/xen.lds.h line 59
Quoted 8 lines
xen/include/xen/xen.lds.h +8
-0+/* +* 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) } \
I also need to add *(.comment.*) due to:
https://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=69e46280937526db9cf78259cd8a0a9ec62dc847
Quoted 32 lines
Quoted 32 lines
xen/include/xen/xen.lds.h +32
-0+ .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 \ + . = ALIGN(POINTER_ALIGN); \
Quoted 9 lines
xen/include/xen/xen.lds.h line 97
Quoted 6 lines
xen/include/xen/xen.lds.h +6
-0+ __start_vpci_array = .; \ + *(SORT(.data.vpci.*)) \ + __end_vpci_array = .; + +#define HYPFS_PARAM \ + . = ALIGN(8); \Since you're generalizing this, you mean
POINTER_ALIGNhere, not 8.
Ok.
Quoted 12 lines
xen/include/xen/xen.lds.h line 106
Quoted 9 lines
xen/include/xen/xen.lds.h +9
-0+ __paramhypfs_start = .; \ + *(.data.paramhypfs) \ + __paramhypfs_end = .; + +#define LOCK_PROFILE_DATA \ + . = ALIGN(POINTER_ALIGN); \ + __lock_profile_start = .; \ + *(.lockprofile.data) \ + __lock_profile_end = .;While for
*_SECTIONSI don't care as much, for these last three items I think it would be good if we (maybe just informally) established an
Quoted 9 lines
ordering rule, such that we can ask further additions here to not occur randomly. Once we've grown a few more of these, this would also help quickly locating the perhaps just one construct of interest when looking up things. Personally I think the only sensible ordering criteria is the name of the construct being defined. This could be mentioned in a comment ahead of them, and that comment would then at the same time serve as separator between
*_SECTIONSand any constructs also defining (enclosing) symbols.
Yes, name of the constructs is the good criteria.
I will do it in v3.
Quoted 2 lines
Jan
Cheers,
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 29 lines · Michal Orzel
Quoted 19 lines · Jan Beulich
Quoted 18 lines · Michal Orzel
xen/include/xen/xen.lds.h +12
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* 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) }Quoted 9 lines
xen/include/xen/xen.lds.h line 23
Quoted 4 lines
xen/include/xen/xen.lds.h +4
-0+#endif + +/* DWARF debug sections. */ +#define DWARF_DEBUG_SECTIONS \May I suggest to call this
DWARF2_DEBUG_SECTIONS, to make clear no Dwarf1 section is included here (and we also don't mean to support such debug info)?
Quoted 5 lines
As this list is not full I thought we are going to add DWARF1 sections one day.
DWARF2_DEBUG_SECTIONSwould mean that we list sections only from DWARF2 which is not true as we have sections from DWARF3,5, etc.
Maybe we should leave it as it is but modify the comment to state:
/* DWARF2+ debug sections */
Well, yes, but only in a way. Dwarf3 and later are simply extensions of Dwarf2, whereas Dwarf2 is not an extension of what originally was called just Dwarf and now is commonly referred to as Dwarf1. I'm fine with a comment saying Dwarf2+, but I'd like to not see the construct be named just DWARF_*.
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
In reply to Michal OrzelHi,
Quoted 8 lines · Michal Orzel
Populate header file
xen.lds.hwith 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"
NIT: This is a bit confusing to see no space after -. Can you add one?
I would also recommend to start with (soft)tab to make clearer this is a list.
Same goes for the other use below.
Quoted 3 lines
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
Typo: s/desctructors/destructors/
Quoted 3 lines
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,
Building natively Xen on Arm with Clang works. So do you mean you using LLD?
NIT: Also, from the formatting it is not clear that the second sentence is part of the last item. How about removing the newline just after the first sentence?
Quoted 6 lines
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 <[email protected]>
[...]
xen/include/xen/xen.lds.h line 9
Quoted 10 lines
xen/include/xen/xen.lds.h +2
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI
AFAIK, we don't define EFI on Arm (just CONFIG_EFI). Yet we do support EFI on arm64.
As this #ifdef is now in generic code, can you explain how this is meant to be used?
Quoted 40 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \
xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \
This is a bit confusing. Here you seem to use the section .comment. But...
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
xen/include/xen/xen.lds.h +7
-0+ .symtab 0 : { *(.symtab) } \ + .strtab 0 : { *(.strtab) } \ + .shstrtab 0 : { *(.shstrtab) } + +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \
... here you will discard it if EFI is set. Which one take precedence if the caller use both ELF_DETAILS_SECTIONS and DISCARD_EFI_SECTION?
Also, can you explain why we need to drop those sections when EFI is set?
Quoted 32 lines
xen/include/xen/xen.lds.h +32
-0+ *(.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 \ + . = ALIGN(POINTER_ALIGN); \ + __start_vpci_array = .; \ + *(SORT(.data.vpci.*)) \ + __end_vpci_array = .; + +#define HYPFS_PARAM \ + . = ALIGN(8); \ + __paramhypfs_start = .; \
xen/include/xen/xen.lds.h line 108
Quoted 10 lines
xen/include/xen/xen.lds.h +9
-0+ *(.data.paramhypfs) \ + __paramhypfs_end = .; + +#define LOCK_PROFILE_DATA \ + . = ALIGN(POINTER_ALIGN); \ + __lock_profile_start = .; \ + *(.lockprofile.data) \ + __lock_profile_end = .; +#endif /* __XEN_LDS_H__ */
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 7 lines · Julien Grall
Hi,
Quoted 4 lines · Michal Orzel
Populate header file
xen.lds.hwith the first portion of macros storing constructs common to x86 and arm linker scripts. Replace the original constructs with these helpers.
Quoted 7 lines
Quoted 4 lines
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"NIT: This is a bit confusing to see no space after -. Can you add one?
Ok.
Quoted 4 lines
I would also recommend to start with (soft)tab to make clearer this is a list.
Same goes for the other use below.
Ok.
Quoted 7 lines
Quoted 4 lines
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, desctructorsTypo: s/desctructors/destructors/
Ok.
Quoted 6 lines
Quoted 3 lines
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,
Building natively Xen on Arm with Clang works. So do you mean you using LLD?
I mean using the LLVM replacements not only for CC + supporting cross-compilation. As for the linker, Xen sets llvm-ld which is very very old and in fact README states LLVM 3.5 or later but llvm-ld was removed before that. Thus IMO support for LLVM on arm is not ready yet.
Quoted 2 lines
NIT: Also, from the formatting it is not clear that the second sentence is part of the last item. How about removing the newline just after the first sentence?
Ok.
Quoted 21 lines
Quoted 6 lines
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 <[email protected]>[...]
Quoted 9 lines
xen/include/xen/xen.lds.h +0
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */
+#ifdef EFIAFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
Quoted 53 lines
Quoted 40 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \This is a bit confusing. Here you seem to use the section .comment. But...
Quoted 10 lines
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
+ .symtab 0 : { *(.symtab) } \
+ .strtab 0 : { *(.strtab) } \
+ .shstrtab 0 : { *(.shstrtab) }xen/include/xen/xen.lds.h +4
-0+ +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \... here you will discard it if EFI is set. Which one take precedence if the caller use both
ELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION?
ELF_DETAILS_SECTIONS is protected by #ifndef EFI and DISCARD_EFI_SECTION by #ifdef EFI so the caller cannot use both ELF_DETAILS_SECTIONS and DISCARD_EFI_SECTION.
Quoted 2 lines
Also, can you explain why we need to drop those sections when EFI is set?
This is related to x86. Please see the commit: 7844f90abd551f6d5cd9b670b5ed8a4683258a21
Quoted 36 lines
Quoted 36 lines
+ *(.comment.*) \
+ *(.note.*)xen/include/xen/xen.lds.h +34
-0+#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 \ + . = ALIGN(POINTER_ALIGN); \ + __start_vpci_array = .; \ + *(SORT(.data.vpci.*)) \ + __end_vpci_array = .; + +#define HYPFS_PARAM \ + . = ALIGN(8); \ + __paramhypfs_start = .; \ + *(.data.paramhypfs) \ + __paramhypfs_end = .; + +#define LOCK_PROFILE_DATA \
Quoted 9 lines
Quoted 6 lines
+ . =
ALIGN(POINTER_ALIGN); \
+__lock_profile_start= .; \
+ *(.lockprofile.data) \
+__lock_profile_end= .;
+
#endif /*__XEN_LDS_H__*/Cheers,
Cheers,
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Hi,
Quoted 36 lines · Michal Orzel
Quoted 7 lines · Julien Grall
Hi,
Quoted 4 lines · Michal Orzel
Populate header file
xen.lds.hwith the first portion of macros storing constructs common to x86 and arm linker scripts. Replace the original constructs with these helpers.Quoted 7 lines
Quoted 4 lines
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"NIT: This is a bit confusing to see no space after -. Can you add one?
Ok.
Quoted 4 lines
I would also recommend to start with (soft)tab to make clearer this is a list.
Same goes for the other use below.
Ok.
Quoted 7 lines
Quoted 4 lines
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, desctructorsTypo: s/desctructors/destructors/
Ok.
Quoted 4 lines
Quoted 3 lines
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,
Quoted 5 lines
Quoted 2 lines
Building natively Xen on Arm with Clang works. So do you mean you using LLD?
I mean using the LLVM replacements not only for CC + supporting cross-compilation. As for the linker, Xen sets llvm-ld which is very very old and in fact README states LLVM 3.5 or later but llvm-ld was removed before that.
I am confused. I looked at the llvm repo and lld is still there. So why are you saying is lld is very old and removed?
Quoted 2 lines
Thus IMO support for LLVM on arm
is not ready yet.
I agree that building Xen on Arm only with LLVM tools is not possible yet. But this statement seems to be a bit too broad here. I think what matters is we don't support linking with LLD on Arm.
Quoted 21 lines
Quoted 21 lines
Quoted 6 lines
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 <[email protected]>[...]
xen/include/xen/xen.lds.h line 8
Quoted 9 lines
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.
Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Once we answered that, we can decide whether this is correct to use EFI in generic code. IOW, is thish going to be useful for other arch?
Quoted 64 lines
Quoted 54 lines
Quoted 41 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \This is a bit confusing. Here you seem to use the section .comment. But...
Quoted 10 lines
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
xen/include/xen/xen.lds.h +7
-0+ .symtab 0 : { *(.symtab) } \ + .strtab 0 : { *(.strtab) } \ + .shstrtab 0 : { *(.shstrtab) } + +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \... here you will discard it if EFI is set. Which one take precedence if the caller use both
ELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION?
Quoted 2 lines
ELF_DETAILS_SECTIONSis protected by #ifndef EFI andDISCARD_EFI_SECTIONby #ifdef EFI so the caller cannot use bothELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION.
The caller will protect it. But it is not in the header. I don't think we should expect the user to check x86 to understand how this is meant to be used.
Quoted 4 lines
Quoted 3 lines
Also, can you explain why we need to drop those sections when EFI is set?
This is related to x86. Please see the commit:
7844f90abd551f6d5cd9b670b5ed8a4683258a21
Why is this in the generic header then?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 39 lines · Julien Grall
Hi,
Quoted 36 lines · Michal Orzel
Quoted 7 lines · Julien Grall
Hi,
Quoted 4 lines · Michal Orzel
Populate header file
xen.lds.hwith the first portion of macros storing constructs common to x86 and arm linker scripts. Replace the original constructs with these helpers.Quoted 7 lines
Quoted 4 lines
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"NIT: This is a bit confusing to see no space after -. Can you add one?
Ok.
Quoted 4 lines
I would also recommend to start with (soft)tab to make clearer this is a list.
Same goes for the other use below.
Ok.
Quoted 7 lines
Quoted 4 lines
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, desctructorsTypo: s/desctructors/destructors/
Ok.
Quoted 4 lines
Quoted 3 lines
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,
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Building natively Xen on Arm with Clang works. So do you mean you using LLD?
I mean using the LLVM replacements not only for CC + supporting cross-compilation. As for the linker, Xen sets llvm-ld which is very very old and in fact README states LLVM 3.5 or later but llvm-ld was removed before that.
I am confused. I looked at the llvm repo and lld is still there. So why are you saying is lld is very old and removed?
lld is not llvm-ld. I'm talking about llvm-ld. lld is the current LLVM linker. Xen sets LD to llvm-ld which has been removed in 3.2:
See: https://releases.llvm.org/3.2/docs/ReleaseNotes.html
Quoted 30 lines
Quoted 2 lines
Thus IMO support for LLVM on arm
is not ready yet.I agree that building Xen on Arm only with LLVM tools is not possible yet. But this statement seems to be a bit too broad here. I think what matters is we don't support linking with LLD on Arm.
Quoted 21 lines
Quoted 21 lines
Quoted 6 lines
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 <[email protected]>[...]
Quoted 9 lines
xen/include/xen/xen.lds.h +0
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */
+#ifdef EFIAFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
Quoted 8 lines
I find the name "EFI" too generic to figure out that this code can only be used by x86.
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Once we answered that, we can decide whether this is correct to use EFI in generic code. IOW, is thish going to be useful for other arch?
I think Jan needs to answer this question as I am not sure.
Quoted 67 lines
Quoted 64 lines
Quoted 54 lines
Quoted 41 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \This is a bit confusing. Here you seem to use the section .comment. But...
Quoted 10 lines
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
+ .symtab 0 : { *(.symtab) } \
+ .strtab 0 : { *(.strtab) } \
+ .shstrtab 0 : { *(.shstrtab) }xen/include/xen/xen.lds.h +4
-0+ +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \... here you will discard it if EFI is set. Which one take precedence if the caller use both
ELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION?Quoted 2 lines
ELF_DETAILS_SECTIONSis protected by #ifndef EFI andDISCARD_EFI_SECTIONby #ifdef EFI so the caller cannot use bothELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION.
Quoted 9 lines
The caller will protect it. But it is not in the header. I don't think we should expect the user to check x86 to understand how this is meant to be used.
Quoted 4 lines
Quoted 3 lines
Also, can you explain why we need to drop those sections when EFI is set?
This is related to x86. Please see the commit:
7844f90abd551f6d5cd9b670b5ed8a4683258a21Why is this in the generic header then?
If we decide that EFI is not meant for anything else than x86, I will get rid of it completely from this header.
Quoted 2 lines
Cheers,
Cheers,
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
In reply to Julien GrallQuoted 20 lines · Julien Grall
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Julien Grall
xen/include/xen/xen.lds.h line 8
Quoted 7 lines · Michal Orzel
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
Quoted 6 lines
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
We produce two linker scripts from the single source file: One (with EFI undefined) to link the ELF binary, and another (with EFI defined) to link the PE/COFF output. If "EFI" is too imprecise as a name for the identifier, I wouldn't mind renaming it (to PE_COFF?), but at the same time I'm not convinced this is really necessary.
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Hi Jan,
Quoted 28 lines · Jan Beulich
Quoted 20 lines · Julien Grall
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Julien Grall
xen/include/xen/xen.lds.h line 8
Quoted 7 lines · Michal Orzel
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
Quoted 6 lines
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Quoted 5 lines
We produce two linker scripts from the single source file: One (with EFI undefined) to link the ELF binary, and another (with EFI defined) to link the PE/COFF output. If "EFI" is too imprecise as a name for the identifier, I wouldn't mind renaming it (to
PE_COFF?), but at the same time I'm not convinced this is really necessary.
Thank for the explanation (and the other ones in this thread). You are right the confusion arised from "generating" vs "linking".
Renaming to PE_COFF may help to avoid the confusion with CONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 35 lines · Julien Grall
Quoted 28 lines · Jan Beulich
Quoted 20 lines · Julien Grall
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Julien Grall
xen/include/xen/xen.lds.h line 8
Quoted 7 lines · Michal Orzel
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
Quoted 6 lines
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Quoted 5 lines
We produce two linker scripts from the single source file: One (with EFI undefined) to link the ELF binary, and another (with EFI defined) to link the PE/COFF output. If "EFI" is too imprecise as a name for the identifier, I wouldn't mind renaming it (to
PE_COFF?), but at the same time I'm not convinced this is really necessary.
Quoted 6 lines
Thank for the explanation (and the other ones in this thread). You are right the confusion arised from "generating" vs "linking".
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".
Indeed. And EFI_PE_COFF is getting a little unwieldy for my taste.
Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
That's perhaps the best place, yes.
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Hello,
Quoted 43 lines · Jan Beulich
Quoted 35 lines · Julien Grall
Quoted 28 lines · Jan Beulich
Quoted 20 lines · Julien Grall
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Julien Grall
xen/include/xen/xen.lds.h line 8
Quoted 7 lines · Michal Orzel
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
Quoted 6 lines
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Quoted 5 lines
We produce two linker scripts from the single source file: One (with EFI undefined) to link the ELF binary, and another (with EFI defined) to link the PE/COFF output. If "EFI" is too imprecise as a name for the identifier, I wouldn't mind renaming it (to
PE_COFF?), but at the same time I'm not convinced this is really necessary.Quoted 6 lines
Thank for the explanation (and the other ones in this thread). You are right the confusion arised from "generating" vs "linking".
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".
Quoted 8 lines
Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
That's perhaps the best place, yes.
In this case how about the following comment at the top of xen.lds.h:
"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary. Currently EFI macro is only defined by x86 to link PE/COFF output, however it is not unique to this architecture."
Quoted 2 lines
Jan
Cheers,
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 52 lines · Michal Orzel
Hello,
Quoted 49 lines · Jan Beulich
Quoted 35 lines · Julien Grall
Quoted 28 lines · Jan Beulich
Quoted 20 lines · Julien Grall
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Julien Grall
xen/include/xen/xen.lds.h line 8
Quoted 7 lines · Michal Orzel
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
Quoted 6 lines
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Quoted 5 lines
We produce two linker scripts from the single source file: One (with EFI undefined) to link the ELF binary, and another (with EFI defined) to link the PE/COFF output. If "EFI" is too imprecise as a name for the identifier, I wouldn't mind renaming it (to
PE_COFF?), but at the same time I'm not convinced this is really necessary.Quoted 6 lines
Thank for the explanation (and the other ones in this thread). You are right the confusion arised from "generating" vs "linking".
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Quoted 7 lines
Quoted 2 lines
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and CONFIG_EFI, without going into arch specifics.
Jan
Quoted 7 lines
Currently EFI macro is
only defined by x86 to link PE/COFF output, however it is not unique to this architecture."Cheers,
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 57 lines · Jan Beulich
Quoted 56 lines · Michal Orzel
Hello,
Quoted 43 lines · Jan Beulich
Quoted 35 lines · Julien Grall
Quoted 28 lines · Jan Beulich
Quoted 20 lines · Julien Grall
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Julien Grall
xen/include/xen/xen.lds.h line 8
Quoted 7 lines · Michal Orzel
xen/include/xen/xen.lds.h +1
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.Quoted 3 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
As we do not define EFI on arm, all the stuff protected by #ifdef EFI is x86 specific.
I find the name "EFI" too generic to figure out that this code can only be used by x86.
Quoted 6 lines
But, from my understanding, this header is meant to contain generic code. It feels a bit odd that we are moving arch specific code.
To be honest, I don't quite understand why we need to make the diffferentiation on x86. So I guess the first question is how this is meant to be used on x86?
Quoted 5 lines
We produce two linker scripts from the single source file: One (with EFI undefined) to link the ELF binary, and another (with EFI defined) to link the PE/COFF output. If "EFI" is too imprecise as a name for the identifier, I wouldn't mind renaming it (to
PE_COFF?), but at the same time I'm not convinced this is really necessary.Quoted 6 lines
Thank for the explanation (and the other ones in this thread). You are right the confusion arised from "generating" vs "linking".
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Quoted 8 lines
Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:
Quoted 7 lines
Quoted 3 lines
"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.
Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like CONFIG_EFI ?
Quoted 11 lines
Jan
Quoted 7 lines
Currently EFI macro is
only defined by x86 to link PE/COFF output, however it is not unique to this architecture."Cheers,
Michal
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 22 lines · Michal Orzel
Quoted 21 lines · Jan Beulich
Quoted 19 lines · Michal Orzel
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Julien Grall
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Quoted 8 lines
Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
Quoted 5 lines
Quoted 3 lines
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like
CONFIG_EFI?
Let's call it a "virtual" CONFIG_EFI then; I think we really should have such an option. But yes, if you don't like referring to such a virtual option, then describing what is meant verbally is certainly going to be fine.
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Michal Orzel
Quoted 24 lines · Jan Beulich
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Jan Beulich
Quoted 3 lines · Julien Grall
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Quoted 7 lines
Quoted 2 lines
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.
Quoted 8 lines
Quoted 2 lines
Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like
CONFIG_EFI?Let's call it a "virtual"
CONFIG_EFIthen; I think we really should have such an option. But yes, if you don't like referring to such a virtual option, then describing what is meant verbally is certainly going to be fine.
FWICS, there was an attempt done by Wei in his NUMA series to define CONFIG_EFI. However as this is not yet merged and agreed, I would like not to refer to identifiers not existing in the code, even though most people are familiar with this option from Linux.
So by taking an example from Linux I would verbally explain it like that:
"To avoid any confusion, please note that EFI macro does not correspond to EFI runtime support and is used when linking a native EFI (i.e. PE/COFF) binary, hence its usage in this header."
If that does not suite you, please help creating a better explanation.
Quoted 2 lines
Jan
Michal
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 35 lines · Michal Orzel
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Michal Orzel
Quoted 24 lines · Jan Beulich
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Jan Beulich
Quoted 3 lines · Julien Grall
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Quoted 7 lines
Quoted 2 lines
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.Quoted 8 lines
Quoted 2 lines
Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like
CONFIG_EFI?Let's call it a "virtual"
CONFIG_EFIthen; I think we really should have such an option. But yes, if you don't like referring to such a virtual option, then describing what is meant verbally is certainly going to be fine.
Quoted 8 lines
FWICS, there was an attempt done by Wei in his NUMA series to define
CONFIG_EFI. However as this is not yet merged and agreed, I would like not to refer to identifiers not existing in the code, even though most people are familiar with this option from Linux.So by taking an example from Linux I would verbally explain it like that:
"To avoid any confusion, please note that EFI macro does not correspond to EFI runtime support and is used when linking a native EFI (i.e. PE/COFF) binary, hence its usage in this header."
This reads okay to me (perhaps with "the" inserted before "EFI macro").
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
In reply to Michal OrzelHi,
Quoted 37 lines · Michal Orzel
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Michal Orzel
Quoted 24 lines · Jan Beulich
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Jan Beulich
Quoted 3 lines · Julien Grall
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Quoted 7 lines
Quoted 2 lines
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.Quoted 8 lines
Quoted 2 lines
Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like
CONFIG_EFI?Let's call it a "virtual"
CONFIG_EFIthen; I think we really should have such an option. But yes, if you don't like referring to such a virtual option, then describing what is meant verbally is certainly going to be fine.
Quoted 7 lines
FWICS, there was an attempt done by Wei in his NUMA series to define
CONFIG_EFI. However as this is not yet merged and agreed, I would like not to refer to identifiers not existing in the code, even though most people are familiar with this option from Linux.So by taking an example from Linux I would verbally explain it like that:
"To avoid any confusion, please note that EFI macro does not correspond to EFI runtime support and is used when linking a native EFI (i.e. PE/COFF) binary, hence its
"EFI runtime support" can be mistakenly associated to EFI runtime services (which BTW not supported on Arm). So I would suggest to s/runtime/boot/.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 44 lines · Julien Grall
Hi,
Quoted 41 lines · Michal Orzel
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Michal Orzel
Quoted 24 lines · Jan Beulich
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Jan Beulich
Quoted 3 lines · Julien Grall
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Quoted 7 lines
Quoted 2 lines
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.Quoted 8 lines
Quoted 2 lines
Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like
CONFIG_EFI?Let's call it a "virtual"
CONFIG_EFIthen; I think we really should have such an option. But yes, if you don't like referring to such a virtual option, then describing what is meant verbally is certainly going to be fine.FWICS, there was an attempt done by Wei in his NUMA series to define
CONFIG_EFI. However as this is not yet merged and agreed, I would like not to refer to identifiers not existing in the code, even though most people are familiar with this option from Linux.
Quoted 7 lines
Quoted 3 lines
So by taking an example from Linux I would verbally explain it like that:
"To avoid any confusion, please note that EFI macro does not correspond to EFI runtime support and is used when linking a native EFI (i.e. PE/COFF) binary, hence its"EFI runtime support" can be mistakenly associated to EFI runtime services (which BTW not supported on Arm). So I would suggest to s/runtime/boot/.
Or simply just "EFI support"?
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 49 lines · Jan Beulich
Quoted 48 lines · Julien Grall
Hi,
Quoted 44 lines · Michal Orzel
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Michal Orzel
Quoted 24 lines · Jan Beulich
Quoted 12 lines · Michal Orzel
Quoted 11 lines · Jan Beulich
Quoted 3 lines · Julien Grall
Renaming to
PE_COFFmay help to avoid the confusion withCONFIG_EFI. That said, it would possibly make more difficult to associate the flag with "linking an EFI binary".Indeed. And
EFI_PE_COFFis getting a little unwieldy for my taste.Quoted 3 lines
I think some documentaion about the define EFI would be help so there are no more confusion between CONFIG_EFI/EFI. But I am not sure where to put it. Maybe at the top of the header?
Quoted 7 lines
Quoted 2 lines
That's perhaps the best place, yes.
In this case how about the following comment at the top of
xen.lds.h:"To avoid any confusion about EFI macro used in this header vs EFI support, the former is used when linking a native EFI (i.e. PE/COFF) binary, whereas the latter means support for generating EFI binary.
No, that's the case on Arm only. As Julien suggested, it is perhaps best to explain the difference between EFI and
CONFIG_EFI, without going into arch specifics.Quoted 8 lines
Quoted 2 lines
Could you please tell me what you are reffering to as there is no such identifier in Xen (as opposed to Linux) like
CONFIG_EFI?Let's call it a "virtual"
CONFIG_EFIthen; I think we really should have such an option. But yes, if you don't like referring to such a virtual option, then describing what is meant verbally is certainly going to be fine.FWICS, there was an attempt done by Wei in his NUMA series to define
CONFIG_EFI. However as this is not yet merged and agreed, I would like not to refer to identifiers not existing in the code, even though most people are familiar with this option from Linux.So by taking an example from Linux I would verbally explain it like that:
"To avoid any confusion, please note that EFI macro does not correspond to EFI runtime support and is used when linking a native EFI (i.e. PE/COFF) binary, hence its
Quoted 5 lines
Quoted 3 lines
"EFI runtime support" can be mistakenly associated to EFI runtime services (which BTW not supported on Arm). So I would suggest to s/runtime/boot/.
Or simply just "EFI support"?
That works for me.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
In reply to Julien GrallQuoted 7 lines · Julien Grall
Quoted 6 lines · Michal Orzel
xen/include/xen/xen.lds.h +0
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */
Quoted 8 lines
xen/include/xen/xen.lds.h line 9
Quoted 2 lines
xen/include/xen/xen.lds.h +2
-0+/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.As this #ifdef is now in generic code, can you explain how this is meant to be used?
The identifier may now be somewhat misleading, yes - it has always meant "linking a native EFI (i.e. PE/COFF) binary". The equivalence "EFI binary" == "EFI support" has long been lost.
Quoted 53 lines
Quoted 40 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \This is a bit confusing. Here you seem to use the section .comment. But...
Quoted 10 lines
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
xen/include/xen/xen.lds.h +7
-0+ .symtab 0 : { *(.symtab) } \ + .strtab 0 : { *(.strtab) } \ + .shstrtab 0 : { *(.shstrtab) } + +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \... here you will discard it if EFI is set. Which one take precedence if the caller use both
ELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION?
Given the above explanation I think it's clear that only one of the two may be used at a time: ELF_DETAILS_SECTIONS when linking an ELF binary and DISCARD_EFI_SECTIONS when linking a PE/COFF binary.
Jan
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Hi Jan,
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Julien Grall
xen/include/xen/xen.lds.h line 9
Quoted 8 lines · Michal Orzel
xen/include/xen/xen.lds.h +2
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.
Quoted 6 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
The identifier may now be somewhat misleading, yes - it has always meant "linking a native EFI (i.e. PE/COFF) binary". The equivalence "EFI binary" == "EFI support" has long been lost.
On Arm, we will be generating a EFI binary (or better a Image/EFI). So IIUC the description, we should in theory set EFI.
But I think it would do the wrong thing on Arm. Would you be able to explain why you need to differentiate it on x86?
Quoted 64 lines
Quoted 53 lines
Quoted 40 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \This is a bit confusing. Here you seem to use the section .comment. But...
Quoted 10 lines
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
xen/include/xen/xen.lds.h +7
-0+ .symtab 0 : { *(.symtab) } \ + .strtab 0 : { *(.strtab) } \ + .shstrtab 0 : { *(.shstrtab) } + +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \... here you will discard it if EFI is set. Which one take precedence if the caller use both
ELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION?
Quoted 3 lines
Given the above explanation I think it's clear that only one of the two may be used at a time:
ELF_DETAILS_SECTIONSwhen linking an ELF binary andDISCARD_EFI_SECTIONSwhen linking a PE/COFF binary.
I guess this may be obvious on x86. But for Arm, we are generating the ELF first and then extracting the information to generate the binary. The end result will be a binary that is PE/COFF compatible.
So to me, it would make sense to include DISCARD_EFI_SECTIONS because we going to create an EFI binary and also include EFI_DETAILS_SECTIONS because we are building an ELF.
Overall it sounds like to me that it is too premature to move the #if{,n}def EFI bits in the generic header.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v2 2/2] xen: Populate xen.lds.h and make use of its macros
Quoted 15 lines · Julien Grall
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Julien Grall
xen/include/xen/xen.lds.h line 9
Quoted 8 lines · Michal Orzel
xen/include/xen/xen.lds.h +2
-0@@ -5,4 +5,104 @@* Common macros to be used in architecture specific linker scripts. */ +/* Macros to declare debug sections. */ +#ifdef EFI AFAIK, we don't define EFI on Arm (just
CONFIG_EFI). Yet we do support EFI on arm64.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
As this #ifdef is now in generic code, can you explain how this is meant to be used?
The identifier may now be somewhat misleading, yes - it has always meant "linking a native EFI (i.e. PE/COFF) binary". The equivalence "EFI binary" == "EFI support" has long been lost.
On Arm, we will be generating a EFI binary (or better a Image/EFI). So IIUC the description, we should in theory set EFI.
Well, no - you're mixing up "generating" and "linking". What's of interest here is what the linker is told to produce, not what may involved further processing steps. We're talking about a linker script here, after all.
Quoted 2 lines
But I think it would do the wrong thing on Arm. Would you be able to explain why you need to differentiate it on x86?
The differences aren't unique to x86; they all are related to how ELF and PE/COFF differ from one another.
Quoted 68 lines
Quoted 64 lines
Quoted 53 lines
Quoted 40 lines
xen/include/xen/xen.lds.h +40
-0+/* +* 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) } \xen/include/xen/xen.lds.h line 59
Quoted 10 lines
xen/include/xen/xen.lds.h +10
-0+ .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) } \This is a bit confusing. Here you seem to use the section .comment. But...
Quoted 10 lines
xen/include/xen/xen.lds.h line 66
Quoted 7 lines
xen/include/xen/xen.lds.h +7
-0+ .symtab 0 : { *(.symtab) } \ + .strtab 0 : { *(.strtab) } \ + .shstrtab 0 : { *(.shstrtab) } + +#ifdef EFI +#define DISCARD_EFI_SECTIONS \ + *(.comment) \... here you will discard it if EFI is set. Which one take precedence if the caller use both
ELF_DETAILS_SECTIONSandDISCARD_EFI_SECTION?Quoted 3 lines
Given the above explanation I think it's clear that only one of the two may be used at a time:
ELF_DETAILS_SECTIONSwhen linking an ELF binary andDISCARD_EFI_SECTIONSwhen linking a PE/COFF binary.
Quoted 7 lines
I guess this may be obvious on x86. But for Arm, we are generating the ELF first and then extracting the information to generate the binary. The end result will be a binary that is PE/COFF compatible.
So to me, it would make sense to include
DISCARD_EFI_SECTIONSbecause we going to create an EFI binary and also includeEFI_DETAILS_SECTIONSbecause we are building an ELF.
No - as per above, all we should be concerned about in the linker script are requirements by the linker for linking a file in the request output format.
Jan
Hi Jan,
Could you please review this series as you did give some comments in v1?
Quoted 16 lines · Michal Orzel
This patch series aims to do the first step towards linker scripts synchronization. Linker scripts for arm and x86 share a lot of common sections and in order to make the process of changing/improving/syncing them, these sections shall be defined in just one place.
The first patch creates an empty header file
xen.lds.hto store the constructs mutual to both x86 and arm linker scripts. It also includes this header in the scripts.The second patch populates
xen.lds.hwith the first portion of common macros and replaces the original contructs with these helpers.Michal Orzel (2):
xen: Introduce a header to store common linker scripts content
xen: Populatexen.lds.hand make use of its macros
Quoted 6 lines
xen/arch/arm/xen.lds.S | 38 +++++--------- xen/arch/x86/xen.lds.S | 79 +++------------------------- xen/include/xen/xen.lds.h | 108 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 96 deletions(-) create mode 100644 xen/include/xen/xen.lds.h
Cheers,
Michal
Quoted 1 line · Michal Orzel
Could you please review this series as you did give some comments in v1?
I have it on my list of things to look at, yes.
Jan
Quoted 27 lines · Michal Orzel
Quoted 16 lines
This patch series aims to do the first step towards linker scripts synchronization. Linker scripts for arm and x86 share a lot of common sections and in order to make the process of changing/improving/syncing them, these sections shall be defined in just one place.
The first patch creates an empty header file
xen.lds.hto store the constructs mutual to both x86 and arm linker scripts. It also includes this header in the scripts.The second patch populates
xen.lds.hwith the first portion of common macros and replaces the original contructs with these helpers.Michal Orzel (2):
xen: Introduce a header to store common linker scripts content
xen: Populatexen.lds.hand make use of its macrosQuoted 6 lines
xen/arch/arm/xen.lds.S | 38 +++++--------- xen/arch/x86/xen.lds.S | 79 +++------------------------- xen/include/xen/xen.lds.h | 108 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 96 deletions(-) create mode 100644 xen/include/xen/xen.lds.hCheers,
Michal