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.

Help re linker warning: "section relative symbols from different output sections cannot be mixed"

I'm trying to do the following in my linker cmd file, in the SECTIONS area.

    /* RAM_L ****************************************************************************/
    RAM_Ts       : run  = 0x008000    page 0  RUN_START  (_RAM_L_START_LABEL)
    .ebss        : run  = RAM_L       page 0  RUN_START  (ebssStart)
    RAM_Dma      : run  = RAM_L(HIGH) page 0  RUN_END    (_RAM_L_END_LABEL)
    { _RAM_L_SIZE = _RAM_L_END_LABEL - _RAM_L_START_LABEL; }

When I do this, the computation works fine (_RAM_L_SIZE is computed correctly as 008000), but I get the following warning:

warning: section relative symbols from different output sections cannot be mixed; "_RAM_L_START_LABEL" is in section "RAM_Ts", "_RAM_L_END_LABEL" is in section "RAM_Dma"

This doesn't make sense to me, because I don't see how those symbols are section relative.  _RAM_L_START_LABEL is 008000, and _RAM_L_END_LABEL is 010000.  If they were relative, _RAM_L_START_LABEL would be 0, and _RAM_L_END_LABEL would be whatever the size of the RAM_Dma section is.  Also, the warning says the symbols cannot be mixed, yet they are being mixed and computed correctly.

Also, in SPRU514C (TMS320C28x Assembly Language Tools v5.0.0), there is an example that shows the following:

GROUP
{
    outsect:
    {
        start_of_outsect = .;
    }
    dummy: { size_of_outsect = . - start_of_outsect; }
}

If I try linking this, I get the same warning:

warning: section relative symbols from different output sections cannot be mixed; "start_of_outsect" is in section "outsect", "DOT operator" is in section "dummy"

Is there a way around this, or a better way to do it?  Can the warning be inhibited?  My sections aren't contiguous, so I can't put them in a GROUP statement.  I know I can compute the size at run time, but that seems silly when the value is obviously known at link time.

Thanks.

  • Joel Kuehner said:
    warning: section relative symbols from different output sections cannot be mixed; "_RAM_L_START_LABEL" is in section "RAM_Ts", "_RAM_L_END_LABEL" is in section "RAM_Dma"

    That error message is a bit misleading.  But the problem it points out is real.  Because _RAM_L_START_LABEL and _RAM_L_END_LABEL come from different sections, any expression that uses them both is suspect.  It works out OK in this case.  But it will not work out in all possible cases.  It works out for you because the sections RAM_Ts, .ebss, and RAM_Dma are laid out in memory in that order.  This ordering is not guaranteed.  One answer is to use GROUP and the START operator in combination.  Something like this ...

    GROUP {
       RAM_Ts ...
       .ebss ...
       RAM_Dma ...
    } SIZE(_RAM_L_SIZE)
    

    I presume here that you want to keep those sections in that order.  If you don't care about the order, then there are other possibilities to consider.

    As for this ...

    Joel Kuehner said:
    warning: section relative symbols from different output sections cannot be mixed; "start_of_outsect" is in section "outsect", "DOT operator" is in section "dummy"

    I can see how you might view that as a linker bug.  GROUP is being used here.  So, even though those two symbols arise from different sections, it still makes sense to use them in the same expression.  On the other hand, this example is being used as motivation for why the SIZE operator, and others like it, is in the linker.

    Thanks and regards,

    -George