* Minimal linker script
@ 2009-05-09 8:00 Sam Ravnborg
2009-05-09 23:27 ` H. Peter Anvin
0 siblings, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2009-05-09 8:00 UTC (permalink / raw)
To: linux arch, LKML; +Cc: Tim Abbott
While trying to address the common patters in our
linker scripts I made a sketch of a minimal linker script.
As this will be the basis for my continued effort to create
a set of defines that can be used by all architectues I would like
to receive some feedback.
/*
* Helper macros to support writing architecture specific
* linker scripts.
*
* A minimal linker scripts has following content:
*
* OUTPUT_FORMAT(...)
* OUTPUT_ARCH(...)
* ENTRY(...)
* SECTIONS
* {
* . = START;
* __init_begin = .;
* HEAD_SECTION
* INIT_TEXT_SECTION(PAGE_SIZE)
* INIT_DATA_SECTION(...)
* PERCPU(PAGE_SIZE)
* __init_end = .;
*
* _stext = .;
* TEXT_SECTION = 0
* _etext = .;
*
* _sdata = .;
* RO_DATA_SECTION(PAGE_SIZE)
* RW_DATA_SECTION(...)
* _edata = .;
*
* EXCEPTION_TABLE(...)
* NOTES
*
* __bss_start = .;
* BSS_SECTION(0, 0)
* __bss_stop = .;
* _end = .;
*
* /DISCARD/ : {
* EXIT_TEXT
* EXIT_DATA
* *(.exitcall.exit)
* }
* STABS_DEBUG
* DWARF_DEBUG
* }
*
* [__init_begin, __init_end] is the init section that may be freed after init
* [_stext, _etext] is the text section
* [_sdata, _edata] is the data section
*
* Some of the included output section include their own set of constants.
* Examples are: [__initramfs_start, __initramfs_end] for initramfs and
* [__nosave_begin, __nosave_end] for the nosave data
*/
There is one majot issue in the minimal script I need to address.
All symbols are absolute (__init_begin, _stext etc) - I need to find a nice
way to make them non-absolute.
For now I and more interested in comments on the structure and the coverage
of the symbols.
I strikes me that [_stext, _etext] do not cover text in the init section.
And does [_sdata, _edata] cover RO_DATA?
What abut the order of the sections - are they significant for any archtecture?
I have used an order used by some of the embedded targets that allows
a maximum of code to reside inisde [__init_begin, __init_end].
Comments appreciated!
Sam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Minimal linker script
2009-05-09 8:00 Minimal linker script Sam Ravnborg
@ 2009-05-09 23:27 ` H. Peter Anvin
2009-05-09 23:27 ` H. Peter Anvin
2009-05-10 8:55 ` Sam Ravnborg
0 siblings, 2 replies; 5+ messages in thread
From: H. Peter Anvin @ 2009-05-09 23:27 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux arch, LKML, Tim Abbott
Sam Ravnborg wrote:
> * . = START;
> * __init_begin = .;
> * HEAD_SECTION
> * INIT_TEXT_SECTION(PAGE_SIZE)
> * INIT_DATA_SECTION(...)
> * PERCPU(PAGE_SIZE)
> * __init_end = .;
> *
> * _stext = .;
> * TEXT_SECTION = 0
> * _etext = .;
> *
> * _sdata = .;
> * RO_DATA_SECTION(PAGE_SIZE)
> * RW_DATA_SECTION(...)
> * _edata = .;
> *
> * EXCEPTION_TABLE(...)
> * NOTES
> *
> * __bss_start = .;
> * BSS_SECTION(0, 0)
> * __bss_stop = .;
> * _end = .;
> *
> *
> * [__init_begin, __init_end] is the init section that may be freed after init
> * [_stext, _etext] is the text section
> * [_sdata, _edata] is the data section
> *
> * Some of the included output section include their own set of constants.
> * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
> * [__nosave_begin, __nosave_end] for the nosave data
> */
>
It seems rather disturbing to me that different sections have different
start and end symbols. I realize this is largely for historical
reasons, but if we used a single pattern (e.g. something like
__text_start, __text_end for the .text section) then at least in the
i386 case we could easily recognize those as relocatable symbols even if
they show up as absolute.
Furthermore, consistency is a good thing, even if it means a bigger
changeset.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Minimal linker script
2009-05-09 23:27 ` H. Peter Anvin
@ 2009-05-09 23:27 ` H. Peter Anvin
2009-05-10 8:55 ` Sam Ravnborg
1 sibling, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2009-05-09 23:27 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux arch, LKML, Tim Abbott
Sam Ravnborg wrote:
> * . = START;
> * __init_begin = .;
> * HEAD_SECTION
> * INIT_TEXT_SECTION(PAGE_SIZE)
> * INIT_DATA_SECTION(...)
> * PERCPU(PAGE_SIZE)
> * __init_end = .;
> *
> * _stext = .;
> * TEXT_SECTION = 0
> * _etext = .;
> *
> * _sdata = .;
> * RO_DATA_SECTION(PAGE_SIZE)
> * RW_DATA_SECTION(...)
> * _edata = .;
> *
> * EXCEPTION_TABLE(...)
> * NOTES
> *
> * __bss_start = .;
> * BSS_SECTION(0, 0)
> * __bss_stop = .;
> * _end = .;
> *
> *
> * [__init_begin, __init_end] is the init section that may be freed after init
> * [_stext, _etext] is the text section
> * [_sdata, _edata] is the data section
> *
> * Some of the included output section include their own set of constants.
> * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
> * [__nosave_begin, __nosave_end] for the nosave data
> */
>
It seems rather disturbing to me that different sections have different
start and end symbols. I realize this is largely for historical
reasons, but if we used a single pattern (e.g. something like
__text_start, __text_end for the .text section) then at least in the
i386 case we could easily recognize those as relocatable symbols even if
they show up as absolute.
Furthermore, consistency is a good thing, even if it means a bigger
changeset.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Minimal linker script
2009-05-09 23:27 ` H. Peter Anvin
2009-05-09 23:27 ` H. Peter Anvin
@ 2009-05-10 8:55 ` Sam Ravnborg
2009-05-10 17:53 ` H. Peter Anvin
1 sibling, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2009-05-10 8:55 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: linux arch, LKML, Tim Abbott
On Sat, May 09, 2009 at 04:27:20PM -0700, H. Peter Anvin wrote:
> Sam Ravnborg wrote:
> > * . = START;
> > * __init_begin = .;
> > * HEAD_SECTION
> > * INIT_TEXT_SECTION(PAGE_SIZE)
> > * INIT_DATA_SECTION(...)
> > * PERCPU(PAGE_SIZE)
> > * __init_end = .;
> > *
> > * __text_begin = .;
> > * TEXT_SECTION = 0
> > * __text_end = .;
> > *
> > * __data_begin = .;
> > * RO_DATA_SECTION(PAGE_SIZE)
> > * RW_DATA_SECTION(...)
> > * __data_end = .;
> > *
> > * EXCEPTION_TABLE(...)
> > * NOTES
> > *
> > * __bss_start = .;
> > * BSS_SECTION(0, 0)
> > * __bss_end = .;
> > * _end = .;
> > *
> > *
> > * [__init_begin, __init_end] is the init section that may be freed after init
> > * [_stext, _etext] is the text section
> > * [_sdata, _edata] is the data section
> > *
> > * Some of the included output section include their own set of constants.
> > * Examples are: [__initramfs_start, __initramfs_end] for initramfs and
> > * [__nosave_begin, __nosave_end] for the nosave data
> > */
> >
>
> It seems rather disturbing to me that different sections have different
> start and end symbols. I realize this is largely for historical
> reasons, but if we used a single pattern (e.g. something like
> __text_start, __text_end for the .text section)
The 'oldish' names were kept only because they are widely used.
I agree to be consistent is better so will change it to be so.
I edited the sample above to consistently use __<section>_{begin,end}.
For now I kept '_end' as I had no better name for it.
> then at least in the
> i386 case we could easily recognize those as relocatable symbols even if
> they show up as absolute.
Do you then say that i386 could allow us to use absolute symbols,
and we could adjust in the code instead?
That would make the linker script nicer but with added
complexity in the code..
Sam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Minimal linker script
2009-05-10 8:55 ` Sam Ravnborg
@ 2009-05-10 17:53 ` H. Peter Anvin
0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2009-05-10 17:53 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: linux arch, LKML, Tim Abbott
Sam Ravnborg wrote:
>
> Do you then say that i386 could allow us to use absolute symbols,
> and we could adjust in the code instead?
>
> That would make the linker script nicer but with added
> complexity in the code..
>
Correct. The key, obviously, is to make sure we don't end up having to
adjust in multiple places all the time.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-05-10 17:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-09 8:00 Minimal linker script Sam Ravnborg
2009-05-09 23:27 ` H. Peter Anvin
2009-05-09 23:27 ` H. Peter Anvin
2009-05-10 8:55 ` Sam Ravnborg
2009-05-10 17:53 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox