eliminate some section start symbols
cover eliminate some section start symbols
Section start symbols frequently obscure the actual symbol name living at the start of the section. Eliminate them where they can be replaced by linker resolved .startof.* symbols. (Section end symbols may have the same undesirable effect, but they're less easy to eliminate, as they'd need to be represented by the sum of .startof.<section> and .sizeof.<section>).
1: x86: force suitable alignment in sources rather than in linker script 2: make use of .startof.() and .sizeof.() assembler expressions
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/2 x86: force suitable alignment in sources rather than in linker script
Besides being more logical this also allows verifying correct recording of alignments in .o files.
The cpu0_stack related ASSERT() in xen.lds.S is now of questionable value (as it now verifies correct tool chain behavior), but I've left it in nevertheless.
xen/arch/x86/hvm/hvm.c +1 -0
@@ -89,6 +89,7 @@ struct hvm_function_table hvm_funcs __re*/ #define HVM_IOBITMAP_SIZE (3 * PAGE_SIZE) unsigned long __section(".bss.page_aligned") + __attribute__((aligned (PAGE_SIZE ))) hvm_io_bitmap[HVM_IOBITMAP_SIZE / BYTES_PER_LONG];/* Xen command-line option to enable HAP */
xen/arch/x86/mm.c +4 -2
@@ -125,7 +125,8 @@#include <asm/pci.h> /* Mapping of the fixmap space needed early. */ -l1_pgentry_t __section(".bss.page_aligned") l1_fixmap[L1_PAGETABLE_ENTRIES]; +l1_pgentry_t __section(".bss.page_aligned") __attribute__((aligned(PAGE_SIZE))) + l1_fixmap[L1_PAGETABLE_ENTRIES]; #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING , _f "\n" , ## _a)
@@ -588,7 +589,8 @@ static inline void guest_get_eff_kern_l1TOGGLE_MODE (); } -const char __section(".bss.page_aligned.const") zero_page[PAGE_SIZE]; +const char __section(".bss.page_aligned.const") + __attribute__((aligned(PAGE_SIZE))) zero_page[PAGE_SIZE];static void invalidate_shadow_ldt (struct vcpu *v,int flush) {
xen/arch/x86/setup.c +2 -1
@@ -105,7 +105,8 @@ unsigned long __read_mostly xen_virt_end DEFINE_PER_CPU(struct tss_struct, init_tss); -char __section(".bss.stack_aligned") cpu0_stack[STACK_SIZE]; +char __section(".bss.stack_aligned") __attribute__((aligned(STACK_SIZE))) + cpu0_stack[STACK_SIZE];struct cpuinfo_x86 __read_mostly boot_cpu_data = {0 ,0 ,0 ,0 ,-1 };
xen/arch/x86/xen.lds.S +0 -3
@@ -222,7 +222,6 @@ SECTIONS } :text .data : { /* Data */ - . = ALIGN(PAGE_SIZE); *(.data.page_aligned) *(.data) *(.data.rel)
@@ -231,10 +230,8 @@ SECTIONS } :text .bss : { /* BSS */ - . = ALIGN(STACK_SIZE); __bss_start = .; *(.bss.stack_aligned) - . = ALIGN(PAGE_SIZE); *(.bss.page_aligned*) *(.bss) . = ALIGN(SMP_CACHE_BYTES);
x86: force suitable alignment in sources rather than in linker script
Besides being more logical this also allows verifying correct recording of alignments in .o files.
The cpu0_stack related ASSERT() in xen.lds.S is now of questionable value (as it now verifies correct tool chain behavior), but I've left it in nevertheless.
xen/arch/x86/hvm/hvm.c +1 -0
@@ -89,6 +89,7 @@ struct hvm_function_table hvm_funcs __re*/ #define HVM_IOBITMAP_SIZE (3 * PAGE_SIZE) unsigned long __section(".bss.page_aligned") + __attribute__((aligned (PAGE_SIZE ))) hvm_io_bitmap[HVM_IOBITMAP_SIZE / BYTES_PER_LONG];/* Xen command-line option to enable HAP */
xen/arch/x86/mm.c +4 -2
@@ -125,7 +125,8 @@#include <asm/pci.h> /* Mapping of the fixmap space needed early. */ -l1_pgentry_t __section(".bss.page_aligned") l1_fixmap[L1_PAGETABLE_ENTRIES]; +l1_pgentry_t __section(".bss.page_aligned") __attribute__((aligned(PAGE_SIZE))) + l1_fixmap[L1_PAGETABLE_ENTRIES]; #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING , _f "\n" , ## _a)
@@ -588,7 +589,8 @@ static inline void guest_get_eff_kern_l1TOGGLE_MODE (); } -const char __section(".bss.page_aligned.const") zero_page[PAGE_SIZE]; +const char __section(".bss.page_aligned.const") + __attribute__((aligned(PAGE_SIZE))) zero_page[PAGE_SIZE];static void invalidate_shadow_ldt (struct vcpu *v,int flush) {
xen/arch/x86/setup.c +2 -1
@@ -105,7 +105,8 @@ unsigned long __read_mostly xen_virt_end DEFINE_PER_CPU(struct tss_struct, init_tss); -char __section(".bss.stack_aligned") cpu0_stack[STACK_SIZE]; +char __section(".bss.stack_aligned") __attribute__((aligned(STACK_SIZE))) + cpu0_stack[STACK_SIZE];struct cpuinfo_x86 __read_mostly boot_cpu_data = {0 ,0 ,0 ,0 ,-1 };
xen/arch/x86/xen.lds.S +0 -3
@@ -222,7 +222,6 @@ SECTIONS } :text .data : { /* Data */ - . = ALIGN(PAGE_SIZE); *(.data.page_aligned) *(.data) *(.data.rel)
@@ -231,10 +230,8 @@ SECTIONS } :text .bss : { /* BSS */ - . = ALIGN(STACK_SIZE); __bss_start = .; *(.bss.stack_aligned) - . = ALIGN(PAGE_SIZE); *(.bss.page_aligned*) *(.bss) . = ALIGN(SMP_CACHE_BYTES);
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
Quoted 12 lines · Jan Beulich
Besides being more logical this also allows verifying correct recording of alignments in .o files.
The
cpu0_stackrelatedASSERT()inxen.lds.Sis now of questionable value (as it now verifies correct tool chain behavior), but I've left it in nevertheless.Signed-off-by Jan Beulich <[email protected]>
xen/arch/x86/hvm/hvm.c struct hvm_function_table hvm_funcs __re · line 92
Quoted 4 lines
xen/arch/x86/hvm/hvm.c +1
-0@@ -89,6 +89,7 @@ struct hvm_function_table hvm_funcs __re*/ #define HVM_IOBITMAP_SIZE (3 * PAGE_SIZE) unsigned long __section(".bss.page_aligned") + __attribute__((aligned(PAGE_SIZE)))
Can I talk you into introducing #define __aligned(x) __attribute__((aligned(x))) in compiler.h ?
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 12.08.16 at 17:02, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Besides being more logical this also allows verifying correct recording of alignments in .o files.
The
cpu0_stackrelatedASSERT()inxen.lds.Sis now of questionable value (as it now verifies correct tool chain behavior), but I've left it in nevertheless.Signed-off-by Jan Beulich <[email protected]>
Quoted 10 lines
xen/arch/x86/hvm/hvm.c struct hvm_function_table hvm_funcs __re · line 92
Quoted 7 lines
xen/arch/x86/hvm/hvm.c +1
-0@@ -89,6 +89,7 @@ struct hvm_function_table hvm_funcs __re*/ #define HVM_IOBITMAP_SIZE (3 * PAGE_SIZE) unsigned long __section(".bss.page_aligned") + __attribute__((aligned(PAGE_SIZE)))Can I talk you into introducing #define
__aligned(x)__attribute__((aligned(x))) incompiler.h?
Sure, I was on the edge of introducing it while putting this together anyway, but then thought it's maybe not worth it.
Quoted 1 line
Otherwise, Reviewed-by: Andrew Cooper <[email protected]>
Thanks, Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
Quoted 20 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 12.08.16 at 17:02, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Besides being more logical this also allows verifying correct recording of alignments in .o files.
The
cpu0_stackrelatedASSERT()inxen.lds.Sis now of questionable value (as it now verifies correct tool chain behavior), but I've left it in nevertheless.Signed-off-by Jan Beulich <[email protected]>Quoted 9 lines
xen/arch/x86/hvm/hvm.c struct hvm_function_table hvm_funcs __re · line 92
Quoted 7 lines
xen/arch/x86/hvm/hvm.c +1
-0@@ -89,6 +89,7 @@ struct hvm_function_table hvm_funcs __re*/ #define HVM_IOBITMAP_SIZE (3 * PAGE_SIZE) unsigned long __section(".bss.page_aligned") + __attribute__((aligned(PAGE_SIZE)))Can I talk you into introducing #define
__aligned(x)__attribute__((aligned(x))) incompiler.h?
Quoted 2 lines
Sure, I was on the edge of introducing it while putting this together anyway, but then thought it's maybe not worth it.
I have been meaning to do it for a while, and clean up the existing opencoded uses in the tree.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/2 make use of .startof.() and .sizeof.() assembler expressions
In reply to Jan BeulichSection start symbols frequently obscure the actual symbol name living at the start of the section. Eliminate them where they can be replaced by linker resolved .startof.* symbols. (Section end symbols may have the same undesirable effect, but they're less easy to eliminate, as they'd need to be represented by the sum of .startof.<section> and .sizeof.<section>).
Along those lines use .sizeof.* where section sizes get calculated from the difference of section and and section start symbols.
Note that this would be nice for the build-id section too, but:
- The generated (by ld) section names differ between ELF and COFF/PE (ELF: .note.gnu.build-id; COFF/PE[2.26+]: .buildid), yet we compile version.c just once (and hence can use only either of the necessary .startof./.sizeof. forms).
- The ELF section name needs to be quoted in the .startof./.sizeof. expressions, yet that quoting is supported only by gas 2.26+.
xen/arch/arm/arm32/head.S +3 -3
@@ -184,10 +184,10 @@ hyp: PRINT("- Xen starting in Hyp mod bne skip_bss PRINT("- Zero BSS -\r\n") - ldr r0, =__bss_start /* Load start & end of bss */ - ldr r1, =__bss_end + ldr r0, =.startof.(.bss) /* Load start & size of bss */ + ldr r1, =.sizeof.(.bss) add r0, r0, r10 /* Apply physical offset */ - add r1, r1, r10 + add r1, r1, r0 /* Calculate end of bss */ mov r2, #0 1: str r2, [r0], #4
xen/arch/arm/arm64/head.S +3 -3
@@ -318,10 +318,10 @@ el2: PRINT("- Xen starting at EL2 -\r cbnz x22, skip_bss PRINT("- Zero BSS -\r\n") - ldr x0, =__bss_start /* Load start & end of bss */ - ldr x1, =__bss_end + ldr x0, =.startof.(.bss) /* Load start & size of bss */ + ldr x1, =.sizeof.(.bss) add x0, x0, x20 /* Apply physical offset */ - add x1, x1, x20 + add x1, x1, x0 /* Calculate end of .bss */ 1: str xzr, [x0], #8 cmp x0, x1
xen/arch/arm/device.c +9 -2
@@ -21,8 +21,8 @@#include <xen/errno.h> #include <xen/lib.h> -extern const struct device_desc _sdevice[], _edevice[]; -extern const struct acpi_device_desc _asdevice[], _aedevice[]; +extern const struct device_desc _sdevice[] asm(".startof.(.dev.info)" ); +extern const struct device_desc _edevice[];int __init device_init (struct dt_device_node *dev,enum device_class class,const void *data)
@@ -51,6 +51,11 @@ int __init device_init(struct dt_device_return -EBADF ; } +#ifdef CONFIG_ACPI + +extern const struct acpi_device_desc _asdevice[] asm(".startof.(.adev.info)" ); +extern const struct acpi_device_desc _aedevice[]; +int __init acpi_device_init (enum device_class class,const void *data,int class_type) {const struct acpi_device_desc *desc;
@@ -68,6 +73,8 @@ int __init acpi_device_init(enum device_ return -EBADF; } +#endif +enum device_class device_get_class (const struct dt_device_node *dev) {const struct device_desc *desc;
xen/arch/arm/domain_build.c +1 -1
@@ -2058,7 +2058,7 @@ static void __init find_gnttab_region(st* enough space for a large grant table */ kinfo->gnttab_start =__pa (_stext); - kinfo->gnttab_size = (_etext - _stext) &PAGE_MASK ; + kinfo->gnttab_size = _sizeof_text &PAGE_MASK ;/* Make sure the grant table will fit in the region */ if ( (kinfo->gnttab_size >>PAGE_SHIFT ) < max_grant_frames )
xen/arch/arm/platform.c +2 -1
@@ -22,7 +22,8 @@#include <xen/init.h> #include <asm/psci.h> -extern const struct platform_desc _splatform[], _eplatform[]; +extern const struct platform_desc _splatform[] asm(".startof.(.arch.info)" ); +extern const struct platform_desc _eplatform[];/* Pointer to the current platform description */ static const struct platform_desc *platform;
xen/arch/arm/xen.lds.S +0 -8
@@ -31,7 +31,6 @@ SECTIONS . = XEN_VIRT_START; _start = .; .text : /* XXX should be AT ( XEN_PHYS_START ) */ { - _stext = .; /* Text section */ *(.text) *(.text.cold) *(.text.unlikely)
@@ -42,7 +41,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); .rodata : { - _srodata = .; /* Read-only data */ /* Bug frames table */ __start_bug_frames = .; *(.bug_frames.0)
@@ -104,21 +102,18 @@ SECTIONS . = ALIGN(8); .arch.info : { - _splatform = .; *(.arch.info) _eplatform = .; } :text . = ALIGN(8); .dev.info : { - _sdevice = .; *(.dev.info) _edevice = .; } :text . = ALIGN(8); .adev.info : { - _asdevice = .; *(.adev.info) _aedevice = .; } :text
@@ -126,7 +121,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : { - _sinittext = .; *(.init.text) _einittext = .; } :text
@@ -174,7 +168,6 @@ SECTIONS __init_end = .; .bss : { /* BSS */ - __bss_start = .; *(.bss.stack_aligned) . = ALIGN(PAGE_SIZE); *(.bss.page_aligned)
@@ -186,7 +179,6 @@ SECTIONS *(.bss.percpu.read_mostly) . = ALIGN(SMP_CACHE_BYTES); __per_cpu_data_end = .; - __bss_end = .; } :text _end = . ;
xen/arch/x86/boot/head.S +2 -3
@@ -124,9 +124,8 @@ __start: mov %eax,sym_phys(multiboot_ptr) /* Initialize BSS (no nasty surprises!) */ - mov $sym_phys(__bss_start),%edi - mov $sym_phys(__bss_end),%ecx - sub %edi,%ecx + mov $sym_phys(.startof.(.bss)),%edi + mov $.sizeof.(.bss),%ecx xor %eax,%eax shr $2,%ecx rep stosl
xen/arch/x86/setup.c +1 -1
@@ -181,7 +181,7 @@ void __init discard_initial_images(void) initial_images =NULL ; } -extern char __init_begin[], __init_end[], __bss_start[], __bss_end[]; +extern char __init_begin[], __init_end[], __bss_end[];static void __init init_idle_domain (void ) {
xen/arch/x86/tboot.c +7 -2
@@ -48,7 +48,7 @@ static uint64_t __initdata sinit_base, _#define TXTCR_HEAP_BASE 0x0300#define TXTCR_HEAP_SIZE 0x0308 -extern char __init_begin[], __bss_start[], __bss_end[]; +extern char __init_begin[];#define SHA1_SIZE 20typedef uint8_t sha1_hash_t [SHA1_SIZE ];
@@ -376,7 +376,12 @@ void tboot_shutdown(uint32_t shutdown_ty__pa (&_stext);/* bss */ g_tboot_shared->mac_regions[2 ].start = (uint64_t )__pa (&__bss_start); - g_tboot_shared->mac_regions[2 ].size =__pa (&__bss_end) -__pa (&__bss_start); +#if 0 /* This doesn't work due to -fPIC. */ + g_tboot_shared->mac_regions[2 ].size = _sizeof_bss; +#else + asm ("movl $.sizeof.(.bss),%0" + :"=m" (g_tboot_shared->mac_regions[2 ].size) ); +#endif /* * MAC domains and other Xen memory
xen/arch/x86/xen.lds.S +2 -6
@@ -58,7 +58,6 @@ SECTIONS . = __XEN_VIRT_START + MB(1); _start = .; .text : { - _stext = .; /* Text and read-only data */ *(.text) *(.text.cold) *(.text.unlikely)
@@ -77,7 +76,6 @@ SECTIONS __2M_rodata_start = .; /* Start of 2M superpages, mapped RO. */ .rodata : { - _srodata = .; /* Bug frames table */ . = ALIGN(4); __start_bug_frames = .;
@@ -149,7 +147,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : { - _sinittext = .; *(.init.text) /* * Here are the replacement instructions. The linker sticks them
@@ -230,7 +227,6 @@ SECTIONS } :text .bss : { /* BSS */ - __bss_start = .; *(.bss.stack_aligned) *(.bss.page_aligned*) *(.bss)
@@ -323,5 +319,5 @@ ASSERT(IS_ALIGNED(__init_end, PAGE_SIZ ASSERT(IS_ALIGNED(trampoline_start, 4), "trampoline_start misaligned") ASSERT(IS_ALIGNED(trampoline_end, 4), "trampoline_end misaligned") -ASSERT(IS_ALIGNED(__bss_start, 4), "__bss_start misaligned") -ASSERT(IS_ALIGNED(__bss_end, 4), "__bss_end misaligned") +ASSERT(IS_ALIGNED(.startof..bss, 4), ".bss misaligned") +ASSERT(IS_ALIGNED(.sizeof..bss, 4), ".bss size misaligned")
xen/include/xen/kernel.h +13 -3
@@ -71,24 +71,34 @@ extern char _start[], _end[], start[]; (__p >= _start) && (__p < _end); \ }) -extern char _stext[], _etext[]; +extern const char _stext[] asm(".startof.(.text)" ); +extern const char _etext[];#define is_kernel_text (p) ({ \ char *__p = (char *)(unsigned long)(p); \ (__p >= _stext) && (__p < _etext); \ }) -extern const char _srodata[], _erodata[]; +extern const char _sizeof_text[] asm(".sizeof.(.text)" ); +#define _sizeof_text ((unsigned long)_sizeof_text) + +extern const char _srodata[] asm(".startof.(.rodata)" ); +extern const char _erodata[];#define is_kernel_rodata (p) ({ \ const char *__p = (const char *)(unsigned long)(p); \ (__p >= _srodata) && (__p < _erodata); \ }) -extern char _sinittext[], _einittext[]; +extern const char _sinittext[] asm(".startof.(.init.text)" ); +extern const char _einittext[];#define is_kernel_inittext (p) ({ \ char *__p = (char *)(unsigned long)(p); \ (__p >= _sinittext) && (__p < _einittext); \ }) +extern char __bss_start[] asm(".startof.(.bss)" ); +extern const char _sizeof_bss[] asm(".sizeof.(.bss)" ); +#define _sizeof_bss ((unsigned long)_sizeof_bss) + extern enum system_state { SYS_STATE_early_boot, SYS_STATE_boot,
xen/tools/symbols.c +6 -2
@@ -143,11 +143,12 @@ static int read_symbol(FILE *in, struct sym++;/* Ignore most absolute/undefined (?) symbols. */ -if (strcmp (sym,"_stext" ) ==0 ) +if (strcmp (sym,"_stext" ) ==0 ||strcmp (sym,".startof..text" ) ==0 ) _stext = s->addr;else if (strcmp (sym,"_etext" ) ==0 ) _etext = s->addr; -else if (strcmp (sym,"_sinittext" ) ==0 ) +else if (strcmp (sym,"_sinittext" ) ==0 || +strcmp (sym,".startof..init.text" ) ==0 ) _sinittext = s->addr;else if (strcmp (sym,"_einittext" ) ==0 ) _einittext = s->addr;
@@ -168,6 +169,9 @@ static int read_symbol(FILE *in, struct/* exclude also MIPS ELF local symbols ($L123 instead of .L123) */ else if (str[0] == '$') goto skip_tail; +/* Also strip .startof. symbols. */ +if (strncmp (sym,".startof." ,9 ) ==0 ) + goto skip_tail;/* include the type field in the symbol name, so that it gets * compressed together */
make use of .startof.() and .sizeof.() assembler expressions
Section start symbols frequently obscure the actual symbol name living at the start of the section. Eliminate them where they can be replaced by linker resolved .startof.* symbols. (Section end symbols may have the same undesirable effect, but they're less easy to eliminate, as they'd need to be represented by the sum of .startof.<section> and .sizeof.<section>).
Along those lines use .sizeof.* where section sizes get calculated from the difference of section and and section start symbols.
Note that this would be nice for the build-id section too, but:
- The generated (by ld) section names differ between ELF and COFF/PE (ELF: .note.gnu.build-id; COFF/PE[2.26+]: .buildid), yet we compile version.c just once (and hence can use only either of the necessary .startof./.sizeof. forms).
- The ELF section name needs to be quoted in the .startof./.sizeof. expressions, yet that quoting is supported only by gas 2.26+.
xen/arch/arm/arm32/head.S +3 -3
@@ -184,10 +184,10 @@ hyp: PRINT("- Xen starting in Hyp mod bne skip_bss PRINT("- Zero BSS -\r\n") - ldr r0, =__bss_start /* Load start & end of bss */ - ldr r1, =__bss_end + ldr r0, =.startof.(.bss) /* Load start & size of bss */ + ldr r1, =.sizeof.(.bss) add r0, r0, r10 /* Apply physical offset */ - add r1, r1, r10 + add r1, r1, r0 /* Calculate end of bss */ mov r2, #0 1: str r2, [r0], #4
xen/arch/arm/arm64/head.S +3 -3
@@ -318,10 +318,10 @@ el2: PRINT("- Xen starting at EL2 -\r cbnz x22, skip_bss PRINT("- Zero BSS -\r\n") - ldr x0, =__bss_start /* Load start & end of bss */ - ldr x1, =__bss_end + ldr x0, =.startof.(.bss) /* Load start & size of bss */ + ldr x1, =.sizeof.(.bss) add x0, x0, x20 /* Apply physical offset */ - add x1, x1, x20 + add x1, x1, x0 /* Calculate end of .bss */ 1: str xzr, [x0], #8 cmp x0, x1
xen/arch/arm/device.c +9 -2
@@ -21,8 +21,8 @@#include <xen/errno.h> #include <xen/lib.h> -extern const struct device_desc _sdevice[], _edevice[]; -extern const struct acpi_device_desc _asdevice[], _aedevice[]; +extern const struct device_desc _sdevice[] asm(".startof.(.dev.info)" ); +extern const struct device_desc _edevice[];int __init device_init (struct dt_device_node *dev,enum device_class class,const void *data)
@@ -51,6 +51,11 @@ int __init device_init(struct dt_device_return -EBADF ; } +#ifdef CONFIG_ACPI + +extern const struct acpi_device_desc _asdevice[] asm(".startof.(.adev.info)" ); +extern const struct acpi_device_desc _aedevice[]; +int __init acpi_device_init (enum device_class class,const void *data,int class_type) {const struct acpi_device_desc *desc;
@@ -68,6 +73,8 @@ int __init acpi_device_init(enum device_ return -EBADF; } +#endif +enum device_class device_get_class (const struct dt_device_node *dev) {const struct device_desc *desc;
xen/arch/arm/domain_build.c +1 -1
@@ -2058,7 +2058,7 @@ static void __init find_gnttab_region(st* enough space for a large grant table */ kinfo->gnttab_start =__pa (_stext); - kinfo->gnttab_size = (_etext - _stext) &PAGE_MASK ; + kinfo->gnttab_size = _sizeof_text &PAGE_MASK ;/* Make sure the grant table will fit in the region */ if ( (kinfo->gnttab_size >>PAGE_SHIFT ) < max_grant_frames )
xen/arch/arm/platform.c +2 -1
@@ -22,7 +22,8 @@#include <xen/init.h> #include <asm/psci.h> -extern const struct platform_desc _splatform[], _eplatform[]; +extern const struct platform_desc _splatform[] asm(".startof.(.arch.info)" ); +extern const struct platform_desc _eplatform[];/* Pointer to the current platform description */ static const struct platform_desc *platform;
xen/arch/arm/xen.lds.S +0 -8
@@ -31,7 +31,6 @@ SECTIONS . = XEN_VIRT_START; _start = .; .text : /* XXX should be AT ( XEN_PHYS_START ) */ { - _stext = .; /* Text section */ *(.text) *(.text.cold) *(.text.unlikely)
@@ -42,7 +41,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); .rodata : { - _srodata = .; /* Read-only data */ /* Bug frames table */ __start_bug_frames = .; *(.bug_frames.0)
@@ -104,21 +102,18 @@ SECTIONS . = ALIGN(8); .arch.info : { - _splatform = .; *(.arch.info) _eplatform = .; } :text . = ALIGN(8); .dev.info : { - _sdevice = .; *(.dev.info) _edevice = .; } :text . = ALIGN(8); .adev.info : { - _asdevice = .; *(.adev.info) _aedevice = .; } :text
@@ -126,7 +121,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : { - _sinittext = .; *(.init.text) _einittext = .; } :text
@@ -174,7 +168,6 @@ SECTIONS __init_end = .; .bss : { /* BSS */ - __bss_start = .; *(.bss.stack_aligned) . = ALIGN(PAGE_SIZE); *(.bss.page_aligned)
@@ -186,7 +179,6 @@ SECTIONS *(.bss.percpu.read_mostly) . = ALIGN(SMP_CACHE_BYTES); __per_cpu_data_end = .; - __bss_end = .; } :text _end = . ;
xen/arch/x86/boot/head.S +2 -3
@@ -124,9 +124,8 @@ __start: mov %eax,sym_phys(multiboot_ptr) /* Initialize BSS (no nasty surprises!) */ - mov $sym_phys(__bss_start),%edi - mov $sym_phys(__bss_end),%ecx - sub %edi,%ecx + mov $sym_phys(.startof.(.bss)),%edi + mov $.sizeof.(.bss),%ecx xor %eax,%eax shr $2,%ecx rep stosl
xen/arch/x86/setup.c +1 -1
@@ -181,7 +181,7 @@ void __init discard_initial_images(void) initial_images =NULL ; } -extern char __init_begin[], __init_end[], __bss_start[], __bss_end[]; +extern char __init_begin[], __init_end[], __bss_end[];static void __init init_idle_domain (void ) {
xen/arch/x86/tboot.c +7 -2
@@ -48,7 +48,7 @@ static uint64_t __initdata sinit_base, _#define TXTCR_HEAP_BASE 0x0300#define TXTCR_HEAP_SIZE 0x0308 -extern char __init_begin[], __bss_start[], __bss_end[]; +extern char __init_begin[];#define SHA1_SIZE 20typedef uint8_t sha1_hash_t [SHA1_SIZE ];
@@ -376,7 +376,12 @@ void tboot_shutdown(uint32_t shutdown_ty__pa (&_stext);/* bss */ g_tboot_shared->mac_regions[2 ].start = (uint64_t )__pa (&__bss_start); - g_tboot_shared->mac_regions[2 ].size =__pa (&__bss_end) -__pa (&__bss_start); +#if 0 /* This doesn't work due to -fPIC. */ + g_tboot_shared->mac_regions[2 ].size = _sizeof_bss; +#else + asm ("movl $.sizeof.(.bss),%0" + :"=m" (g_tboot_shared->mac_regions[2 ].size) ); +#endif /* * MAC domains and other Xen memory
xen/arch/x86/xen.lds.S +2 -6
@@ -58,7 +58,6 @@ SECTIONS . = __XEN_VIRT_START + MB(1); _start = .; .text : { - _stext = .; /* Text and read-only data */ *(.text) *(.text.cold) *(.text.unlikely)
@@ -77,7 +76,6 @@ SECTIONS __2M_rodata_start = .; /* Start of 2M superpages, mapped RO. */ .rodata : { - _srodata = .; /* Bug frames table */ . = ALIGN(4); __start_bug_frames = .;
@@ -149,7 +147,6 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; .init.text : { - _sinittext = .; *(.init.text) /* * Here are the replacement instructions. The linker sticks them
@@ -230,7 +227,6 @@ SECTIONS } :text .bss : { /* BSS */ - __bss_start = .; *(.bss.stack_aligned) *(.bss.page_aligned*) *(.bss)
@@ -323,5 +319,5 @@ ASSERT(IS_ALIGNED(__init_end, PAGE_SIZ ASSERT(IS_ALIGNED(trampoline_start, 4), "trampoline_start misaligned") ASSERT(IS_ALIGNED(trampoline_end, 4), "trampoline_end misaligned") -ASSERT(IS_ALIGNED(__bss_start, 4), "__bss_start misaligned") -ASSERT(IS_ALIGNED(__bss_end, 4), "__bss_end misaligned") +ASSERT(IS_ALIGNED(.startof..bss, 4), ".bss misaligned") +ASSERT(IS_ALIGNED(.sizeof..bss, 4), ".bss size misaligned")
xen/include/xen/kernel.h +13 -3
@@ -71,24 +71,34 @@ extern char _start[], _end[], start[]; (__p >= _start) && (__p < _end); \ }) -extern char _stext[], _etext[]; +extern const char _stext[] asm(".startof.(.text)" ); +extern const char _etext[];#define is_kernel_text (p) ({ \ char *__p = (char *)(unsigned long)(p); \ (__p >= _stext) && (__p < _etext); \ }) -extern const char _srodata[], _erodata[]; +extern const char _sizeof_text[] asm(".sizeof.(.text)" ); +#define _sizeof_text ((unsigned long)_sizeof_text) + +extern const char _srodata[] asm(".startof.(.rodata)" ); +extern const char _erodata[];#define is_kernel_rodata (p) ({ \ const char *__p = (const char *)(unsigned long)(p); \ (__p >= _srodata) && (__p < _erodata); \ }) -extern char _sinittext[], _einittext[]; +extern const char _sinittext[] asm(".startof.(.init.text)" ); +extern const char _einittext[];#define is_kernel_inittext (p) ({ \ char *__p = (char *)(unsigned long)(p); \ (__p >= _sinittext) && (__p < _einittext); \ }) +extern char __bss_start[] asm(".startof.(.bss)" ); +extern const char _sizeof_bss[] asm(".sizeof.(.bss)" ); +#define _sizeof_bss ((unsigned long)_sizeof_bss) + extern enum system_state { SYS_STATE_early_boot, SYS_STATE_boot,
xen/tools/symbols.c +6 -2
@@ -143,11 +143,12 @@ static int read_symbol(FILE *in, struct sym++;/* Ignore most absolute/undefined (?) symbols. */ -if (strcmp (sym,"_stext" ) ==0 ) +if (strcmp (sym,"_stext" ) ==0 ||strcmp (sym,".startof..text" ) ==0 ) _stext = s->addr;else if (strcmp (sym,"_etext" ) ==0 ) _etext = s->addr; -else if (strcmp (sym,"_sinittext" ) ==0 ) +else if (strcmp (sym,"_sinittext" ) ==0 || +strcmp (sym,".startof..init.text" ) ==0 ) _sinittext = s->addr;else if (strcmp (sym,"_einittext" ) ==0 ) _einittext = s->addr;
@@ -168,6 +169,9 @@ static int read_symbol(FILE *in, struct/* exclude also MIPS ELF local symbols ($L123 instead of .L123) */ else if (str[0] == '$') goto skip_tail; +/* Also strip .startof. symbols. */ +if (strncmp (sym,".startof." ,9 ) ==0 ) + goto skip_tail;/* include the type field in the symbol name, so that it gets * compressed together */
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions
Quoted 18 lines · Jan Beulich
Section start symbols frequently obscure the actual symbol name living at the start of the section. Eliminate them where they can be replaced by linker resolved .startof.* symbols. (Section end symbols may have the same undesirable effect, but they're less easy to eliminate, as they'd need to be represented by the sum of .startof.<section> and .sizeof.<section>).
Along those lines use .sizeof.* where section sizes get calculated from the difference of section and and section start symbols.
Note that this would be nice for the build-id section too, but:
- The generated (by ld) section names differ between ELF and COFF/PE (ELF: .note.gnu.build-id; COFF/PE[2.26+]: .buildid), yet we compileversion.cjust once (and hence can use only either of the necessary .startof./.sizeof. forms).
- The ELF section name needs to be quoted in the .startof./.sizeof. expressions, yet that quoting is supported only by gas 2.26+.
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>
Is there any documentation of these? I cant seem to find any.
Does this work on Clang at all?
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 15.08.16 at 11:43, <[email protected]> wrote:
Quoted 18 lines · Jan Beulich
Section start symbols frequently obscure the actual symbol name living at the start of the section. Eliminate them where they can be replaced by linker resolved .startof.* symbols. (Section end symbols may have the same undesirable effect, but they're less easy to eliminate, as they'd need to be represented by the sum of .startof.<section> and .sizeof.<section>).
Along those lines use .sizeof.* where section sizes get calculated from the difference of section and and section start symbols.
Note that this would be nice for the build-id section too, but:
- The generated (by ld) section names differ between ELF and COFF/PE (ELF: .note.gnu.build-id; COFF/PE[2.26+]: .buildid), yet we compileversion.cjust once (and hence can use only either of the necessary .startof./.sizeof. forms).
- The ELF section name needs to be quoted in the .startof./.sizeof. expressions, yet that quoting is supported only by gas 2.26+.
Quoted 3 lines
Quoted 1 line
Signed-off-by Jan Beulich <[email protected]>Is there any documentation of these? I cant seem to find any.
Indeed I can't find any either, at least not inside the binutils repo. But the support for this has been there for a long time (it is present in 2.16.1, which is the oldest I have readily available).
Quoted 1 line
Does this work on Clang at all?
To be honest - I have no idea.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel