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.

HALCoGen creates multiple functions in single file



Hello SafeTI Support

In HALCoGen I set up the GIO registers and generate the code, the gio.c file produced contains 11 functions for manipulating the GIO registers.

If in my code I am only using say 3 of the functions is there a setting somewhere in the compiler/linker so as it only includes in the final executable only those functions that are actually used?

Or do I need to delete from the file the functions that I’m not using?

I do not want to have dead/unreachable code in my executable.

Alternatively is there a setting in HALCoGen to select the functions required or maybe create one file per function so they can be removed by the linker (e.g. by putting them in a Library).

Regards

Bob Bacon

  • Actually the linker does not include the functions that are not called. Each function exists in its own subsection and is only included if it is referenced. There is no need to delete the functions and they do not end up in the final executable.
  • Hi Bob
    Are you sure about this or is there a setting in the linker I need to set ?

    I just tried this with a project that just calls gioInit but the map file includes all the gio.c functions :-
    0007022c gioDisableNotification
    00070208 gioEnableNotification
    00070170 gioGetBit
    00070198 gioGetPort
    00070010 gioInit
    000703f4 gioNotification
    00070100 gioSetBit
    000700e0 gioSetDirection
    00070150 gioSetPort
    000701b0 gioToggleBit

    My experience of compilers / linkers is that the compiler creates an object file for each *.c file and if you include a single function from that file it pulls in the entire object.

    If there is a switch or setting somewhere to change this that would be great.

    Thanks
    Bob Bacon
  • Ooops, sorry. Thought this option was on by default. You can either do whole program optimization, or turn on separate subsections for each function. The second option is under "Advanced Options"->"Runtime Model Options".

  • Thanks Bob
    That appears to work now
    Regards
    Bob Bacon