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.

MCU-PLUS-SDK-AM243X: combination of __attribute__ weak and section produces two symbols?

Part Number: MCU-PLUS-SDK-AM243X

Depending on the other thread https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1333895/mcu-plus-sdk-am243x-ccs-refuses-to-locate-the-correct-source-file-for-a-function/5108241#5108241

I noticed that if I use the weak-attribute on a function in parallel to the section-attribute it seems that the linker does notice the weak-attribute and uses another function with the same name if it is available, but it won't drop the previous weak-declared definition. We are compiling with tiarmclang LTS 3.2.0 and the -fdata-sections and -ffunction-sections options.

It looks the following:

The weak-declared function:

our function (it's guarded with extern "C"{} in a cpp-file):

I noticed that since the compiler produces the assembly code for it, but without a symbol in disassembly:

and for our function:

the map file only contains a symbol for our function:

also the space does seem to be available in the map-file:

tiarmreadelf also only shows our symbol, not the weak-one.

could it be that the section-attribute always tells the linker to place it inside a section even if it is declared weak and thus overwritten? I couldn't find any explanation for this in the compiler-manual. My guess is the linker just leaves it there and only corrects the call later on. what bugs a me a bit is that CCS finds that not-used function when there is not even a definition and I can even set a breakpoint into it. But it's never called.

PS: I removed the interrupt-attribute since it shouldn't be needed for a function directly called out of an interrupt-function, which is in this case the HwiP_data_abort_handler in the asm-file. The interrupt-attribute would lead to the behaviour that a warning would be generated with all follow-up called functions that it could clobber the interruptees VFP and setting the interrupt-attribute for all follow-up called fucntions would be a problem since the attribute generates a different function-return PC and so sets the PC 4 bytes back which means the function is called again instead of proceeding.

Best regards

Felix

  • Hello Felix,

    Thanks for reaching out to Texas Instruments E2E support forum.

    I have taken your inputs and working on it. Please allow some time to revert back.

    Regards,

    Tushar

  • Just to clarify, the code works as you expect.  The strong function is called.  The problem seems to be some hints of the weak function still remain.  I presume this is a fair summary.

    Please understand code for the weak function is present in the object file.  It is the linker which determines the strong function is present in a different object file, and then removes the weak function.  I suspect that, when the weak function is removed, the associated debug information is not removed with it.  And the Modules view in CCS reads debug information for the weak function that should not be present.  Or something along those lines.  I need to work with a few other people to confirm what I suspect.  Please be patient.

    Thanks and regards,

    -George

  • While I am not certain, I am confident that the cause is due to the known issue EXT_EP-11458.  Click that link for the details.

    We are compiling with tiarmclang LTS 3.2.0

    The issue is fixed in versions 3.2.1.LTS and higher.  The latest 3.2.x.LTS version currently available is 3.2.2.LTS.  Please upgrade to this version of the compiler.  The only difference with version 3.2.0.LTS is bug fixes, so there will be no compatibility issues.  

    Thanks and regards,

    -George

  • Thanks George!

    I will test it and come back to this thread.