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.

How to use RELATIONAL Expressions in Linker Command File

Hello,

In the spnu118h.pdf within the following section:

7.13.3 Assignment Expressions

there is a Table of Expressions with the following title: 

Table 7-2. Groups of Operators Used in Expressions (Precedence)

Please help me understand how do I use the RELATIONAL Expressions using Linker Symbols within a Linker Command File as mentioned in the above mentioned document.

The document title is:

ARM Assembly Language Tools

v4.6

User's Guide

Literature Number: SPNU118H

September

Thank you.

Regards

Pashan

  • This is a rather general question, so it is difficult to answer.  What is the overarching problem you want to solve?  

    The only expressions you can write in a linker command file are assignments.  There is no control flow (i.e. if statements).  So you can only write something like

    global_sym1 = global_sym2 >= global_sym3;

    global_sym1 is assigned the value 1 or 0 based on that relational expression.  Experiment with toy examples to get a feel for how it works.  

    Hope this helps ...

    -George

     

  • Imagine that you need define the maximum load address (that will go to the image) at link time (e.g. I needed this for special CRC-like header for the image).

    You can get load address, run address and size of the sections, also you can use "dot"-operator to get like-current address.

    But, further imagination, your sections have a big variety of load and start addresses, you can't GROUP them and "dot"-operator is also useless. You can get only load address, run address and size for each section. So how to get the maximum address?

    Lets we have __section_1_start, __section_1_size, __section_2_start, __section_2_size, __section_3_start and __section_3_size.

    define __section_x_end = __section_x_start + __section_x_size; for each.

    Now,

    __max_addr = __section_1_end;

    __compare = __max_addr > __section_2_end;

    __max_addr = __max_addr * __compare + __section_2_end * !__compare;

    __compare = __max_addr > __section_3_end;

    __max_addr = __max_addr * __compare + __section_3_end * !__compare;

    So now __max_addr hold our goal...

    But also we get warnings about symbol redifinition and symbol from different sections combining...

    Oh, maybe I missed some conditional operator in the linker symbols expressions??? :)