This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/DRA829V: Conditional statements in ti-arm linker command file

Part Number: DRA829V

Tool/software: TI C/C++ Compiler

Hi,

Is it possible to use conditional statements in linker command file or the "?" operator?
For example if we need to define a mySymbol2 as following:

mySymbol0 = 0x0;
mySymbol1 = 0x3;
mySymbol2 = ( (mySymbol1 - mySymbol0) & 0x1) ? 0x7 : 0;

Please let me know if it is possible or if there is any other way to accomplish this.

thanks,
Rizwan

  • The ? operator is not supported.  The linker does support C-style preprocessing.  For details, please search the TI ARM assembly tools manual for the sub-chapter titled Linker Command File Preprocessing.

    Thanks and regards,

    -George

  • Hi George,

    I am asking this in context of setting up MPU configuration for Cortex-R5 CPUs.

    MPU needs a base address and region size. What utility does the linker provide to simplify MPU settings ( in C code we are going to use symbols which will be defined in linker script) keeping in view all the alignment constraints. Can you provide an example linker script which is developed for setting up MPU regions in c code?

    thanks,
    Rizwan

  • I don't know the specifics of the MPU.  But I can make a general suggestion that may be helpful.

    Write a header file similar to ... 

    /* mpu_memory.h */
    #define MPU_BASE 0x00800000
    #define MPU_SIZE 0x00040000

    C files and the linker command file include this file ...

    #include "mpu_memory.h"

    In the MEMORY directive of the linker command file, you can define the memory range for the MPU with these names ...

    MPU : origin = MPU_BASE, length = MPU_SIZE

    Thanks and regards,

    -George