debuggers.hg

changeset 19966:3f12d48f2880

x86: merge final linking scripts

While unrelated to the previous four patches, I realized that the two
scripts are nearly identical when coding those earlier patches, and
this patch depends on them in order to apply cleanly.

As an extra measure, it also adjusts the (unused) space freed at the
end of the per-CPU area to include all alignment space needed before
the first actual constituent of the .bss section (up to 7 pages on
x86-64).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 13 11:51:07 2009 +0100 (2009-07-13)
parents 2dbabefe62dc
children f17c897546bf
files xen/arch/x86/Makefile xen/arch/x86/setup.c xen/arch/x86/x86_32/xen.lds.S xen/arch/x86/x86_64/xen.lds.S xen/arch/x86/xen.lds.S
line diff
     1.1 --- a/xen/arch/x86/Makefile	Mon Jul 13 11:45:31 2009 +0100
     1.2 +++ b/xen/arch/x86/Makefile	Mon Jul 13 11:51:07 2009 +0100
     1.3 @@ -82,7 +82,7 @@ ALL_OBJS := $(BASEDIR)/arch/x86/boot/bui
     1.4  asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c
     1.5  	$(CC) $(CFLAGS) -S -o $@ $<
     1.6  
     1.7 -xen.lds: $(TARGET_SUBARCH)/xen.lds.S
     1.8 +xen.lds: xen.lds.S
     1.9  	$(CC) -P -E -Ui386 $(AFLAGS) -o $@ $<
    1.10  
    1.11  boot/mkelf32: boot/mkelf32.c
     2.1 --- a/xen/arch/x86/setup.c	Mon Jul 13 11:45:31 2009 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Mon Jul 13 11:51:07 2009 +0100
     2.3 @@ -191,7 +191,8 @@ void __init discard_initial_images(void)
     2.4      init_domheap_pages(initial_images_base, initial_images_end);
     2.5  }
     2.6  
     2.7 -extern char __per_cpu_start[], __per_cpu_data_end[], __per_cpu_end[];
     2.8 +extern char __init_begin[], __bss_start[];
     2.9 +extern char __per_cpu_start[], __per_cpu_data_end[];
    2.10  
    2.11  static void __init percpu_init_areas(void)
    2.12  {
    2.13 @@ -213,10 +214,11 @@ static void __init percpu_init_areas(voi
    2.14  
    2.15  #ifndef MEMORY_GUARD
    2.16      init_xenheap_pages(__pa(__per_cpu_start) + (first_unused << PERCPU_SHIFT),
    2.17 -                       __pa(__per_cpu_end));
    2.18 +                       __pa(__bss_start));
    2.19  #endif
    2.20      memguard_guard_range(&__per_cpu_start[first_unused << PERCPU_SHIFT],
    2.21 -                         (NR_CPUS - first_unused) << PERCPU_SHIFT);
    2.22 +                         __bss_start - &__per_cpu_start[first_unused <<
    2.23 +                                                        PERCPU_SHIFT]);
    2.24  #if defined(CONFIG_X86_64)
    2.25      /* Also zap the mapping in the 1:1 area. */
    2.26      memguard_guard_range(__va(__pa(__per_cpu_start)) +
    2.27 @@ -1128,8 +1130,6 @@ int xen_in_range(paddr_t start, paddr_t 
    2.28      /* initialize first time */
    2.29      if ( !xen_regions[0].s )
    2.30      {
    2.31 -        extern char __init_begin[], __bss_start[];
    2.32 -
    2.33          /* S3 resume code (and other real mode trampoline code) */
    2.34          xen_regions[0].s = bootsym_phys(trampoline_start);
    2.35          xen_regions[0].e = bootsym_phys(trampoline_end);
     3.1 --- a/xen/arch/x86/x86_32/xen.lds.S	Mon Jul 13 11:45:31 2009 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,110 +0,0 @@
     3.4 -/* ld script to make i386 Linux kernel
     3.5 - * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
     3.6 - * Modified for i386 Xen by Keir Fraser
     3.7 - */
     3.8 -
     3.9 -#include <xen/config.h>
    3.10 -#include <xen/cache.h>
    3.11 -#include <asm/page.h>
    3.12 -#include <asm/percpu.h>
    3.13 -#undef ENTRY
    3.14 -#undef ALIGN
    3.15 -
    3.16 -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
    3.17 -OUTPUT_ARCH(i386)
    3.18 -ENTRY(start)
    3.19 -PHDRS
    3.20 -{
    3.21 -  text PT_LOAD ;
    3.22 -}
    3.23 -SECTIONS
    3.24 -{
    3.25 -  . = 0xFF000000 + 0x100000;
    3.26 -  _start = .;
    3.27 -  _stext = .;			/* Text and read-only data */
    3.28 -  .text : {
    3.29 -	*(.text)
    3.30 -	*(.fixup)
    3.31 -	*(.gnu.warning)
    3.32 -	} :text =0x9090
    3.33 -
    3.34 -  _etext = .;			/* End of text section */
    3.35 -
    3.36 -  .rodata : { *(.rodata) *(.rodata.*) } :text
    3.37 -
    3.38 -  . = ALIGN(32);		/* Exception table */
    3.39 -  __start___ex_table = .;
    3.40 -  __ex_table : { *(__ex_table) } :text
    3.41 -  __stop___ex_table = .;
    3.42 -
    3.43 -  . = ALIGN(32);		/* Pre-exception table */
    3.44 -  __start___pre_ex_table = .;
    3.45 -  __pre_ex_table : { *(__pre_ex_table) } :text
    3.46 -  __stop___pre_ex_table = .;
    3.47 -
    3.48 -  .data : {			/* Data */
    3.49 -	*(.data)
    3.50 -	CONSTRUCTORS
    3.51 -	} :text
    3.52 -
    3.53 -  . = ALIGN(128);
    3.54 -  .data.read_mostly : { *(.data.read_mostly) } :text
    3.55 -
    3.56 -  . = ALIGN(4096);		/* Init code and data */
    3.57 -  __init_begin = .;
    3.58 -  _sinittext = .;
    3.59 -  .init.text : { *(.init.text) } :text
    3.60 -  _einittext = .;
    3.61 -  .init.data : { *(.init.data) } :text
    3.62 -  . = ALIGN(32);
    3.63 -  __setup_start = .;
    3.64 -  .init.setup : { *(.init.setup) } :text
    3.65 -  __setup_end = .;
    3.66 -  __initcall_start = .;
    3.67 -  .initcall.init : { *(.initcall1.init) } :text
    3.68 -  __initcall_end = .;
    3.69 -  __xsm_initcall_start = .; 
    3.70 -  .xsm_initcall.init : { *(.xsm_initcall.init) } :text
    3.71 -  __xsm_initcall_end = .;
    3.72 -  . = ALIGN(PAGE_SIZE);
    3.73 -  __init_end = .;
    3.74 -
    3.75 -  __per_cpu_shift = PERCPU_SHIFT; /* kdump assist */
    3.76 -  .data.percpu : {
    3.77 -	__per_cpu_start = .;
    3.78 -	*(.data.percpu)
    3.79 -	. = ALIGN(SMP_CACHE_BYTES);
    3.80 -	*(.data.percpu.read_mostly)
    3.81 -	__per_cpu_data_end = .;
    3.82 -  } :text
    3.83 -  . = __per_cpu_start + (NR_CPUS << PERCPU_SHIFT);
    3.84 -  . = ALIGN(PAGE_SIZE);
    3.85 -  __per_cpu_end = .;
    3.86 -
    3.87 -  __bss_start = .;		/* BSS */
    3.88 -  .bss : {
    3.89 -	. = ALIGN(STACK_SIZE);
    3.90 -	*(.bss.stack_aligned)
    3.91 -	. = ALIGN(PAGE_SIZE);
    3.92 -	*(.bss.page_aligned)
    3.93 -	*(.bss)
    3.94 -	} :text
    3.95 -  _end = . ;
    3.96 -
    3.97 -  /* Sections to be discarded */
    3.98 -  /DISCARD/ : {
    3.99 -	*(.exit.text)
   3.100 -	*(.exit.data)
   3.101 -	*(.exitcall.exit)
   3.102 -	*(.eh_frame)
   3.103 -	}
   3.104 -
   3.105 -  /* Stabs debugging sections.  */
   3.106 -  .stab 0 : { *(.stab) }
   3.107 -  .stabstr 0 : { *(.stabstr) }
   3.108 -  .stab.excl 0 : { *(.stab.excl) }
   3.109 -  .stab.exclstr 0 : { *(.stab.exclstr) }
   3.110 -  .stab.index 0 : { *(.stab.index) }
   3.111 -  .stab.indexstr 0 : { *(.stab.indexstr) }
   3.112 -  .comment 0 : { *(.comment) }
   3.113 -}
     4.1 --- a/xen/arch/x86/x86_64/xen.lds.S	Mon Jul 13 11:45:31 2009 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,108 +0,0 @@
     4.4 -/* Excerpts written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> */
     4.5 -/* Modified for x86-64 Xen by Keir Fraser */
     4.6 -
     4.7 -#include <xen/config.h>
     4.8 -#include <xen/cache.h>
     4.9 -#include <asm/page.h>
    4.10 -#include <asm/percpu.h>
    4.11 -#undef ENTRY
    4.12 -#undef ALIGN
    4.13 -
    4.14 -OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
    4.15 -OUTPUT_ARCH(i386:x86-64)
    4.16 -ENTRY(start)
    4.17 -PHDRS
    4.18 -{
    4.19 -  text PT_LOAD ;
    4.20 -}
    4.21 -SECTIONS
    4.22 -{
    4.23 -  . = __XEN_VIRT_START + 0x100000;
    4.24 -  _start = .;
    4.25 -  _stext = .;			/* Text and read-only data */
    4.26 -  .text : {
    4.27 -	*(.text)
    4.28 -	*(.fixup)
    4.29 -	*(.gnu.warning)
    4.30 -	} :text = 0x9090
    4.31 -
    4.32 -  _etext = .;			/* End of text section */
    4.33 -
    4.34 -  .rodata : { *(.rodata) *(.rodata.*) } :text
    4.35 -
    4.36 -  . = ALIGN(32);		/* Exception table */
    4.37 -  __start___ex_table = .;
    4.38 -  __ex_table : { *(__ex_table) } :text
    4.39 -  __stop___ex_table = .;
    4.40 -
    4.41 -  . = ALIGN(32);                /* Pre-exception table */
    4.42 -  __start___pre_ex_table = .;
    4.43 -  __pre_ex_table : { *(__pre_ex_table) } :text
    4.44 -  __stop___pre_ex_table = .;
    4.45 -
    4.46 -  .data : {			/* Data */
    4.47 -	*(.data)
    4.48 -	CONSTRUCTORS
    4.49 -	} :text
    4.50 -
    4.51 -  . = ALIGN(128);
    4.52 -  .data.read_mostly : { *(.data.read_mostly) } :text
    4.53 -
    4.54 -  . = ALIGN(4096);		/* Init code and data */
    4.55 -  __init_begin = .;
    4.56 -  _sinittext = .;
    4.57 -  .init.text : { *(.init.text) } :text
    4.58 -  _einittext = .;
    4.59 -  .init.data : { *(.init.data) } :text
    4.60 -  . = ALIGN(32);
    4.61 -  __setup_start = .;
    4.62 -  .init.setup : { *(.init.setup) } :text
    4.63 -  __setup_end = .;
    4.64 -  __initcall_start = .;
    4.65 -  .initcall.init : { *(.initcall1.init) } :text
    4.66 -  __initcall_end = .;
    4.67 -  __xsm_initcall_start = .; 
    4.68 -  .xsm_initcall.init : { *(.xsm_initcall.init) } :text
    4.69 -  __xsm_initcall_end = .;
    4.70 -  . = ALIGN(PAGE_SIZE);
    4.71 -  __init_end = .;
    4.72 -
    4.73 -  __per_cpu_shift = PERCPU_SHIFT; /* kdump assist */
    4.74 -  .data.percpu : {
    4.75 -	__per_cpu_start = .;
    4.76 -	*(.data.percpu)
    4.77 -	. = ALIGN(SMP_CACHE_BYTES);
    4.78 -	*(.data.percpu.read_mostly)
    4.79 -	__per_cpu_data_end = .;
    4.80 -  } :text
    4.81 -  . = __per_cpu_start + (NR_CPUS << PERCPU_SHIFT);
    4.82 -  . = ALIGN(PAGE_SIZE);
    4.83 -  __per_cpu_end = .;
    4.84 -
    4.85 -  __bss_start = .;		/* BSS */
    4.86 -  .bss : {
    4.87 -	. = ALIGN(STACK_SIZE);
    4.88 -	*(.bss.stack_aligned)
    4.89 -	. = ALIGN(PAGE_SIZE);
    4.90 -	*(.bss.page_aligned)
    4.91 -	*(.bss)
    4.92 -	} :text
    4.93 -  _end = . ;
    4.94 -
    4.95 -  /* Sections to be discarded */
    4.96 -  /DISCARD/ : {
    4.97 -	*(.exit.text)
    4.98 -	*(.exit.data)
    4.99 -	*(.exitcall.exit)
   4.100 -	*(.eh_frame)
   4.101 -	}
   4.102 -
   4.103 -  /* Stabs debugging sections.  */
   4.104 -  .stab 0 : { *(.stab) }
   4.105 -  .stabstr 0 : { *(.stabstr) }
   4.106 -  .stab.excl 0 : { *(.stab.excl) }
   4.107 -  .stab.exclstr 0 : { *(.stab.exclstr) }
   4.108 -  .stab.index 0 : { *(.stab.index) }
   4.109 -  .stab.indexstr 0 : { *(.stab.indexstr) }
   4.110 -  .comment 0 : { *(.comment) }
   4.111 -}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xen/arch/x86/xen.lds.S	Mon Jul 13 11:51:07 2009 +0100
     5.3 @@ -0,0 +1,136 @@
     5.4 +/* Excerpts written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> */
     5.5 +/* Modified for i386/x86-64 Xen by Keir Fraser */
     5.6 +
     5.7 +#include <xen/config.h>
     5.8 +#include <xen/cache.h>
     5.9 +#include <asm/page.h>
    5.10 +#include <asm/percpu.h>
    5.11 +#undef ENTRY
    5.12 +#undef ALIGN
    5.13 +
    5.14 +#ifdef __x86_64__
    5.15 +OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
    5.16 +OUTPUT_ARCH(i386:x86-64)
    5.17 +#else
    5.18 +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
    5.19 +OUTPUT_ARCH(i386)
    5.20 +#endif
    5.21 +
    5.22 +ENTRY(start)
    5.23 +PHDRS
    5.24 +{
    5.25 +  text PT_LOAD ;
    5.26 +}
    5.27 +SECTIONS
    5.28 +{
    5.29 +  . = __XEN_VIRT_START + 0x100000;
    5.30 +  _start = .;
    5.31 +  .text : {
    5.32 +        _stext = .;            /* Text and read-only data */
    5.33 +       *(.text)
    5.34 +       *(.fixup)
    5.35 +       *(.gnu.warning)
    5.36 +       _etext = .;             /* End of text section */
    5.37 +  } :text = 0x9090
    5.38 +
    5.39 +  .rodata : {
    5.40 +       *(.rodata)
    5.41 +       *(.rodata.*)
    5.42 +  } :text
    5.43 +
    5.44 +  . = ALIGN(32);               /* Exception table */
    5.45 +  __ex_table : {
    5.46 +       __start___ex_table = .;
    5.47 +       *(__ex_table)
    5.48 +       __stop___ex_table = .;
    5.49 +  } :text
    5.50 +
    5.51 +  . = ALIGN(32);               /* Pre-exception table */
    5.52 +  __pre_ex_table : {
    5.53 +       __start___pre_ex_table = .;
    5.54 +       *(__pre_ex_table)
    5.55 +       __stop___pre_ex_table = .;
    5.56 +  } :text
    5.57 +
    5.58 +  .data : {                    /* Data */
    5.59 +       *(.data)
    5.60 +       CONSTRUCTORS
    5.61 +  } :text
    5.62 +
    5.63 +  . = ALIGN(128);
    5.64 +  .data.read_mostly : {
    5.65 +       *(.data.read_mostly)
    5.66 +  } :text
    5.67 +
    5.68 +  . = ALIGN(4096);             /* Init code and data */
    5.69 +  __init_begin = .;
    5.70 +  .init.text : {
    5.71 +       _sinittext = .;
    5.72 +       *(.init.text)
    5.73 +       _einittext = .;
    5.74 +  } :text
    5.75 +  .init.data : {
    5.76 +       *(.init.data)
    5.77 +  } :text
    5.78 +  . = ALIGN(32);
    5.79 +  .init.setup : {
    5.80 +       __setup_start = .;
    5.81 +       *(.init.setup)
    5.82 +       __setup_end = .;
    5.83 +  } :text
    5.84 +  .initcall.init : {
    5.85 +       __initcall_start = .;
    5.86 +       *(.initcall1.init)
    5.87 +       __initcall_end = .;
    5.88 +  } :text
    5.89 +  .xsm_initcall.init : {
    5.90 +       __xsm_initcall_start = .;
    5.91 +       *(.xsm_initcall.init)
    5.92 +       __xsm_initcall_end = .;
    5.93 +  } :text
    5.94 +  . = ALIGN(PAGE_SIZE);
    5.95 +  __init_end = .;
    5.96 +
    5.97 +  __per_cpu_shift = PERCPU_SHIFT; /* kdump assist */
    5.98 +  .data.percpu : {
    5.99 +       __per_cpu_start = .;
   5.100 +       *(.data.percpu)
   5.101 +       . = ALIGN(SMP_CACHE_BYTES);
   5.102 +       *(.data.percpu.read_mostly)
   5.103 +       __per_cpu_data_end = .;
   5.104 +  } :text
   5.105 +  . = __per_cpu_start + (NR_CPUS << PERCPU_SHIFT);
   5.106 +  . = ALIGN(PAGE_SIZE);
   5.107 +
   5.108 +  /*
   5.109 +   * Do not insert anything here - the unused portion of .data.percpu
   5.110 +   * will be freed/unmapped up to __bss_start (defined below).
   5.111 +   */
   5.112 +
   5.113 +  .bss : {                     /* BSS */
   5.114 +       . = ALIGN(STACK_SIZE);
   5.115 +       __bss_start = .;
   5.116 +       *(.bss.stack_aligned)
   5.117 +       . = ALIGN(PAGE_SIZE);
   5.118 +       *(.bss.page_aligned)
   5.119 +       *(.bss)
   5.120 +  } :text
   5.121 +  _end = . ;
   5.122 +
   5.123 +  /* Sections to be discarded */
   5.124 +  /DISCARD/ : {
   5.125 +       *(.exit.text)
   5.126 +       *(.exit.data)
   5.127 +       *(.exitcall.exit)
   5.128 +       *(.eh_frame)
   5.129 +  }
   5.130 +
   5.131 +  /* Stabs debugging sections.  */
   5.132 +  .stab 0 : { *(.stab) }
   5.133 +  .stabstr 0 : { *(.stabstr) }
   5.134 +  .stab.excl 0 : { *(.stab.excl) }
   5.135 +  .stab.exclstr 0 : { *(.stab.exclstr) }
   5.136 +  .stab.index 0 : { *(.stab.index) }
   5.137 +  .stab.indexstr 0 : { *(.stab.indexstr) }
   5.138 +  .comment 0 : { *(.comment) }
   5.139 +}