Forums

Linker.cmd values in C program

Started by Peter Becher July 20, 2005
Hi All,

Is there a way to use values from the linker.cmd file in a C program?

Such as the .xStack ORIGIN and LENGTH values.

Thanks,
Pete


There might be better ways, but here is an example ...
 
 
MEMORY
{
...
 .xstack  (RW)  : ORIGIN = 0x0040, LENGTH = 0x0300  # stack
...
 .custom (R)   : ORIGIN = 0x2000, LENGTH = 0x0010  # custom stuff from this file 
...
}
    
SECTIONS
{
...
 
 
  .information :
  {
     _STACK_ORIGIN0x40;         # constant from MEMORY declaration above
     _STACK_LENGTH = 0x300;        # constant from MEMORY declaration above
     WRITEH( _STACK_ORIGIN );
  
   WRITEH( _STACK_LENGTH );
  } > .custom
 
              #
              # Make the custom variables global
              # and accessible from "C"
              # under the same name w/o the leading "F"
              #
   Fstack_origin = ADDR(.information) + 0;
   Fstack_length = ADDR(.information) + 1;
...
}
-----Original Message-----
From: Peter Becher [mailto:p...@dynatronix.com]
Sent: Wednesday, July 20, 2005 1:34 PM
To: m...@yahoogroups.com
Subject: [motoroladsp] Linker.cmd values in C program

Hi All,

Is there a way to use values from the linker.cmd file in a C program?

Such as the .xStack ORIGIN and LENGTH values.

Thanks,
Pete


The information contained in this message is confidential and intended only for use of the designated recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this message in error, and that any review, dissemination, distribution, copying, or alteration of this message is strictly prohibited. If you have received this communication in error, please notify the originator immediately and remove it from your system.



Hi William,

Thanks for the reply.

I was hoping there was a way to directly use the values entered in the MEMORY section.  I do something similar to what you are doing with constants but sometimes I forget to change both values.  Maybe I just need a better "memory".

Thanks,
Pete

At 03:55 PM 7/20/2005 -0400, Yochum, William wrote:
There might be better ways, but here is an example ...



MEMORY
{

...
.xstack  (RW)  : ORIGIN = 0x0040, LENGTH = 0x0300  # stack
...

.custom (R)   : ORIGIN = 0x2000, LENGTH = 0x0010  # custom stuff from this file
...
}
   
SECTIONS
{

...


  .information :
  {
     _STACK_ORIGIN 0x40;         # constant from MEMORY declaration above

     _STACK_LENGTH 0x300;        # constant from MEMORY declaration above
     WRITEH( _STACK_ORIGIN );
     WRITEH( _STACK_LENGTH );
  } > .custom


              #
              # Make the custom variables global
              # and accessible from "C"

              # under the same name w/o the leading "F"
              #
   Fstack_origin = ADDR(.information) + 0;

   Fstack_length ADDR(.information) + 1;
...
}
-----Original Message-----
From: Peter Becher [mailto:p...@dynatronix.com]
Sent: Wednesday, July 20, 2005 1:34 PM
To: m...@yahoogroups.com
Subject: [motoroladsp] Linker.cmd values in C program

Hi All,

Is there a way to use values from the linker.cmd file in a C program?

Such as the .xStack ORIGIN and LENGTH values.

Thanks, Pete