powerpc/8xx: Use SPRG2 and DAR registers to stash r11 and cr.
[safe/jmp/linux-2.6] / arch / powerpc / kernel / vmlinux.lds.S
index 9ceaa7a..dcd01c8 100644 (file)
@@ -1,9 +1,34 @@
-#include <linux/config.h>
+#ifdef CONFIG_PPC64
+#define PROVIDE32(x)   PROVIDE(__unused__##x)
+#else
+#define PROVIDE32(x)   PROVIDE(x)
+#endif
 #include <asm/page.h>
 #include <asm-generic/vmlinux.lds.h>
+#include <asm/cache.h>
+#include <asm/thread_info.h>
 
 ENTRY(_stext)
 
+PHDRS {
+       kernel PT_LOAD FLAGS(7); /* RWX */
+       notes PT_NOTE FLAGS(0);
+       dummy PT_NOTE FLAGS(0);
+
+       /* binutils < 2.18 has a bug that makes it misbehave when taking an
+          ELF file with all segments at load address 0 as input.  This
+          happens when running "strip" on vmlinux, because of the AT() magic
+          in this linker script.  People using GCC >= 4.2 won't run into
+          this problem, because the "build-id" support will put some data
+          into the "notes" segment (at a non-zero load address).
+
+          To work around this, we force some data into both the "dummy"
+          segment and the kernel segment, so the dummy segment will get a
+          non-zero load address.  It's not enough to always create the
+          "notes" segment, since if nothing gets assigned to it, its load
+          address will be zero.  */
+}
+
 #ifdef CONFIG_PPC64
 OUTPUT_ARCH(powerpc:common64)
 jiffies = jiffies_64;
@@ -13,266 +38,226 @@ jiffies = jiffies_64 + 4;
 #endif
 SECTIONS
 {
-  /* Sections to be discarded. */
-  /DISCARD/ : {
-    *(.exitcall.exit)
-    *(.exit.data)
-  }
-
-  . = KERNELBASE;
+       . = 0;
+       reloc_start = .;
+
+       . = KERNELBASE;
+
+/*
+ * Text, read only data and other permanent read-only sections
+ */
+
+       /* Text and gots */
+       .text : AT(ADDR(.text) - LOAD_OFFSET) {
+               ALIGN_FUNCTION();
+               HEAD_TEXT
+               _text = .;
+               /* careful! __ftr_alt_* sections need to be close to .text */
+               *(.text .fixup __ftr_alt_* .ref.text)
+               SCHED_TEXT
+               LOCK_TEXT
+               KPROBES_TEXT
+               IRQENTRY_TEXT
 
-  /* Read-only sections, merged into text segment: */
-#ifdef CONFIG_PPC32
-  . = + SIZEOF_HEADERS;
-  .interp : { *(.interp) }
-  .hash          : { *(.hash)          }
-  .dynsym        : { *(.dynsym)                }
-  .dynstr        : { *(.dynstr)                }
-  .rel.text      : { *(.rel.text)              }
-  .rela.text     : { *(.rela.text)     }
-  .rel.data      : { *(.rel.data)              }
-  .rela.data     : { *(.rela.data)     }
-  .rel.rodata    : { *(.rel.rodata)    }
-  .rela.rodata   : { *(.rela.rodata)   }
-  .rel.got       : { *(.rel.got)               }
-  .rela.got      : { *(.rela.got)              }
-  .rel.ctors     : { *(.rel.ctors)     }
-  .rela.ctors    : { *(.rela.ctors)    }
-  .rel.dtors     : { *(.rel.dtors)     }
-  .rela.dtors    : { *(.rela.dtors)    }
-  .rel.bss       : { *(.rel.bss)               }
-  .rela.bss      : { *(.rela.bss)              }
-  .rel.plt       : { *(.rel.plt)               }
-  .rela.plt      : { *(.rela.plt)              }
-/*  .init          : { *(.init)        } =0*/
-  .plt : { *(.plt) }
-#endif
-  .text : {
-    *(.text .text.*)
-    SCHED_TEXT
-    LOCK_TEXT
-    KPROBES_TEXT
-    *(.fixup)
-#ifdef CONFIG_PPC32
-    *(.got1)
-    __got2_start = .;
-    *(.got2)
-    __got2_end = .;
-#else
-    . = ALIGN(PAGE_SIZE);
-    _etext = .;
-#endif
-  }
 #ifdef CONFIG_PPC32
-  _etext = .;
-  PROVIDE (etext = .);
-
-  RODATA
-  .fini      : { *(.fini)    } =0
-  .ctors     : { *(.ctors)   }
-  .dtors     : { *(.dtors)   }
+               *(.got1)
+               __got2_start = .;
+               *(.got2)
+               __got2_end = .;
+#endif /* CONFIG_PPC32 */
+
+       } :kernel
+
+       . = ALIGN(PAGE_SIZE);
+       _etext = .;
+       PROVIDE32 (etext = .);
+
+       /* Read-only data */
+       RODATA
+
+       EXCEPTION_TABLE(0)
+
+       NOTES :kernel :notes
+
+       /* The dummy segment contents for the bug workaround mentioned above
+          near PHDRS.  */
+       .dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
+               LONG(0)
+               LONG(0)
+               LONG(0)
+       } :kernel :dummy
+
+/*
+ * Init sections discarded at runtime
+ */
+       . = ALIGN(PAGE_SIZE);
+       __init_begin = .;
+       INIT_TEXT_SECTION(PAGE_SIZE) :kernel
+
+       /* .exit.text is discarded at runtime, not link time,
+        * to deal with references from __bug_table
+        */
+       .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
+               EXIT_TEXT
+       }
 
-  .fixup   : { *(.fixup) }
+       .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
+               INIT_DATA
+               __vtop_table_begin = .;
+               *(.vtop_fixup);
+               __vtop_table_end = .;
+               __ptov_table_begin = .;
+               *(.ptov_fixup);
+               __ptov_table_end = .;
+#ifdef CONFIG_PPC_ISERIES
+               __dt_strings_start = .;
+               *(.dt_strings);
+               __dt_strings_end = .;
 #endif
+       }
 
-       __ex_table : {
-               __start___ex_table = .;
-               *(__ex_table)
-               __stop___ex_table = .;
+       .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
+               INIT_SETUP(16)
        }
 
-       __bug_table : {
-               __start___bug_table = .;
-               *(__bug_table)
-               __stop___bug_table = .;
+       .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
+               INIT_CALLS
        }
 
-#ifdef CONFIG_PPC64
-       __ftr_fixup : {
+       .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
+               CON_INITCALL
+       }
+
+       SECURITY_INIT
+
+       . = ALIGN(8);
+       __ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
                __start___ftr_fixup = .;
                *(__ftr_fixup)
                __stop___ftr_fixup = .;
        }
-
-  RODATA
+       . = ALIGN(8);
+       __mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
+               __start___mmu_ftr_fixup = .;
+               *(__mmu_ftr_fixup)
+               __stop___mmu_ftr_fixup = .;
+       }
+       . = ALIGN(8);
+       __lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
+               __start___lwsync_fixup = .;
+               *(__lwsync_fixup)
+               __stop___lwsync_fixup = .;
+       }
+#ifdef CONFIG_PPC64
+       . = ALIGN(8);
+       __fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
+               __start___fw_ftr_fixup = .;
+               *(__fw_ftr_fixup)
+               __stop___fw_ftr_fixup = .;
+       }
 #endif
+       .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
+               INIT_RAM_FS
+       }
 
-#ifdef CONFIG_PPC32
-  /* Read-write section, merged into data segment: */
-  . = ALIGN(PAGE_SIZE);
-  _sdata = .;
-  .data    :
-  {
-    *(.data)
-    *(.data1)
-    *(.sdata)
-    *(.sdata2)
-    *(.got.plt) *(.got)
-    *(.dynamic)
-    CONSTRUCTORS
-  }
-
-  . = ALIGN(PAGE_SIZE);
-  __nosave_begin = .;
-  .data_nosave : { *(.data.nosave) }
-  . = ALIGN(PAGE_SIZE);
-  __nosave_end = .;
-
-  . = ALIGN(32);
-  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
-
-  _edata  =  .;
-  PROVIDE (edata = .);
-
-  . = ALIGN(8192);
-  .data.init_task : { *(.data.init_task) }
-#endif
+       PERCPU(PAGE_SIZE)
 
-  /* will be freed after init */
-  . = ALIGN(PAGE_SIZE);
-  __init_begin = .;
-  .init.text : {
-       _sinittext = .;
-       *(.init.text)
-       _einittext = .;
-  }
-#ifdef CONFIG_PPC32
-  /* .exit.text is discarded at runtime, not link time,
-     to deal with references from __bug_table */
-  .exit.text : { *(.exit.text) }
+       . = ALIGN(8);
+       .machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
+               __machine_desc_start = . ;
+               *(.machine.desc)
+               __machine_desc_end = . ;
+       }
+#ifdef CONFIG_RELOCATABLE
+       . = ALIGN(8);
+       .dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET) { *(.dynsym) }
+       .dynstr : AT(ADDR(.dynstr) - LOAD_OFFSET) { *(.dynstr) }
+       .dynamic : AT(ADDR(.dynamic) - LOAD_OFFSET)
+       {
+               __dynamic_start = .;
+               *(.dynamic)
+       }
+       .hash : AT(ADDR(.hash) - LOAD_OFFSET) { *(.hash) }
+       .interp : AT(ADDR(.interp) - LOAD_OFFSET) { *(.interp) }
+       .rela.dyn : AT(ADDR(.rela.dyn) - LOAD_OFFSET)
+       {
+               __rela_dyn_start = .;
+               *(.rela*)
+       }
 #endif
-  .init.data : {
-    *(.init.data);
-    __vtop_table_begin = .;
-    *(.vtop_fixup);
-    __vtop_table_end = .;
-    __ptov_table_begin = .;
-    *(.ptov_fixup);
-    __ptov_table_end = .;
-  }
-
-  . = ALIGN(16);
-  .init.setup : {
-    __setup_start = .;
-    *(.init.setup)
-    __setup_end = .;
-  }
-
-  .initcall.init : {
-       __initcall_start = .;
-       *(.initcall1.init)
-       *(.initcall2.init)
-       *(.initcall3.init)
-       *(.initcall4.init)
-       *(.initcall5.init)
-       *(.initcall6.init)
-       *(.initcall7.init)
-       __initcall_end = .;
-  }
-
-  .con_initcall.init : {
-    __con_initcall_start = .;
-    *(.con_initcall.init)
-    __con_initcall_end = .;
-  }
-
-  SECURITY_INIT
+
+       /* freed after init ends here */
+       . = ALIGN(PAGE_SIZE);
+       __init_end = .;
+
+/*
+ * And now the various read/write data
+ */
+
+       . = ALIGN(PAGE_SIZE);
+       _sdata = .;
 
 #ifdef CONFIG_PPC32
-  __start___ftr_fixup = .;
-  __ftr_fixup : { *(__ftr_fixup) }
-  __stop___ftr_fixup = .;
+       .data : AT(ADDR(.data) - LOAD_OFFSET) {
+               DATA_DATA
+               *(.sdata)
+               *(.got.plt) *(.got)
+       }
 #else
-  . = ALIGN(PAGE_SIZE);
-  .init.ramfs : {
-    __initramfs_start = .;
-    *(.init.ramfs)
-    __initramfs_end = .;
-  }
-#endif
+       .data : AT(ADDR(.data) - LOAD_OFFSET) {
+               DATA_DATA
+               *(.data.rel*)
+               *(.toc1)
+               *(.branch_lt)
+       }
 
-#ifdef CONFIG_PPC32
-  . = ALIGN(32);
+       .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
+               *(.opd)
+       }
+
+       .got : AT(ADDR(.got) - LOAD_OFFSET) {
+               __toc_start = .;
+               *(.got)
+               *(.toc)
+       }
 #endif
-  .data.percpu : {
-    __per_cpu_start = .;
-    *(.data.percpu)
-    __per_cpu_end = .;
-  }
 
- . = ALIGN(PAGE_SIZE);
-#ifdef CONFIG_PPC64
- . = ALIGN(16384);
- __init_end = .;
- /* freed after init ends here */
-
- /* Read/write sections */
- . = ALIGN(PAGE_SIZE);
- . = ALIGN(16384);
- _sdata = .;
- /* The initial task and kernel stack */
- .data.init_task : {
-      *(.data.init_task)
-      }
-
- . = ALIGN(PAGE_SIZE);
- .data.page_aligned : {
-      *(.data.page_aligned)
-      }
-
- .data.cacheline_aligned : {
-      *(.data.cacheline_aligned)
-      }
-
- .data : {
-      *(.data .data.rel* .toc1)
-      *(.branch_lt)
-      }
-
- .opd : {
-      *(.opd)
-      }
-
- .got : {
-      __toc_start = .;
-      *(.got)
-      *(.toc)
-      . = ALIGN(PAGE_SIZE);
-      _edata = .;
-      }
-
-  . = ALIGN(PAGE_SIZE);
-#else
-  __initramfs_start = .;
-  .init.ramfs : {
-    *(.init.ramfs)
-  }
-  __initramfs_end = .;
+       /* The initial task and kernel stack */
+       .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
+               INIT_TASK_DATA(THREAD_SIZE)
+       }
 
-  . = ALIGN(4096);
-  __init_end = .;
+       .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
+               PAGE_ALIGNED_DATA(PAGE_SIZE)
+       }
 
-  . = ALIGN(4096);
-  _sextratext = .;
-  _eextratext = .;
+       .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
+               CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
+       }
 
-  __bss_start = .;
-#endif
+       .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
+               READ_MOSTLY_DATA(L1_CACHE_BYTES)
+       }
 
-  .bss : {
-    __bss_start = .;
-   *(.sbss) *(.scommon)
-   *(.dynbss)
-   *(.bss)
-   *(COMMON)
-  __bss_stop = .;
-  }
+       . = ALIGN(PAGE_SIZE);
+       .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
+               NOSAVE_DATA
+       }
 
-#ifdef CONFIG_PPC64
-  . = ALIGN(PAGE_SIZE);
-#endif
-  _end = . ;
-#ifdef CONFIG_PPC32
-  PROVIDE (end = .);
-#endif
+       . = ALIGN(PAGE_SIZE);
+       _edata  =  .;
+       PROVIDE32 (edata = .);
+
+/*
+ * And finally the bss
+ */
+
+       BSS_SECTION(0, 0, 0)
+
+       . = ALIGN(PAGE_SIZE);
+       _end = . ;
+       PROVIDE32 (end = .);
+
+       /* Sections to be discarded. */
+       DISCARDS
 }