2005-11-05 07:36:59 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
2006-03-28 20:15:54 +08:00
|
|
|
#define PROVIDE32(x) PROVIDE(__unused__##x)
|
2005-11-05 07:36:59 +08:00
|
|
|
#else
|
2006-03-28 20:15:54 +08:00
|
|
|
#define PROVIDE32(x) PROVIDE(x)
|
2005-11-05 07:36:59 +08:00
|
|
|
#endif
|
2008-04-16 03:52:26 +08:00
|
|
|
#include <asm/page.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
#include <asm-generic/vmlinux.lds.h>
|
2007-07-04 12:04:31 +08:00
|
|
|
#include <asm/cache.h>
|
2009-09-24 22:36:24 +08:00
|
|
|
#include <asm/thread_info.h>
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-11-03 13:03:06 +08:00
|
|
|
ENTRY(_stext)
|
|
|
|
|
2008-07-22 07:03:45 +08:00
|
|
|
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. */
|
|
|
|
}
|
|
|
|
|
2005-09-30 14:16:52 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
OUTPUT_ARCH(powerpc:common64)
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
#else
|
2005-09-26 14:04:21 +08:00
|
|
|
OUTPUT_ARCH(powerpc:common)
|
|
|
|
jiffies = jiffies_64 + 4;
|
2005-09-30 14:16:52 +08:00
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
SECTIONS
|
|
|
|
{
|
2006-03-28 20:15:54 +08:00
|
|
|
. = KERNELBASE;
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
/*
|
|
|
|
* Text, read only data and other permanent read-only sections
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Text and gots */
|
2008-04-16 03:52:28 +08:00
|
|
|
.text : AT(ADDR(.text) - LOAD_OFFSET) {
|
2007-09-14 04:42:35 +08:00
|
|
|
ALIGN_FUNCTION();
|
2009-04-26 10:11:05 +08:00
|
|
|
HEAD_TEXT
|
2006-12-07 09:14:04 +08:00
|
|
|
_text = .;
|
2009-04-28 23:47:15 +08:00
|
|
|
/* careful! __ftr_alt_* sections need to be close to .text */
|
|
|
|
*(.text .fixup __ftr_alt_* .ref.text)
|
2006-03-28 20:15:54 +08:00
|
|
|
SCHED_TEXT
|
|
|
|
LOCK_TEXT
|
|
|
|
KPROBES_TEXT
|
2009-02-10 13:10:27 +08:00
|
|
|
IRQENTRY_TEXT
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
*(.got1)
|
|
|
|
__got2_start = .;
|
|
|
|
*(.got2)
|
|
|
|
__got2_end = .;
|
|
|
|
#endif /* CONFIG_PPC32 */
|
|
|
|
|
2008-07-22 07:03:45 +08:00
|
|
|
} :kernel
|
2006-03-28 20:15:54 +08:00
|
|
|
|
2008-09-02 13:04:09 +08:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_etext = .;
|
|
|
|
PROVIDE32 (etext = .);
|
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
/* Read-only data */
|
|
|
|
RODATA
|
|
|
|
|
2009-09-24 22:36:24 +08:00
|
|
|
EXCEPTION_TABLE(0)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-07-22 07:03:45 +08:00
|
|
|
NOTES :kernel :notes
|
|
|
|
|
|
|
|
/* The dummy segment contents for the bug workaround mentioned above
|
|
|
|
near PHDRS. */
|
2008-07-25 08:08:41 +08:00
|
|
|
.dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
|
2009-01-02 18:46:04 +08:00
|
|
|
LONG(0)
|
|
|
|
LONG(0)
|
|
|
|
LONG(0)
|
2008-07-22 07:03:45 +08:00
|
|
|
} :kernel :dummy
|
2007-07-19 16:48:38 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
/*
|
|
|
|
* Init sections discarded at runtime
|
|
|
|
*/
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__init_begin = .;
|
2009-09-24 22:36:24 +08:00
|
|
|
INIT_TEXT_SECTION(PAGE_SIZE) :kernel
|
2006-03-28 20:15:54 +08:00
|
|
|
|
|
|
|
/* .exit.text is discarded at runtime, not link time,
|
|
|
|
* to deal with references from __bug_table
|
|
|
|
*/
|
2008-04-16 03:52:28 +08:00
|
|
|
.exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
|
2008-01-20 21:15:03 +08:00
|
|
|
EXIT_TEXT
|
|
|
|
}
|
2006-03-28 20:15:54 +08:00
|
|
|
|
2008-04-16 03:52:28 +08:00
|
|
|
.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
|
2008-01-20 21:15:03 +08:00
|
|
|
INIT_DATA
|
2006-03-28 20:15:54 +08:00
|
|
|
__vtop_table_begin = .;
|
|
|
|
*(.vtop_fixup);
|
|
|
|
__vtop_table_end = .;
|
|
|
|
__ptov_table_begin = .;
|
|
|
|
*(.ptov_fixup);
|
|
|
|
__ptov_table_end = .;
|
|
|
|
}
|
|
|
|
|
2008-04-16 03:52:28 +08:00
|
|
|
.init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
INIT_SETUP(16)
|
2006-03-28 20:15:54 +08:00
|
|
|
}
|
|
|
|
|
2008-04-16 03:52:28 +08:00
|
|
|
.initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
INIT_CALLS
|
|
|
|
}
|
2006-03-28 20:15:54 +08:00
|
|
|
|
2008-04-16 03:52:28 +08:00
|
|
|
.con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
CON_INITCALL
|
2006-03-28 20:15:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECURITY_INIT
|
|
|
|
|
|
|
|
. = ALIGN(8);
|
2008-04-16 03:52:28 +08:00
|
|
|
__ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
|
2005-09-30 14:16:52 +08:00
|
|
|
__start___ftr_fixup = .;
|
|
|
|
*(__ftr_fixup)
|
|
|
|
__stop___ftr_fixup = .;
|
|
|
|
}
|
2008-07-01 23:16:40 +08:00
|
|
|
. = ALIGN(8);
|
2008-12-19 03:13:32 +08:00
|
|
|
__mmu_ftr_fixup : AT(ADDR(__mmu_ftr_fixup) - LOAD_OFFSET) {
|
|
|
|
__start___mmu_ftr_fixup = .;
|
|
|
|
*(__mmu_ftr_fixup)
|
|
|
|
__stop___mmu_ftr_fixup = .;
|
|
|
|
}
|
|
|
|
. = ALIGN(8);
|
2008-07-01 23:16:40 +08:00
|
|
|
__lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
|
|
|
|
__start___lwsync_fixup = .;
|
|
|
|
*(__lwsync_fixup)
|
|
|
|
__stop___lwsync_fixup = .;
|
|
|
|
}
|
2006-09-25 16:19:00 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
. = ALIGN(8);
|
2008-04-16 03:52:28 +08:00
|
|
|
__fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
|
2006-09-25 16:19:00 +08:00
|
|
|
__start___fw_ftr_fixup = .;
|
|
|
|
*(__fw_ftr_fixup)
|
|
|
|
__stop___fw_ftr_fixup = .;
|
|
|
|
}
|
|
|
|
#endif
|
2008-04-16 03:52:28 +08:00
|
|
|
.init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
INIT_RAM_FS
|
2006-03-28 20:15:54 +08:00
|
|
|
}
|
2009-09-24 22:36:24 +08:00
|
|
|
|
2011-03-25 01:50:09 +08:00
|
|
|
PERCPU_SECTION(L1_CACHE_BYTES)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
. = ALIGN(8);
|
2008-04-16 03:52:28 +08:00
|
|
|
.machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
|
2006-03-28 20:15:54 +08:00
|
|
|
__machine_desc_start = . ;
|
|
|
|
*(.machine.desc)
|
|
|
|
__machine_desc_end = . ;
|
|
|
|
}
|
2008-10-23 02:43:45 +08:00
|
|
|
#ifdef CONFIG_RELOCATABLE
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
. = ALIGN(8);
|
2011-12-15 06:58:12 +08:00
|
|
|
.dynsym : AT(ADDR(.dynsym) - LOAD_OFFSET)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_RELOCATABLE_PPC32
|
|
|
|
__dynamic_symtab = .;
|
|
|
|
#endif
|
|
|
|
*(.dynsym)
|
|
|
|
}
|
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as
a position-independent executable (PIE) when it is set. This involves
processing the dynamic relocations in the image in the early stages of
booting, even if the kernel is being run at the address it is linked at,
since the linker does not necessarily fill in words in the image for
which there are dynamic relocations. (In fact the linker does fill in
such words for 64-bit executables, though not for 32-bit executables,
so in principle we could avoid calling relocate() entirely when we're
running a 64-bit kernel at the linked address.)
The dynamic relocations are processed by a new function relocate(addr),
where the addr parameter is the virtual address where the image will be
run. In fact we call it twice; once before calling prom_init, and again
when starting the main kernel. This means that reloc_offset() returns
0 in prom_init (since it has been relocated to the address it is running
at), which necessitated a few adjustments.
This also changes __va and __pa to use an equivalent definition that is
simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are
constants (for 64-bit) whereas PHYSICAL_START is a variable (and
KERNELBASE ideally should be too, but isn't yet).
With this, relocatable kernels still copy themselves down to physical
address 0 and run there.
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-08-30 09:43:47 +08:00
|
|
|
.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*)
|
|
|
|
}
|
2008-10-23 02:43:45 +08:00
|
|
|
#endif
|
2015-10-08 07:28:28 +08:00
|
|
|
/* .exit.data is discarded at runtime, not link time,
|
|
|
|
* to deal with references from .exit.text
|
|
|
|
*/
|
|
|
|
.exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
|
|
|
|
EXIT_DATA
|
|
|
|
}
|
2006-03-28 20:15:54 +08:00
|
|
|
|
|
|
|
/* freed after init ends here */
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__init_end = .;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* And now the various read/write data
|
|
|
|
*/
|
|
|
|
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_sdata = .;
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2005-09-30 14:16:52 +08:00
|
|
|
#ifdef CONFIG_PPC32
|
2008-04-16 03:52:28 +08:00
|
|
|
.data : AT(ADDR(.data) - LOAD_OFFSET) {
|
2007-05-17 19:38:44 +08:00
|
|
|
DATA_DATA
|
2006-03-28 20:15:54 +08:00
|
|
|
*(.sdata)
|
|
|
|
*(.got.plt) *(.got)
|
|
|
|
}
|
2005-09-30 14:16:52 +08:00
|
|
|
#else
|
2008-04-16 03:52:28 +08:00
|
|
|
.data : AT(ADDR(.data) - LOAD_OFFSET) {
|
2007-06-17 10:29:04 +08:00
|
|
|
DATA_DATA
|
|
|
|
*(.data.rel*)
|
|
|
|
*(.toc1)
|
2006-03-28 20:15:54 +08:00
|
|
|
*(.branch_lt)
|
|
|
|
}
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2008-04-16 03:52:28 +08:00
|
|
|
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
|
2006-03-28 20:15:54 +08:00
|
|
|
*(.opd)
|
|
|
|
}
|
|
|
|
|
2015-05-14 12:45:40 +08:00
|
|
|
. = ALIGN(256);
|
2008-04-16 03:52:28 +08:00
|
|
|
.got : AT(ADDR(.got) - LOAD_OFFSET) {
|
2006-03-28 20:15:54 +08:00
|
|
|
__toc_start = .;
|
2012-11-27 01:39:03 +08:00
|
|
|
#ifndef CONFIG_RELOCATABLE
|
|
|
|
__prom_init_toc_start = .;
|
|
|
|
arch/powerpc/kernel/prom_init.o*(.toc .got)
|
|
|
|
__prom_init_toc_end = .;
|
|
|
|
#endif
|
2006-03-28 20:15:54 +08:00
|
|
|
*(.got)
|
|
|
|
*(.toc)
|
|
|
|
}
|
2005-09-30 14:16:52 +08:00
|
|
|
#endif
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
/* The initial task and kernel stack */
|
2010-02-20 08:03:35 +08:00
|
|
|
INIT_TASK_DATA_SECTION(THREAD_SIZE)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2010-02-20 08:03:37 +08:00
|
|
|
.data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
PAGE_ALIGNED_DATA(PAGE_SIZE)
|
2006-03-28 20:15:54 +08:00
|
|
|
}
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2010-02-20 08:03:34 +08:00
|
|
|
.data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
|
2006-03-28 20:15:54 +08:00
|
|
|
}
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2010-02-20 08:03:44 +08:00
|
|
|
.data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
READ_MOSTLY_DATA(L1_CACHE_BYTES)
|
2007-07-04 12:04:31 +08:00
|
|
|
}
|
|
|
|
|
2009-09-29 14:00:06 +08:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
2008-04-16 03:52:28 +08:00
|
|
|
.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
|
2009-09-24 22:36:24 +08:00
|
|
|
NOSAVE_DATA
|
2006-03-28 20:15:54 +08:00
|
|
|
}
|
2005-10-10 20:38:46 +08:00
|
|
|
|
2009-08-10 03:06:24 +08:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_edata = .;
|
|
|
|
PROVIDE32 (edata = .);
|
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
/*
|
|
|
|
* And finally the bss
|
|
|
|
*/
|
|
|
|
|
2009-09-24 22:36:24 +08:00
|
|
|
BSS_SECTION(0, 0, 0)
|
2005-09-26 14:04:21 +08:00
|
|
|
|
2006-03-28 20:15:54 +08:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_end = . ;
|
|
|
|
PROVIDE32 (end = .);
|
linker script: unify usage of discard definition
Discarded sections in different archs share some commonality but have
considerable differences. This led to linker script for each arch
implementing its own /DISCARD/ definition, which makes maintaining
tedious and adding new entries error-prone.
This patch makes all linker scripts to move discard definitions to the
end of the linker script and use the common DISCARDS macro. As ld
uses the first matching section definition, archs can include default
discarded sections by including them earlier in the linker script.
ia64 is notable because it first throws away some ia64 specific
subsections and then include the rest of the sections into the final
image, so those sections must be discarded before the inclusion.
defconfig compile tested for x86, x86-64, powerpc, powerpc64, ia64,
alpha, sparc, sparc64 and s390. Michal Simek tested microblaze.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Tested-by: Michal Simek <monstr@monstr.eu>
Cc: linux-arch@vger.kernel.org
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Tony Luck <tony.luck@intel.com>
2009-07-09 10:27:40 +08:00
|
|
|
|
|
|
|
/* Sections to be discarded. */
|
|
|
|
DISCARDS
|
2005-09-26 14:04:21 +08:00
|
|
|
}
|