2005-11-05 10:36:59 +11:00
# ifdef C O N F I G _ P P C 6 4
2006-03-28 23:15:54 +11: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 10:36:59 +11:00
# else
2006-03-28 23:15:54 +11:00
# define P R O V I D E 3 2 ( x ) P R O V I D E ( x )
2005-11-05 10:36:59 +11:00
# endif
2008-04-16 05:52:26 +10:00
# include < a s m / p a g e . h >
2005-09-26 16:04:21 +10: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 14:04:31 +10:00
# include < a s m / c a c h e . h >
2005-09-26 16:04:21 +10:00
2005-11-03 16:03:06 +11:00
ENTRY( _ s t e x t )
2008-07-22 09:03:45 +10: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 16:16:52 +10: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 16:04:21 +10: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 16:16:52 +10:00
# endif
2005-09-26 16:04:21 +10:00
SECTIONS
{
2006-03-28 23:15:54 +11:00
/* Sections to be discarded. */
/ DISCARD/ : {
* ( .exitcall .exit )
2008-01-20 14:15:03 +01:00
EXIT_ D A T A
2006-03-28 23:15:54 +11:00
}
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11:00
. = KERNELBASE;
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11: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-16 05:52:28 +10:00
.text : AT( A D D R ( . t e x t ) - L O A D _ O F F S E T ) {
2007-09-13 15:42:35 -05:00
ALIGN_ F U N C T I O N ( ) ;
* ( .text .head )
2006-12-07 02:14:04 +01: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 11:32:54 +10:00
* ( .text .fixup .text .init .refok .exit .text .refok _ _ ftr_ a l t _ * )
2006-03-28 23:15:54 +11:00
SCHED_ T E X T
LOCK_ T E X T
KPROBES_ T E X T
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11: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 09:03:45 +10:00
} : kernel
2006-03-28 23:15:54 +11:00
2008-09-02 15:04:09 +10:00
. = ALIGN( P A G E _ S I Z E ) ;
_ etext = . ;
PROVIDE3 2 ( e t e x t = . ) ;
2006-03-28 23:15:54 +11:00
/* Read-only data */
RODATA
/* Exception & bug tables */
2008-04-16 05:52:28 +10:00
_ _ ex_ t a b l e : A T ( A D D R ( _ _ e x _ t a b l e ) - L O A D _ O F F S E T ) {
2005-09-26 16:04:21 +10:00
_ _ start_ _ _ e x _ t a b l e = . ;
* ( _ _ ex_ t a b l e )
_ _ stop_ _ _ e x _ t a b l e = . ;
}
2008-07-22 09:03:45 +10: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 10:08:41 +10:00
.dummy : AT( A D D R ( . d u m m y ) - L O A D _ O F F S E T ) {
2008-07-22 09:03:45 +10:00
LONG( 0 x f17 7 )
} : kernel : d u m m y
2007-07-19 01:48:38 -07:00
2006-03-28 23:15:54 +11: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 = . ;
2008-04-16 05:52:28 +10:00
.init .text : AT( A D D R ( . i n i t . t e x t ) - L O A D _ O F F S E T ) {
2006-03-28 23:15:54 +11:00
_ sinittext = . ;
2008-01-20 14:15:03 +01:00
INIT_ T E X T
2006-03-28 23:15:54 +11:00
_ einittext = . ;
2008-07-22 09:03:45 +10:00
} : kernel
2006-03-28 23:15:54 +11: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-16 05:52:28 +10: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 14:15:03 +01:00
EXIT_ T E X T
}
2006-03-28 23:15:54 +11:00
2008-04-16 05:52:28 +10: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 14:15:03 +01:00
INIT_ D A T A
2006-03-28 23:15:54 +11: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 17:04:48 +10: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 23:15:54 +11:00
}
. = ALIGN( 1 6 ) ;
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
_ _ setup_ s t a r t = . ;
* ( .init .setup )
_ _ setup_ e n d = . ;
}
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
_ _ initcall_ s t a r t = . ;
2006-10-27 11:41:44 -07:00
INITCALLS
2006-03-28 23:15:54 +11:00
_ _ initcall_ e n d = . ;
}
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
_ _ con_ i n i t c a l l _ s t a r t = . ;
* ( .con_initcall .init )
_ _ con_ i n i t c a l l _ e n d = . ;
}
SECURITY_ I N I T
. = ALIGN( 8 ) ;
2008-04-16 05:52:28 +10: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 16:16:52 +10: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-02 01:16:40 +10:00
. = ALIGN( 8 ) ;
2008-12-18 19:13:32 +00: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-02 01:16:40 +10: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 18:19:00 +10:00
# ifdef C O N F I G _ P P C 6 4
. = ALIGN( 8 ) ;
2008-04-16 05:52:28 +10: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 18:19:00 +10: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
2007-02-10 01:44:44 -08:00
# ifdef C O N F I G _ B L K _ D E V _ I N I T R D
2006-03-28 23:15:54 +11:00
. = ALIGN( P A G E _ S I Z E ) ;
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
_ _ initramfs_ s t a r t = . ;
* ( .init .ramfs )
_ _ initramfs_ e n d = . ;
}
2007-02-10 01:44:44 -08:00
# endif
2007-05-02 19:27:12 +02:00
. = ALIGN( P A G E _ S I Z E ) ;
2008-04-16 05:52:28 +10:00
.data .percpu : AT( A D D R ( . d a t a . p e r c p u ) - L O A D _ O F F S E T ) {
2006-03-28 23:15:54 +11:00
_ _ per_ c p u _ s t a r t = . ;
* ( .data .percpu )
2007-07-19 01:48:12 -07:00
* ( .data .percpu .shared_aligned )
2006-03-28 23:15:54 +11:00
_ _ per_ c p u _ e n d = . ;
}
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11:00
. = ALIGN( 8 ) ;
2008-04-16 05:52:28 +10: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 23:15:54 +11:00
_ _ machine_ d e s c _ s t a r t = . ;
* ( .machine .desc )
_ _ machine_ d e s c _ e n d = . ;
}
2008-10-22 18:43:45 +00: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 11:43:47 +10: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 18:43:45 +00:00
# endif
2006-03-28 23:15:54 +11: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 16:04:21 +10:00
2005-09-30 16:16:52 +10:00
# ifdef C O N F I G _ P P C 3 2
2008-04-16 05:52:28 +10:00
.data : AT( A D D R ( . d a t a ) - L O A D _ O F F S E T ) {
2007-05-17 13:38:44 +02:00
DATA_ D A T A
2006-03-28 23:15:54 +11:00
* ( .sdata )
* ( .got .plt ) * ( .got )
}
2005-09-30 16:16:52 +10:00
# else
2008-04-16 05:52:28 +10:00
.data : AT( A D D R ( . d a t a ) - L O A D _ O F F S E T ) {
2007-06-16 22:29:04 -04:00
DATA_ D A T A
* ( .data .rel * )
* ( .toc1 )
2006-03-28 23:15:54 +11:00
* ( .branch_lt )
}
2005-09-26 16:04:21 +10:00
2008-04-16 05:52:28 +10:00
.opd : AT( A D D R ( . o p d ) - L O A D _ O F F S E T ) {
2006-03-28 23:15:54 +11:00
* ( .opd )
}
2008-04-16 05:52:28 +10:00
.got : AT( A D D R ( . g o t ) - L O A D _ O F F S E T ) {
2006-03-28 23:15:54 +11:00
_ _ toc_ s t a r t = . ;
* ( .got )
* ( .toc )
}
2005-09-30 16:16:52 +10:00
# endif
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11:00
. = ALIGN( P A G E _ S I Z E ) ;
_ edata = . ;
PROVIDE3 2 ( e d a t a = . ) ;
/* The initial task and kernel stack */
# ifdef C O N F I G _ P P C 3 2
. = ALIGN( 8 1 9 2 ) ;
2005-09-30 16:16:52 +10:00
# else
2006-03-28 23:15:54 +11:00
. = ALIGN( 1 6 3 8 4 ) ;
# endif
2008-04-16 05:52:28 +10:00
.data .init_task : AT( A D D R ( . d a t a . i n i t _ t a s k ) - L O A D _ O F F S E T ) {
2006-03-28 23:15:54 +11:00
* ( .data .init_task )
}
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11:00
. = ALIGN( P A G E _ S I Z E ) ;
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
* ( .data .page_aligned )
}
2005-09-26 16:04:21 +10:00
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
* ( .data .cacheline_aligned )
}
2005-09-26 16:04:21 +10:00
2007-07-04 14:04:31 +10:00
. = ALIGN( L 1 _ C A C H E _ B Y T E S ) ;
2008-04-16 05:52:28 +10: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 ) {
2007-07-04 14:04:31 +10:00
* ( .data .read_mostly )
}
2006-03-28 23:15:54 +11:00
. = ALIGN( P A G E _ S I Z E ) ;
2008-04-16 05:52:28 +10: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 ) {
2006-03-28 23:15:54 +11:00
_ _ nosave_ b e g i n = . ;
* ( .data .nosave )
. = ALIGN( P A G E _ S I Z E ) ;
_ _ nosave_ e n d = . ;
}
2005-10-10 22:38:46 +10:00
2006-03-28 23:15:54 +11:00
/ *
* And f i n a l l y t h e b s s
* /
2008-04-16 05:52:28 +10:00
.bss : AT( A D D R ( . b s s ) - L O A D _ O F F S E T ) {
2006-03-28 23:15:54 +11:00
_ _ bss_ s t a r t = . ;
* ( .sbss ) * ( .scommon )
* ( .dynbss )
* ( .bss )
* ( COMMON)
_ _ bss_ s t o p = . ;
}
2005-09-26 16:04:21 +10:00
2006-03-28 23:15:54 +11:00
. = ALIGN( P A G E _ S I Z E ) ;
_ end = . ;
PROVIDE3 2 ( e n d = . ) ;
2005-09-26 16:04:21 +10:00
}