2005-11-05 02:36:59 +03:00
# ifdef C O N F I G _ P P C 6 4
2006-03-28 16:15:54 +04:00
# define P R O V I D E 3 2 ( x ) P R O V I D E ( _ _ u n u s e d _ _ ## x )
2005-11-05 02:36:59 +03:00
# else
2006-03-28 16:15:54 +04:00
# define P R O V I D E 3 2 ( x ) P R O V I D E ( x )
2005-11-05 02:36:59 +03:00
# endif
2008-04-15 23:52:26 +04:00
# include < a s m / p a g e . h >
2005-09-26 10:04:21 +04:00
# include < a s m - g e n e r i c / v m l i n u x . l d s . h >
2007-07-04 08:04:31 +04:00
# include < a s m / c a c h e . h >
2009-09-24 18:36:24 +04:00
# include < a s m / t h r e a d _ i n f o . h >
2005-09-26 10:04:21 +04:00
2005-11-03 08:03:06 +03:00
ENTRY( _ s t e x t )
2008-07-22 03:03:45 +04:00
PHDRS {
kernel P T _ L O A D F L A G S ( 7 ) ; /* RWX */
notes P T _ N O T E F L A G S ( 0 ) ;
dummy P T _ N O T E F L A G S ( 0 ) ;
/ * binutils < 2 . 1 8 h a s a b u g t h a t m a k e s i t m i s b e h a v e w h e n t a k i n g a n
ELF f i l e w i t h a l l s e g m e n t s a t l o a d a d d r e s s 0 a s i n p u t . T h i s
happens w h e n r u n n i n g " s t r i p " o n v m l i n u x , b e c a u s e o f t h e A T ( ) m a g i c
in t h i s l i n k e r s c r i p t . P e o p l e u s i n g G C C > = 4 . 2 w o n ' t r u n i n t o
this p r o b l e m , b e c a u s e t h e " b u i l d - i d " s u p p o r t w i l l p u t s o m e d a t a
into t h e " n o t e s " s e g m e n t ( a t a n o n - z e r o l o a d a d d r e s s ) .
To w o r k a r o u n d t h i s , w e f o r c e s o m e d a t a i n t o b o t h t h e " d u m m y "
segment a n d t h e k e r n e l s e g m e n t , s o t h e d u m m y s e g m e n t w i l l g e t a
non- z e r o l o a d a d d r e s s . I t ' s n o t e n o u g h t o a l w a y s c r e a t e t h e
" notes" s e g m e n t , s i n c e i f n o t h i n g g e t s a s s i g n e d t o i t , i t s l o a d
address w i l l b e z e r o . * /
}
2005-09-30 10:16:52 +04:00
# ifdef C O N F I G _ P P C 6 4
OUTPUT_ A R C H ( p o w e r p c : c o m m o n 6 4 )
jiffies = j i f f i e s _ 6 4 ;
# else
2005-09-26 10:04:21 +04:00
OUTPUT_ A R C H ( p o w e r p c : c o m m o n )
jiffies = j i f f i e s _ 6 4 + 4 ;
2005-09-30 10:16:52 +04:00
# endif
2005-09-26 10:04:21 +04:00
SECTIONS
{
2009-12-16 01:28:32 +03:00
. = 0 ;
reloc_ s t a r t = . ;
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, r e a d o n l y d a t a a n d o t h e r p e r m a n e n t r e a d - o n l y s e c t i o n s
* /
/* Text and gots */
2008-04-15 23:52:28 +04:00
.text : AT( A D D R ( . t e x t ) - L O A D _ O F F S E T ) {
2007-09-14 00:42:35 +04:00
ALIGN_ F U N C T I O N ( ) ;
2009-04-26 06:11:05 +04:00
HEAD_ T E X T
2006-12-07 04:14:04 +03:00
_ text = . ;
2009-04-28 19:47:15 +04:00
/* careful! __ftr_alt_* sections need to be close to .text */
* ( .text .fixup _ _ ftr_ a l t _ * . r e f . t e x t )
2006-03-28 16:15:54 +04:00
SCHED_ T E X T
LOCK_ T E X T
KPROBES_ T E X T
2009-02-10 08:10:27 +03:00
IRQENTRY_ T E X T
2005-09-26 10:04:21 +04:00
2006-03-28 16:15:54 +04:00
# ifdef C O N F I G _ P P C 3 2
* ( .got1 )
_ _ got2 _ s t a r t = . ;
* ( .got2 )
_ _ got2 _ e n d = . ;
# endif / * C O N F I G _ P P C 3 2 * /
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( P A G E _ S I Z E ) ;
_ etext = . ;
PROVIDE3 2 ( e t e x t = . ) ;
2006-03-28 16:15:54 +04:00
/* Read-only data */
RODATA
2009-09-24 18:36:24 +04:00
EXCEPTION_ T A B L E ( 0 )
2005-09-26 10:04:21 +04:00
2008-07-22 03:03:45 +04:00
NOTES : k e r n e l : n o t e s
/ * The d u m m y s e g m e n t c o n t e n t s f o r t h e b u g w o r k a r o u n d m e n t i o n e d a b o v e
near P H D R S . * /
2008-07-25 04:08:41 +04:00
.dummy : AT( A D D R ( . d u m m y ) - L O A D _ O F F S E T ) {
2009-01-02 13:46:04 +03:00
LONG( 0 )
LONG( 0 )
LONG( 0 )
2008-07-22 03:03:45 +04:00
} : kernel : d u m m y
2007-07-19 12:48:38 +04:00
2006-03-28 16:15:54 +04:00
/ *
* Init s e c t i o n s d i s c a r d e d a t r u n t i m e
* /
. = ALIGN( P A G E _ S I Z E ) ;
_ _ init_ b e g i n = . ;
2009-09-24 18:36:24 +04:00
INIT_ T E X T _ S E C T I O N ( P A G E _ S I Z E ) : k e r n e l
2006-03-28 16:15:54 +04:00
/ * .exit .text is discarded a t r u n t i m e , n o t l i n k t i m e ,
* to d e a l w i t h r e f e r e n c e s f r o m _ _ b u g _ t a b l e
* /
2008-04-15 23:52:28 +04:00
.exit .text : AT( A D D R ( . e x i t . t e x t ) - L O A D _ O F F S E T ) {
2008-01-20 16:15:03 +03:00
EXIT_ T E X T
}
2006-03-28 16:15:54 +04:00
2008-04-15 23:52:28 +04:00
.init .data : AT( A D D R ( . i n i t . d a t a ) - L O A D _ O F F S E T ) {
2008-01-20 16:15:03 +03:00
INIT_ D A T A
2006-03-28 16:15:54 +04:00
_ _ vtop_ t a b l e _ b e g i n = . ;
* ( .vtop_fixup ) ;
_ _ vtop_ t a b l e _ e n d = . ;
_ _ ptov_ t a b l e _ b e g i n = . ;
* ( .ptov_fixup ) ;
_ _ ptov_ t a b l e _ e n d = . ;
2006-05-19 11:04:48 +04:00
# ifdef C O N F I G _ P P C _ I S E R I E S
_ _ dt_ s t r i n g s _ s t a r t = . ;
* ( .dt_strings ) ;
_ _ dt_ s t r i n g s _ e n d = . ;
# endif
2006-03-28 16:15:54 +04:00
}
2008-04-15 23:52:28 +04:00
.init .setup : AT( A D D R ( . i n i t . s e t u p ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
INIT_ S E T U P ( 1 6 )
2006-03-28 16:15:54 +04:00
}
2008-04-15 23:52:28 +04:00
.initcall .init : AT( A D D R ( . i n i t c a l l . i n i t ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
INIT_ C A L L S
}
2006-03-28 16:15:54 +04:00
2008-04-15 23:52:28 +04:00
.con_initcall .init : AT( A D D R ( . c o n _ i n i t c a l l . i n i t ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
CON_ I N I T C A L L
2006-03-28 16:15:54 +04:00
}
SECURITY_ I N I T
. = ALIGN( 8 ) ;
2008-04-15 23:52:28 +04:00
_ _ ftr_ f i x u p : A T ( A D D R ( _ _ f t r _ f i x u p ) - L O A D _ O F F S E T ) {
2005-09-30 10:16:52 +04:00
_ _ start_ _ _ f t r _ f i x u p = . ;
* ( _ _ ftr_ f i x u p )
_ _ stop_ _ _ f t r _ f i x u p = . ;
}
2008-07-01 19:16:40 +04:00
. = ALIGN( 8 ) ;
2008-12-18 22:13:32 +03:00
_ _ mmu_ f t r _ f i x u p : A T ( A D D R ( _ _ m m u _ f t r _ f i x u p ) - L O A D _ O F F S E T ) {
_ _ start_ _ _ m m u _ f t r _ f i x u p = . ;
* ( _ _ mmu_ f t r _ f i x u p )
_ _ stop_ _ _ m m u _ f t r _ f i x u p = . ;
}
. = ALIGN( 8 ) ;
2008-07-01 19:16:40 +04:00
_ _ lwsync_ f i x u p : A T ( A D D R ( _ _ l w s y n c _ f i x u p ) - L O A D _ O F F S E T ) {
_ _ start_ _ _ l w s y n c _ f i x u p = . ;
* ( _ _ lwsync_ f i x u p )
_ _ stop_ _ _ l w s y n c _ f i x u p = . ;
}
2006-09-25 12:19:00 +04:00
# ifdef C O N F I G _ P P C 6 4
. = ALIGN( 8 ) ;
2008-04-15 23:52:28 +04:00
_ _ fw_ f t r _ f i x u p : A T ( A D D R ( _ _ f w _ f t r _ f i x u p ) - L O A D _ O F F S E T ) {
2006-09-25 12:19:00 +04:00
_ _ start_ _ _ f w _ f t r _ f i x u p = . ;
* ( _ _ fw_ f t r _ f i x u p )
_ _ stop_ _ _ f w _ f t r _ f i x u p = . ;
}
# endif
2008-04-15 23:52:28 +04:00
.init .ramfs : AT( A D D R ( . i n i t . r a m f s ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
INIT_ R A M _ F S
2006-03-28 16:15:54 +04:00
}
2009-09-24 18:36:24 +04:00
2011-01-25 16:26:50 +03:00
PERCPU( L 1 _ C A C H E _ B Y T E S , P A G E _ S I Z E )
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( A D D R ( . m a c h i n e . d e s c ) - L O A D _ O F F S E T ) {
2006-03-28 16:15:54 +04:00
_ _ machine_ d e s c _ s t a r t = . ;
* ( .machine .desc )
_ _ machine_ d e s c _ e n d = . ;
}
2008-10-22 22:43:45 +04:00
# ifdef C O N F I G _ R E L O C A T A B L E
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( A D D R ( . d y n s y m ) - L O A D _ O F F S E T ) { * ( . d y n s y m ) }
.dynstr : AT( A D D R ( . d y n s t r ) - L O A D _ O F F S E T ) { * ( . d y n s t r ) }
.dynamic : AT( A D D R ( . d y n a m i c ) - L O A D _ O F F S E T )
{
_ _ dynamic_ s t a r t = . ;
* ( .dynamic )
}
.hash : AT( A D D R ( . h a s h ) - L O A D _ O F F S E T ) { * ( . h a s h ) }
.interp : AT( A D D R ( . i n t e r p ) - L O A D _ O F F S E T ) { * ( . i n t e r p ) }
.rela .dyn : AT( A D D R ( . r e l a . d y n ) - L O A D _ O F F S E T )
{
_ _ rela_ d y n _ s t a r t = . ;
* ( .rela * )
}
2008-10-22 22:43:45 +04:00
# endif
2006-03-28 16:15:54 +04:00
/* freed after init ends here */
. = ALIGN( P A G E _ S I Z E ) ;
_ _ init_ e n d = . ;
/ *
* And n o w t h e v a r i o u s r e a d / w r i t e d a t a
* /
. = ALIGN( P A G E _ S I Z E ) ;
_ sdata = . ;
2005-09-26 10:04:21 +04:00
2005-09-30 10:16:52 +04:00
# ifdef C O N F I G _ P P C 3 2
2008-04-15 23:52:28 +04:00
.data : AT( A D D R ( . d a t a ) - L O A D _ O F F S E T ) {
2007-05-17 15:38:44 +04:00
DATA_ D A T A
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( A D D R ( . d a t a ) - L O A D _ O F F S E T ) {
2007-06-17 06:29:04 +04:00
DATA_ D A T A
* ( .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( A D D R ( . o p d ) - L O A D _ O F F S E T ) {
2006-03-28 16:15:54 +04:00
* ( .opd )
}
2008-04-15 23:52:28 +04:00
.got : AT( A D D R ( . g o t ) - L O A D _ O F F S E T ) {
2006-03-28 16:15:54 +04:00
_ _ toc_ s t a r t = . ;
* ( .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
/* The initial task and kernel stack */
2010-02-20 03:03:35 +03:00
INIT_ T A S K _ D A T A _ S E C T I O N ( T H R E A D _ S I Z E )
2005-09-26 10:04:21 +04:00
2010-02-20 03:03:37 +03:00
.data . .page_aligned : AT( A D D R ( . d a t a . . p a g e _ a l i g n e d ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
PAGE_ A L I G N E D _ D A T A ( P A G E _ S I Z E )
2006-03-28 16:15:54 +04:00
}
2005-09-26 10:04:21 +04:00
2010-02-20 03:03:34 +03:00
.data . .cacheline_aligned : AT( A D D R ( . d a t a . . c a c h e l i n e _ a l i g n e d ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
CACHELINE_ A L I G N E D _ D A T A ( L 1 _ C A C H E _ B Y T E S )
2006-03-28 16:15:54 +04:00
}
2005-09-26 10:04:21 +04:00
2010-02-20 03:03:44 +03:00
.data . .read_mostly : AT( A D D R ( . d a t a . . r e a d _ m o s t l y ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
READ_ M O S T L Y _ D A T A ( L 1 _ C A C H E _ B Y T E S )
2007-07-04 08:04:31 +04:00
}
2009-09-29 10:00:06 +04:00
. = ALIGN( P A G E _ S I Z E ) ;
2008-04-15 23:52:28 +04:00
.data_nosave : AT( A D D R ( . d a t a _ n o s a v e ) - L O A D _ O F F S E T ) {
2009-09-24 18:36:24 +04:00
NOSAVE_ D A T A
2006-03-28 16:15:54 +04:00
}
2005-10-10 16:38:46 +04:00
2009-08-09 23:06:24 +04:00
. = ALIGN( P A G E _ S I Z E ) ;
_ edata = . ;
PROVIDE3 2 ( e d a t a = . ) ;
2006-03-28 16:15:54 +04:00
/ *
* And f i n a l l y t h e b s s
* /
2009-09-24 18:36:24 +04:00
BSS_ S E C T I O N ( 0 , 0 , 0 )
2005-09-26 10:04:21 +04:00
2006-03-28 16:15:54 +04:00
. = ALIGN( P A G E _ S I Z E ) ;
_ end = . ;
PROVIDE3 2 ( e n d = . ) ;
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 06:27:40 +04:00
/* Sections to be discarded. */
DISCARDS
2005-09-26 10:04:21 +04:00
}