What parts of the codebase are making binaries large?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












I have built some code for a simulator and am now trying to use TI's free toolchain to cross-compile to a target with 64kb of nvram. The compiler claims that my code is about 34kb beyond the ROM:



(...) msp430-elf/bin/ld: region `ROM' overflowed by 33716 bytes


Another line says it cannot fit the .text field into its allotted space. I cannot believe that my additions are 34kb in total, let alone causing the binaries to overflow by this amount.



  • The .o files my code has added to the project are a small fraction (200kb of the 1.9MB) of the project's total, and I have taken out a great deal of components that were in the project to begin with.

  • I am already passing the compiler the -Os -s flags.

  • The new code has about 100 characters worth of string literals.

  • My code uses many math.h functions (in fact it is the only part that does floating point arithmetic), make a call to strtod, and make a call to sprintf

Are there any tools or methods to breaks down what is causing the binaries to be so large?










share|improve this question

















  • 3




    Take a look at the linker-generated map file, it should hopefully tell you everything you need.
    – Some programmer dude
    1 hour ago










  • I'd like to see your own answer on how did you actually solve this ;)
    – Antti Haapala
    31 mins ago














up vote
6
down vote

favorite












I have built some code for a simulator and am now trying to use TI's free toolchain to cross-compile to a target with 64kb of nvram. The compiler claims that my code is about 34kb beyond the ROM:



(...) msp430-elf/bin/ld: region `ROM' overflowed by 33716 bytes


Another line says it cannot fit the .text field into its allotted space. I cannot believe that my additions are 34kb in total, let alone causing the binaries to overflow by this amount.



  • The .o files my code has added to the project are a small fraction (200kb of the 1.9MB) of the project's total, and I have taken out a great deal of components that were in the project to begin with.

  • I am already passing the compiler the -Os -s flags.

  • The new code has about 100 characters worth of string literals.

  • My code uses many math.h functions (in fact it is the only part that does floating point arithmetic), make a call to strtod, and make a call to sprintf

Are there any tools or methods to breaks down what is causing the binaries to be so large?










share|improve this question

















  • 3




    Take a look at the linker-generated map file, it should hopefully tell you everything you need.
    – Some programmer dude
    1 hour ago










  • I'd like to see your own answer on how did you actually solve this ;)
    – Antti Haapala
    31 mins ago












up vote
6
down vote

favorite









up vote
6
down vote

favorite











I have built some code for a simulator and am now trying to use TI's free toolchain to cross-compile to a target with 64kb of nvram. The compiler claims that my code is about 34kb beyond the ROM:



(...) msp430-elf/bin/ld: region `ROM' overflowed by 33716 bytes


Another line says it cannot fit the .text field into its allotted space. I cannot believe that my additions are 34kb in total, let alone causing the binaries to overflow by this amount.



  • The .o files my code has added to the project are a small fraction (200kb of the 1.9MB) of the project's total, and I have taken out a great deal of components that were in the project to begin with.

  • I am already passing the compiler the -Os -s flags.

  • The new code has about 100 characters worth of string literals.

  • My code uses many math.h functions (in fact it is the only part that does floating point arithmetic), make a call to strtod, and make a call to sprintf

Are there any tools or methods to breaks down what is causing the binaries to be so large?










share|improve this question













I have built some code for a simulator and am now trying to use TI's free toolchain to cross-compile to a target with 64kb of nvram. The compiler claims that my code is about 34kb beyond the ROM:



(...) msp430-elf/bin/ld: region `ROM' overflowed by 33716 bytes


Another line says it cannot fit the .text field into its allotted space. I cannot believe that my additions are 34kb in total, let alone causing the binaries to overflow by this amount.



  • The .o files my code has added to the project are a small fraction (200kb of the 1.9MB) of the project's total, and I have taken out a great deal of components that were in the project to begin with.

  • I am already passing the compiler the -Os -s flags.

  • The new code has about 100 characters worth of string literals.

  • My code uses many math.h functions (in fact it is the only part that does floating point arithmetic), make a call to strtod, and make a call to sprintf

Are there any tools or methods to breaks down what is causing the binaries to be so large?







c embedded cross-compiling microcontroller






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









enthdegree

492620




492620







  • 3




    Take a look at the linker-generated map file, it should hopefully tell you everything you need.
    – Some programmer dude
    1 hour ago










  • I'd like to see your own answer on how did you actually solve this ;)
    – Antti Haapala
    31 mins ago












  • 3




    Take a look at the linker-generated map file, it should hopefully tell you everything you need.
    – Some programmer dude
    1 hour ago










  • I'd like to see your own answer on how did you actually solve this ;)
    – Antti Haapala
    31 mins ago







3




3




Take a look at the linker-generated map file, it should hopefully tell you everything you need.
– Some programmer dude
1 hour ago




Take a look at the linker-generated map file, it should hopefully tell you everything you need.
– Some programmer dude
1 hour ago












I'd like to see your own answer on how did you actually solve this ;)
– Antti Haapala
31 mins ago




I'd like to see your own answer on how did you actually solve this ;)
– Antti Haapala
31 mins ago












2 Answers
2






active

oldest

votes

















up vote
8
down vote



accepted










GNU binutils has tools to help you determine the size of each symbol or just each object file.



Have a look at size for instance: https://manpages.debian.org/jessie/binutils/size.1.en.html



nm is also worth a try, as it can show the size of each symbol in the object code: https://manpages.debian.org/jessie/binutils/nm.1.en.html



Know that printf, sprintf and many of the more complex library functions can often take up quite a few kB of extra ROM.



Floating point support using soft-floats will also bloat the code compared to using hard-float, i.e. using software emulation vs. hardware instructions to handle floating point.



Sometimes the compiler will add an astonishing amount of bloat :)
Careful inspecting the output of size and nm will give you intuition for what takes up much space and what doesn't.






share|improve this answer





























    up vote
    0
    down vote













    I once also had memory issus with a tiny MSP430 controller.
    The TI toolchain is linking large librarys into your binary if negativ values are possible or floating point is used. In my case it was about 10% - 20% of total memory usage.



    TIs free Code composer Studio does provide a very powerfull memory visualization (View -> Memory Allocation)



    What helped me a lot was changing the Initialization Model in the Linker settings and other optimization options. I am currently not working with an MSP430 controller so I can not tell you details anymore.






    share|improve this answer




















      Your Answer





      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52734501%2fwhat-parts-of-the-codebase-are-making-binaries-large%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      8
      down vote



      accepted










      GNU binutils has tools to help you determine the size of each symbol or just each object file.



      Have a look at size for instance: https://manpages.debian.org/jessie/binutils/size.1.en.html



      nm is also worth a try, as it can show the size of each symbol in the object code: https://manpages.debian.org/jessie/binutils/nm.1.en.html



      Know that printf, sprintf and many of the more complex library functions can often take up quite a few kB of extra ROM.



      Floating point support using soft-floats will also bloat the code compared to using hard-float, i.e. using software emulation vs. hardware instructions to handle floating point.



      Sometimes the compiler will add an astonishing amount of bloat :)
      Careful inspecting the output of size and nm will give you intuition for what takes up much space and what doesn't.






      share|improve this answer


























        up vote
        8
        down vote



        accepted










        GNU binutils has tools to help you determine the size of each symbol or just each object file.



        Have a look at size for instance: https://manpages.debian.org/jessie/binutils/size.1.en.html



        nm is also worth a try, as it can show the size of each symbol in the object code: https://manpages.debian.org/jessie/binutils/nm.1.en.html



        Know that printf, sprintf and many of the more complex library functions can often take up quite a few kB of extra ROM.



        Floating point support using soft-floats will also bloat the code compared to using hard-float, i.e. using software emulation vs. hardware instructions to handle floating point.



        Sometimes the compiler will add an astonishing amount of bloat :)
        Careful inspecting the output of size and nm will give you intuition for what takes up much space and what doesn't.






        share|improve this answer
























          up vote
          8
          down vote



          accepted







          up vote
          8
          down vote



          accepted






          GNU binutils has tools to help you determine the size of each symbol or just each object file.



          Have a look at size for instance: https://manpages.debian.org/jessie/binutils/size.1.en.html



          nm is also worth a try, as it can show the size of each symbol in the object code: https://manpages.debian.org/jessie/binutils/nm.1.en.html



          Know that printf, sprintf and many of the more complex library functions can often take up quite a few kB of extra ROM.



          Floating point support using soft-floats will also bloat the code compared to using hard-float, i.e. using software emulation vs. hardware instructions to handle floating point.



          Sometimes the compiler will add an astonishing amount of bloat :)
          Careful inspecting the output of size and nm will give you intuition for what takes up much space and what doesn't.






          share|improve this answer














          GNU binutils has tools to help you determine the size of each symbol or just each object file.



          Have a look at size for instance: https://manpages.debian.org/jessie/binutils/size.1.en.html



          nm is also worth a try, as it can show the size of each symbol in the object code: https://manpages.debian.org/jessie/binutils/nm.1.en.html



          Know that printf, sprintf and many of the more complex library functions can often take up quite a few kB of extra ROM.



          Floating point support using soft-floats will also bloat the code compared to using hard-float, i.e. using software emulation vs. hardware instructions to handle floating point.



          Sometimes the compiler will add an astonishing amount of bloat :)
          Careful inspecting the output of size and nm will give you intuition for what takes up much space and what doesn't.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 35 mins ago

























          answered 1 hour ago









          Morten Jensen

          3,20532741




          3,20532741






















              up vote
              0
              down vote













              I once also had memory issus with a tiny MSP430 controller.
              The TI toolchain is linking large librarys into your binary if negativ values are possible or floating point is used. In my case it was about 10% - 20% of total memory usage.



              TIs free Code composer Studio does provide a very powerfull memory visualization (View -> Memory Allocation)



              What helped me a lot was changing the Initialization Model in the Linker settings and other optimization options. I am currently not working with an MSP430 controller so I can not tell you details anymore.






              share|improve this answer
























                up vote
                0
                down vote













                I once also had memory issus with a tiny MSP430 controller.
                The TI toolchain is linking large librarys into your binary if negativ values are possible or floating point is used. In my case it was about 10% - 20% of total memory usage.



                TIs free Code composer Studio does provide a very powerfull memory visualization (View -> Memory Allocation)



                What helped me a lot was changing the Initialization Model in the Linker settings and other optimization options. I am currently not working with an MSP430 controller so I can not tell you details anymore.






                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  I once also had memory issus with a tiny MSP430 controller.
                  The TI toolchain is linking large librarys into your binary if negativ values are possible or floating point is used. In my case it was about 10% - 20% of total memory usage.



                  TIs free Code composer Studio does provide a very powerfull memory visualization (View -> Memory Allocation)



                  What helped me a lot was changing the Initialization Model in the Linker settings and other optimization options. I am currently not working with an MSP430 controller so I can not tell you details anymore.






                  share|improve this answer












                  I once also had memory issus with a tiny MSP430 controller.
                  The TI toolchain is linking large librarys into your binary if negativ values are possible or floating point is used. In my case it was about 10% - 20% of total memory usage.



                  TIs free Code composer Studio does provide a very powerfull memory visualization (View -> Memory Allocation)



                  What helped me a lot was changing the Initialization Model in the Linker settings and other optimization options. I am currently not working with an MSP430 controller so I can not tell you details anymore.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 16 mins ago









                  A.Rech

                  215




                  215



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52734501%2fwhat-parts-of-the-codebase-are-making-binaries-large%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery