From patchwork Fri Aug 12 14:48:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9277237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8FEB960780 for ; Fri, 12 Aug 2016 14:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EE9628A3F for ; Fri, 12 Aug 2016 14:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7330528A42; Fri, 12 Aug 2016 14:51:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3753B28A3F for ; Fri, 12 Aug 2016 14:51:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYDlG-0002PE-Mw; Fri, 12 Aug 2016 14:48:38 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bYDlE-0002P3-VF for xen-devel@lists.xenproject.org; Fri, 12 Aug 2016 14:48:37 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 34/55-09160-4C1EDA75; Fri, 12 Aug 2016 14:48:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsXS6fjDS/fQw7X hBvNPWVp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmLt3MWfN/DWLGz+TJbA+OZSYxdjJwcQgJ5 Ej++32MGsXkF7CSOzD7ABGJLCBhKPH1/na2LkYODRUBV4t2uGJAwm4C6RNuz7awgYREBA4lzR 5O6GLk4mAXWMklcnHUXrFVYIEjiw6YDzBDj7SQu/D8OtopTwF7iWOc9sJG8AoISf3cIg4SZgU omT9jKPoGRZxZCZhaSDIStJfHw1y0WCFtbYtnC18wg5cwC0hLL/3FAhPUkni/5zIqqBMS2lDh 27yDLAkaOVYwaxalFZalFuoZGeklFmekZJbmJmTm6hgbGermpxcWJ6ak5iUnFesn5uZsYgeHK AAQ7GF91Ox9ilORgUhLlfXZhbbgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5nD4BygkWp6akVa Zk5wMiBSUtw8CiJ8LIBo0eIt7ggMbc4Mx0idYpRUUqcdxJInwBIIqM0D64NFq2XGGWlhHkZgQ 4R4ilILcrNLEGVf8UozsGoJMx7FmQKT2ZeCdz0V0CLmYAWnzBbA7K4JBEhJdXAqF681tBk8tO DyzTyw78WW7tHTQxyO64mLTtLj01rMjeHvOHvHe9dXa/498a96Zz0WSItZuHPE+l3X09J8Reb Uv75mdi0uz8Lp2YymKvEM77foXA76WZiUphcycxa34U13jVGURHrDhi8UI+379l36fTNE0K73 or+M/3G88Z39gS3Y7YaXVfFlViKMxINtZiLihMBf/Um/dECAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1471013312!55327089!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4562 invoked from network); 12 Aug 2016 14:48:34 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-14.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Aug 2016 14:48:34 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Fri, 12 Aug 2016 08:48:32 -0600 Message-Id: <57ADFDE0020000780010582F@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Fri, 12 Aug 2016 08:48:32 -0600 From: "Jan Beulich" To: "xen-devel" References: <57ADFCC402000078001057F2@prv-mh.provo.novell.com> In-Reply-To: <57ADFCC402000078001057F2@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan Subject: [Xen-devel] [PATCH 2/2] make use of .startof.() and .sizeof.() assembler expressions X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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.
and .sizeof.
). 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 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.
and .sizeof.
). 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 --- 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 #include -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 #include -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 */ --- 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 #include -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 #include -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 */