Skip to main content
Visitor II
September 30, 2009
Question

Size of HEX file generated by GCC is toot large than expected

  • September 30, 2009
  • 3 replies
  • 1072 views
Posted on September 30, 2009 at 03:18

Size of HEX file generated by GCC is toot large than expected

    This topic has been closed for replies.

    3 replies

    sr_shindeAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:59

    Hi All,

    I am using GCC compiler with Anglia IDE.

    The hex file size generated by GCC is too large than expected.

    I have checked the MAP file generqated by GCC.

    GCC has defined addresses for each object file.

    Also it has defined addresses for each function that is defined in C file.

    It doesnt check whether it has been called by any function in the application.

    So the code is generated for all the function that is included in C file.

    Is there any setting need to be done such that code is generated only for the functions that is used in the application and not for the functions that is not even called by any function.

    I dont find any configuration in IDE for this.

    Does anybody know option setting of GCC for this?

    Please let me know.

    Thanks and regards

    Sai

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:59

    Make sure the following options are checked in settings:

    Split Functions and Split Data - this adds the following gcc options -ffunction-sections -fdata-sections.

    In the linker make sure you have Enable Garbage Collection enabled - this adds the ld options --gc-sections

    Cheers

    sjo

    sr_shindeAuthor
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:59

    Thanks a lot sjo.

    Regards

    Sai