* [PATCH 0/2] eliminate some section start symbols
@ 2016-08-12 14:43 Jan Beulich
2016-08-12 14:47 ` [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script Jan Beulich
2016-08-12 14:48 ` [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions Jan Beulich
0 siblings, 2 replies; 8+ messages in thread
From: Jan Beulich @ 2016-08-12 14:43 UTC (permalink / raw)
To: xen-devel
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
Ian Jackson, Tim Deegan
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
Signed-off-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
2016-08-12 14:43 [PATCH 0/2] eliminate some section start symbols Jan Beulich
@ 2016-08-12 14:47 ` Jan Beulich
2016-08-12 15:02 ` Andrew Cooper
2016-08-12 14:48 ` [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions Jan Beulich
1 sibling, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2016-08-12 14:47 UTC (permalink / raw)
To: xen-devel; +Cc: George Dunlap, Andrew Cooper
[-- Attachment #1: Type: text/plain, Size: 2420 bytes --]
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.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -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 */
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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_l1
TOGGLE_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)
{
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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 };
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -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);
[-- Attachment #2: x86-bss-align.patch --]
[-- Type: text/plain, Size: 2487 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.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -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 */
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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_l1
TOGGLE_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)
{
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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 };
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -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);
[-- Attachment #3: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions
2016-08-12 14:43 [PATCH 0/2] eliminate some section start symbols Jan Beulich
2016-08-12 14:47 ` [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script Jan Beulich
@ 2016-08-12 14:48 ` Jan Beulich
2016-08-15 9:43 ` Andrew Cooper
1 sibling, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2016-08-12 14:48 UTC (permalink / raw)
To: xen-devel
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
Ian Jackson, Tim Deegan
[-- Attachment #1: Type: text/plain, Size: 11427 bytes --]
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+.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -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
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -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
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -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;
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -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 )
--- a/xen/arch/arm/platform.c
+++ b/xen/arch/arm/platform.c
@@ -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;
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -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 = . ;
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -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
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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)
{
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -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 20
typedef 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
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -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")
--- a/xen/include/xen/kernel.h
+++ b/xen/include/xen/kernel.h
@@ -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,
--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -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 */
[-- Attachment #2: startof.patch --]
[-- Type: text/plain, Size: 11487 bytes --]
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+.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -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
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -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
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -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;
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -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 )
--- a/xen/arch/arm/platform.c
+++ b/xen/arch/arm/platform.c
@@ -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;
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -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 = . ;
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -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
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -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)
{
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -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 20
typedef 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
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -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")
--- a/xen/include/xen/kernel.h
+++ b/xen/include/xen/kernel.h
@@ -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,
--- a/xen/tools/symbols.c
+++ b/xen/tools/symbols.c
@@ -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 */
[-- Attachment #3: Type: text/plain, Size: 127 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
2016-08-12 14:47 ` [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script Jan Beulich
@ 2016-08-12 15:02 ` Andrew Cooper
2016-08-12 15:21 ` Jan Beulich
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cooper @ 2016-08-12 15:02 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: George Dunlap
On 12/08/16 15:47, Jan Beulich wrote:
> 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.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -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 <andrew.cooper3@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
2016-08-12 15:02 ` Andrew Cooper
@ 2016-08-12 15:21 ` Jan Beulich
2016-08-12 15:26 ` Andrew Cooper
0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2016-08-12 15:21 UTC (permalink / raw)
To: Andrew Cooper, xen-devel; +Cc: George Dunlap
>>> On 12.08.16 at 17:02, <andrew.cooper3@citrix.com> wrote:
> On 12/08/16 15:47, Jan Beulich wrote:
>> 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.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> --- a/xen/arch/x86/hvm/hvm.c
>> +++ b/xen/arch/x86/hvm/hvm.c
>> @@ -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 ?
Sure, I was on the edge of introducing it while putting this together
anyway, but then thought it's maybe not worth it.
> Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Thanks, Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script
2016-08-12 15:21 ` Jan Beulich
@ 2016-08-12 15:26 ` Andrew Cooper
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Cooper @ 2016-08-12 15:26 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: George Dunlap
On 12/08/16 16:21, Jan Beulich wrote:
>>>> On 12.08.16 at 17:02, <andrew.cooper3@citrix.com> wrote:
>> On 12/08/16 15:47, Jan Beulich wrote:
>>> 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.
>>>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>
>>> --- a/xen/arch/x86/hvm/hvm.c
>>> +++ b/xen/arch/x86/hvm/hvm.c
>>> @@ -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 ?
> 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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions
2016-08-12 14:48 ` [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions Jan Beulich
@ 2016-08-15 9:43 ` Andrew Cooper
2016-08-15 10:12 ` Jan Beulich
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cooper @ 2016-08-15 9:43 UTC (permalink / raw)
To: Jan Beulich, xen-devel
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Tim Deegan, Ian Jackson
On 12/08/16 15:48, Jan Beulich wrote:
> 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+.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Is there any documentation of these? I cant seem to find any.
Does this work on Clang at all?
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions
2016-08-15 9:43 ` Andrew Cooper
@ 2016-08-15 10:12 ` Jan Beulich
0 siblings, 0 replies; 8+ messages in thread
From: Jan Beulich @ 2016-08-15 10:12 UTC (permalink / raw)
To: Andrew Cooper
Cc: Stefano Stabellini, Wei Liu, George Dunlap, Tim Deegan,
Ian Jackson, xen-devel
>>> On 15.08.16 at 11:43, <andrew.cooper3@citrix.com> wrote:
> On 12/08/16 15:48, Jan Beulich wrote:
>> 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+.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> 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).
> Does this work on Clang at all?
To be honest - I have no idea.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-08-15 10:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12 14:43 [PATCH 0/2] eliminate some section start symbols Jan Beulich
2016-08-12 14:47 ` [PATCH 1/2] x86: force suitable alignment in sources rather than in linker script Jan Beulich
2016-08-12 15:02 ` Andrew Cooper
2016-08-12 15:21 ` Jan Beulich
2016-08-12 15:26 ` Andrew Cooper
2016-08-12 14:48 ` [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions Jan Beulich
2016-08-15 9:43 ` Andrew Cooper
2016-08-15 10:12 ` Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.