This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Inline function attribute causes undefined symbol linking error

Hello ARM Community,

I am using DS-5 5.18.1. I have a C function which must be compiled inline to decrease latency of an FIQ handler. I referenced following document for syntax:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472k/chr1359124973480.html

Note that the attribute may accompany the function declaration and/or definition.

I added the attribute to the function declaration as below in example.c:

void foo(void) __attribute__((always_inline));

The following linking error was produced:

L6218E: Undefined symbol foo (referred from example.o).     C/C++ Problem

It is important to note that this error was not present before adding the inline attribute. There are no related warnings, nor any other errors. Why would this single change cause the preceding error?

Thank you,

Ryan

Parents
  • Hi Ryan,

          documentation of the always_inline attribute can be found here: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472k/chr1359124974010.html

    I tried to reproduce the issue you are seeing but it seems to work for me. I created main.c with:

    #include <stdio.h>
    
    void foo(void) __attribute__((always_inline));
    
    int main() {
      foo();
      return 0;
    }
    

    and extra.c with:

    void foo(void) {
      int i = 0;
      i = i+1;
    }
    

    Both files are compiled with armcc and then linked with armlink. The console output of DS-5 is:

    make all

    'Building file: ../extra.c'

    'Invoking: ARM C Compiler 5'

    armcc -O0 --loop_optimization_level=0 -g --md --depend_format=unix_escaped -c -o "extra.o" "../extra.c"

    'Finished building: ../extra.c'

    ' '

    'Building file: ../main.c'

    'Invoking: ARM C Compiler 5'

    armcc -O0 --loop_optimization_level=0 -g --md --depend_format=unix_escaped -c -o "main.o" "../main.c"

    'Finished building: ../main.c'

    ' '

    'Building target: test_inline.axf'

    'Invoking: ARM Linker 5'

    armlink --info=sizes -o "test_inline.axf"  ./extra.o ./main.o  

    The build is successful. I can reproduce the same error if I remove the definition of void foo(void) in extra.c.

    Do you have the definition of the foo function in the same file or in an external file ?

    Best Regards,

    Stefano

Reply
  • Hi Ryan,

          documentation of the always_inline attribute can be found here: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0472k/chr1359124974010.html

    I tried to reproduce the issue you are seeing but it seems to work for me. I created main.c with:

    #include <stdio.h>
    
    void foo(void) __attribute__((always_inline));
    
    int main() {
      foo();
      return 0;
    }
    

    and extra.c with:

    void foo(void) {
      int i = 0;
      i = i+1;
    }
    

    Both files are compiled with armcc and then linked with armlink. The console output of DS-5 is:

    make all

    'Building file: ../extra.c'

    'Invoking: ARM C Compiler 5'

    armcc -O0 --loop_optimization_level=0 -g --md --depend_format=unix_escaped -c -o "extra.o" "../extra.c"

    'Finished building: ../extra.c'

    ' '

    'Building file: ../main.c'

    'Invoking: ARM C Compiler 5'

    armcc -O0 --loop_optimization_level=0 -g --md --depend_format=unix_escaped -c -o "main.o" "../main.c"

    'Finished building: ../main.c'

    ' '

    'Building target: test_inline.axf'

    'Invoking: ARM Linker 5'

    armlink --info=sizes -o "test_inline.axf"  ./extra.o ./main.o  

    The build is successful. I can reproduce the same error if I remove the definition of void foo(void) in extra.c.

    Do you have the definition of the foo function in the same file or in an external file ?

    Best Regards,

    Stefano

Children