2005-11-05 02:36:59 +03:00
|
|
|
#ifdef CONFIG_PPC64
|
2006-03-28 16:15:54 +04:00
|
|
|
#define PROVIDE32(x) PROVIDE(__unused__##x)
|
2005-11-05 02:36:59 +03:00
|
|
|
#else
|
2006-03-28 16:15:54 +04:00
|
|
|
#define PROVIDE32(x) PROVIDE(x)
|
2005-11-05 02:36:59 +03:00
|
|
|
#endif
|
2008-04-15 23:52:26 +04:00
|
|
|
#include <asm/page.h>
|
2005-09-26 10:04:21 +04:00
|
|
|
#include <asm-generic/vmlinux.lds.h>
|
2007-07-04 08:04:31 +04:00
|
|
|
#include <asm/cache.h>
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2005-11-03 08:03:06 +03:00
|
|
|
ENTRY(_stext)
|
|
|
|
|
2008-07-22 03:03:45 +04: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 10:16:52 +04:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
OUTPUT_ARCH(powerpc:common64)
|
|
|
|
jiffies = jiffies_64;
|
|
|
|
#else
|
2005-09-26 10:04:21 +04:00
|
|
|
OUTPUT_ARCH(powerpc:common)
|
|
|
|
jiffies = jiffies_64 + 4;
|
2005-09-30 10:16:52 +04:00
|
|
|
#endif
|
2005-09-26 10:04:21 +04:00
|
|
|
SECTIONS
|
|
|
|
{
|
2006-03-28 16:15:54 +04:00
|
|
|
/* Sections to be discarded. */
|
|
|
|
/DISCARD/ : {
|
|
|
|
*(.exitcall.exit)
|
2008-01-20 16:15:03 +03:00
|
|
|
EXIT_DATA
|
2006-03-28 16:15:54 +04:00
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
. = KERNELBASE;
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
/*
|
|
|
|
* Text, read only data and other permanent read-only sections
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Text and gots */
|
2008-04-15 23:52:28 +04:00
|
|
|
.text : AT(ADDR(.text) - LOAD_OFFSET) {
|
2007-09-14 00:42:35 +04:00
|
|
|
ALIGN_FUNCTION();
|
|
|
|
*(.text.head)
|
2006-12-07 04:14:04 +03:00
|
|
|
_text = .;
|
powerpc: Introduce infrastructure for feature sections with alternatives
The current feature section logic only supports nop'ing out code, this means
if you want to choose at runtime between instruction sequences, one or both
cases will have to execute the nop'ed out contents of the other section, eg:
BEGIN_FTR_SECTION
or 1,1,1
END_FTR_SECTION_IFSET(FOO)
BEGIN_FTR_SECTION
or 2,2,2
END_FTR_SECTION_IFCLR(FOO)
and the resulting code will be either,
or 1,1,1
nop
or,
nop
or 2,2,2
For small code segments this is fine, but for larger code blocks and in
performance criticial code segments, it would be nice to avoid the nops.
This commit starts to implement logic to allow the following:
BEGIN_FTR_SECTION
or 1,1,1
FTR_SECTION_ELSE
or 2,2,2
ALT_FTR_SECTION_END_IFSET(FOO)
and the resulting code will be:
or 1,1,1
or,
or 2,2,2
We achieve this by extending the existing FTR macros. The current feature
section semantic just becomes a special case, ie. if the else case is empty
we nop out the default case.
The key limitation is that the size of the else case must be less than or
equal to the size of the default case. If the else case is smaller the
remainder of the section is nop'ed.
We let the linker put the else case code in with the rest of the text,
so that relative branches from the else case are more likley to link,
this has the disadvantage that we can't free the unused else cases.
This commit introduces the required macro and linker script changes, but
does not enable the patching of the alternative sections.
We also need to update two hand-made section entries in reg.h and timex.h
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2008-06-24 05:32:54 +04:00
|
|
|
*(.text .fixup .text.init.refok .exit.text.refok __ftr_alt_*)
|
2006-03-28 16:15:54 +04:00
|
|
|
SCHED_TEXT
|
|
|
|
LOCK_TEXT
|
|
|
|
KPROBES_TEXT
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
*(.got1)
|
|
|
|
__got2_start = .;
|
|
|
|
*(.got2)
|
|
|
|
__got2_end = .;
|
|
|
|
#endif /* CONFIG_PPC32 */
|
|
|
|
|
2008-07-22 03:03:45 +04:00
|
|
|
} :kernel
|
2006-03-28 16:15:54 +04:00
|
|
|
|
2008-09-02 09:04:09 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_etext = .;
|
|
|
|
PROVIDE32 (etext = .);
|
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
/* Read-only data */
|
|
|
|
RODATA
|
|
|
|
|
|
|
|
/* Exception & bug tables */
|
2008-04-15 23:52:28 +04:00
|
|
|
__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
|
2005-09-26 10:04:21 +04:00
|
|
|
__start___ex_table = .;
|
|
|
|
*(__ex_table)
|
|
|
|
__stop___ex_table = .;
|
|
|
|
}
|
|
|
|
|
2008-07-22 03:03:45 +04:00
|
|
|
NOTES :kernel :notes
|
|
|
|
|
|
|
|
/* The dummy segment contents for the bug workaround mentioned above
|
|
|
|
near PHDRS. */
|
2008-07-25 04:08:41 +04:00
|
|
|
.dummy : AT(ADDR(.dummy) - LOAD_OFFSET) {
|
2008-07-22 03:03:45 +04:00
|
|
|
LONG(0xf177)
|
|
|
|
} :kernel :dummy
|
2007-07-19 12:48:38 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
/*
|
|
|
|
* Init sections discarded at runtime
|
|
|
|
*/
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__init_begin = .;
|
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
_sinittext = .;
|
2008-01-20 16:15:03 +03:00
|
|
|
INIT_TEXT
|
2006-03-28 16:15:54 +04:00
|
|
|
_einittext = .;
|
2008-07-22 03:03:45 +04:00
|
|
|
} :kernel
|
2006-03-28 16:15:54 +04:00
|
|
|
|
|
|
|
/* .exit.text is discarded at runtime, not link time,
|
|
|
|
* to deal with references from __bug_table
|
|
|
|
*/
|
2008-04-15 23:52:28 +04:00
|
|
|
.exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
|
2008-01-20 16:15:03 +03:00
|
|
|
EXIT_TEXT
|
|
|
|
}
|
2006-03-28 16:15:54 +04:00
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
|
2008-01-20 16:15:03 +03:00
|
|
|
INIT_DATA
|
2006-03-28 16:15:54 +04:00
|
|
|
__vtop_table_begin = .;
|
|
|
|
*(.vtop_fixup);
|
|
|
|
__vtop_table_end = .;
|
|
|
|
__ptov_table_begin = .;
|
|
|
|
*(.ptov_fixup);
|
|
|
|
__ptov_table_end = .;
|
2006-05-19 11:04:48 +04:00
|
|
|
#ifdef CONFIG_PPC_ISERIES
|
|
|
|
__dt_strings_start = .;
|
|
|
|
*(.dt_strings);
|
|
|
|
__dt_strings_end = .;
|
|
|
|
#endif
|
2006-03-28 16:15:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
. = ALIGN(16);
|
2008-04-15 23:52:28 +04:00
|
|
|
.init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__setup_start = .;
|
|
|
|
*(.init.setup)
|
|
|
|
__setup_end = .;
|
|
|
|
}
|
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__initcall_start = .;
|
2006-10-27 22:41:44 +04:00
|
|
|
INITCALLS
|
2006-03-28 16:15:54 +04:00
|
|
|
__initcall_end = .;
|
|
|
|
}
|
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__con_initcall_start = .;
|
|
|
|
*(.con_initcall.init)
|
|
|
|
__con_initcall_end = .;
|
|
|
|
}
|
|
|
|
|
|
|
|
SECURITY_INIT
|
|
|
|
|
|
|
|
. = ALIGN(8);
|
2008-04-15 23:52:28 +04:00
|
|
|
__ftr_fixup : AT(ADDR(__ftr_fixup) - LOAD_OFFSET) {
|
2005-09-30 10:16:52 +04:00
|
|
|
__start___ftr_fixup = .;
|
|
|
|
*(__ftr_fixup)
|
|
|
|
__stop___ftr_fixup = .;
|
|
|
|
}
|
2008-07-01 19:16:40 +04:00
|
|
|
. = ALIGN(8);
|
|
|
|
__lwsync_fixup : AT(ADDR(__lwsync_fixup) - LOAD_OFFSET) {
|
|
|
|
__start___lwsync_fixup = .;
|
|
|
|
*(__lwsync_fixup)
|
|
|
|
__stop___lwsync_fixup = .;
|
|
|
|
}
|
2006-09-25 12:19:00 +04:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
. = ALIGN(8);
|
2008-04-15 23:52:28 +04:00
|
|
|
__fw_ftr_fixup : AT(ADDR(__fw_ftr_fixup) - LOAD_OFFSET) {
|
2006-09-25 12:19:00 +04:00
|
|
|
__start___fw_ftr_fixup = .;
|
|
|
|
*(__fw_ftr_fixup)
|
|
|
|
__stop___fw_ftr_fixup = .;
|
|
|
|
}
|
|
|
|
#endif
|
2007-02-10 12:44:44 +03:00
|
|
|
#ifdef CONFIG_BLK_DEV_INITRD
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
2008-04-15 23:52:28 +04:00
|
|
|
.init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__initramfs_start = .;
|
|
|
|
*(.init.ramfs)
|
|
|
|
__initramfs_end = .;
|
|
|
|
}
|
2007-02-10 12:44:44 +03:00
|
|
|
#endif
|
2007-05-02 21:27:12 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
2008-04-15 23:52:28 +04:00
|
|
|
.data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__per_cpu_start = .;
|
|
|
|
*(.data.percpu)
|
2007-07-19 12:48:12 +04:00
|
|
|
*(.data.percpu.shared_aligned)
|
2006-03-28 16:15:54 +04:00
|
|
|
__per_cpu_end = .;
|
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(8);
|
2008-04-15 23:52:28 +04:00
|
|
|
.machine.desc : AT(ADDR(.machine.desc) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__machine_desc_start = . ;
|
|
|
|
*(.machine.desc)
|
|
|
|
__machine_desc_end = . ;
|
|
|
|
}
|
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 05:43:47 +04:00
|
|
|
. = 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*)
|
|
|
|
}
|
2006-03-28 16:15:54 +04:00
|
|
|
|
powerpc: Sync RPA note in zImage with kernel's RPA note
Commit 9b09c6d909dfd8de96b99b9b9c808b94b0a71614 ("powerpc: Change the
default link address for pSeries zImage kernels") changed the
real-base value in the CHRP note added by the addnote program from
12MB to 32MB to give more space for Open Firmware to load the zImage.
(The real-base value says where we want OF to position itself in
memory.) However, this change was ineffective on most pSeries
machines, because the RPA note added by addnote has the "ignore me"
flag set to 1. This was intended to tell OF to ignore just the RPA
note, but has the side effect of also making OF ignore the CHRP note
(at least on most pSeries machines).
To solve this we have to set the "ignore me" flag to 0 in the RPA
note. (We can't just omit the RPA note because that is equivalent to
having an RPA note with default values, and the default values are not
what we want.) However, then we have to make sure the values in the
zImage's RPA note match up with the values that the kernel supplies
later in prom_init.c with either the ibm,client-architecture-support
call or the process-elf-header call in prom_send_capabilities().
So this sets the "ignore me" flag in the RPA note in addnote to 0, and
adjusts the RPA note values in addnote.c and in prom_init.c to be
consistent with each other and with the values in ibm_architecture_vec.
However, since the wrapper is independent of the kernel, this doesn't
ensure that the notes will stay consistent. To ensure that, this adds
code to addnote.c so that it can extract the kernel's RPA note from
the kernel binary and put that in the zImage. To that end, we put the
kernel's fake ELF header (which contains the kernel's RPA note) into
its own section, and arrange for wrapper to pull out that section with
objcopy and pass it to addnote, which then extracts the RPA note from
it and transfers it to the zImage.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2008-10-08 18:03:29 +04:00
|
|
|
/* Fake ELF header containing RPA note; for addnote */
|
|
|
|
.fakeelf : AT(ADDR(.fakeelf) - LOAD_OFFSET) { *(.fakeelf) }
|
|
|
|
|
2006-03-28 16:15:54 +04: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 10:04:21 +04:00
|
|
|
|
2005-09-30 10:16:52 +04:00
|
|
|
#ifdef CONFIG_PPC32
|
2008-04-15 23:52:28 +04:00
|
|
|
.data : AT(ADDR(.data) - LOAD_OFFSET) {
|
2007-05-17 15:38:44 +04:00
|
|
|
DATA_DATA
|
2006-03-28 16:15:54 +04:00
|
|
|
*(.sdata)
|
|
|
|
*(.got.plt) *(.got)
|
|
|
|
}
|
2005-09-30 10:16:52 +04:00
|
|
|
#else
|
2008-04-15 23:52:28 +04:00
|
|
|
.data : AT(ADDR(.data) - LOAD_OFFSET) {
|
2007-06-17 06:29:04 +04:00
|
|
|
DATA_DATA
|
|
|
|
*(.data.rel*)
|
|
|
|
*(.toc1)
|
2006-03-28 16:15:54 +04:00
|
|
|
*(.branch_lt)
|
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
*(.opd)
|
|
|
|
}
|
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.got : AT(ADDR(.got) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__toc_start = .;
|
|
|
|
*(.got)
|
|
|
|
*(.toc)
|
|
|
|
}
|
2005-09-30 10:16:52 +04:00
|
|
|
#endif
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_edata = .;
|
|
|
|
PROVIDE32 (edata = .);
|
|
|
|
|
|
|
|
/* The initial task and kernel stack */
|
|
|
|
#ifdef CONFIG_PPC32
|
|
|
|
. = ALIGN(8192);
|
2005-09-30 10:16:52 +04:00
|
|
|
#else
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(16384);
|
|
|
|
#endif
|
2008-04-15 23:52:28 +04:00
|
|
|
.data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
*(.data.init_task)
|
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
2008-04-15 23:52:28 +04:00
|
|
|
.data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
*(.data.page_aligned)
|
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
*(.data.cacheline_aligned)
|
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2007-07-04 08:04:31 +04:00
|
|
|
. = ALIGN(L1_CACHE_BYTES);
|
2008-04-15 23:52:28 +04:00
|
|
|
.data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
|
2007-07-04 08:04:31 +04:00
|
|
|
*(.data.read_mostly)
|
|
|
|
}
|
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
2008-04-15 23:52:28 +04:00
|
|
|
.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__nosave_begin = .;
|
|
|
|
*(.data.nosave)
|
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
__nosave_end = .;
|
|
|
|
}
|
2005-10-10 16:38:46 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
/*
|
|
|
|
* And finally the bss
|
|
|
|
*/
|
|
|
|
|
2008-04-15 23:52:28 +04:00
|
|
|
.bss : AT(ADDR(.bss) - LOAD_OFFSET) {
|
2006-03-28 16:15:54 +04:00
|
|
|
__bss_start = .;
|
|
|
|
*(.sbss) *(.scommon)
|
|
|
|
*(.dynbss)
|
|
|
|
*(.bss)
|
|
|
|
*(COMMON)
|
|
|
|
__bss_stop = .;
|
|
|
|
}
|
2005-09-26 10:04:21 +04:00
|
|
|
|
2006-03-28 16:15:54 +04:00
|
|
|
. = ALIGN(PAGE_SIZE);
|
|
|
|
_end = . ;
|
|
|
|
PROVIDE32 (end = .);
|
2005-09-26 10:04:21 +04:00
|
|
|
}
|