Placing Functions in Data Segment

Mark Powell
Fri Jun 4 04:57:00 GMT 1999

On 04-Jun-99 David Williams wrote:
>  Hi all,
>  I am using ECGS 1.1.1 for 68K (provided by Object Software) and have a need 
>  to place a small number of functions into the data segment.

>  Is there a pragma or some other special keyword, linker 
>  option, anything at all that would allow me to instruct the compiler to 
>  place these functions into the data segment.
>  Alternately is there a better way to run my code from RAM. It would have to 
>  be good though because this method seems quite effective to me.

Assuming you have the relevant functions in a separate file(s) and you are
using COFF, you can direct the linker to place the .text sections of those
files in RAM by placing commands in the linker script.  Something like this
should do it:

    ram   : ORIGIN = <wherever>, LENGTH = <whatever>
    rom   : ORIGIN = <wherever>, LENGTH = <whatever>

    /* Place code for RAM after the normal text, but located to run
     * in RAM.
     * The region between _ramtext and _eramtext must be copied from
     * ROM starting at _etext.
    .ramtext : AT(_etext)
        _ramtext = .;
        . = ALIGN(0x8);
        _eramtext  = .;
    } > ram

     * Normal .text in Flash EPROM.
    .text : {
        <other stuff>

        _etext = .;
    } > rom

    <other sections as normal>



Mark Powell, Senior Software Engineer, Primagraphics Limited
New Cambridge House, Litlington, nr.Royston, Herts, SG8 0SS, UK
Tel. +44 1763 852222, Fax. 853324,,

New CrossGCC FAQ:
To remove yourself from the crossgcc list, send
mail to with the
text 'unsubscribe' (without the quotes) in the
body of the message.

More information about the crossgcc mailing list