This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Placing Functions in Data Segment


>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. The reason
>being that these functions do programming of flash memory so they cannot
>run from flash. The data segment is copied from Flash to RAM during the
>startup process so this is a very convenient way of getting the code from
>Flash to RAM.
>
>Currently I have compiled my C code to assembler and then modified the
>assembler file directly to place the functions into the data segment. This
>is a bit of a maintenance hassle and I would prefer some way of using the C
>file directly. 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.
>
I would use a special linker script that looks something like:

OUTPUT_FORMAT( "coff-m68k" )
OUTPUT_ARCH( m68k )

MEMORY {
  ram : ORIGIN = 0x10000, LENGTH = 10k
  flash: ORIGIN=0xff000000, LENGTH= 8M
}

SECTIONS {
  ramcode :   { ramcode.o(.text) }            > ram
  flashcode : { *(.text) } 		      > flash
}

Of course there are many more sections to take care of, just find what
linker file is used right now and modify it to suit your needs.

Regards

Anders Blomdell



------------------------------------------------------------------------------
 Anders Blomdell
 Department of Automatic Control        Email: anders.blomdell@control.lth.se
 Lund Institute of Technology           Phone: +46 46 222 4625
 Box 118, S-221 00 Lund, Sweden         Fax:   +46 46 138118



_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]