Re: msp430-elf-g++ optimizing out main()
Wylder Keane <[email protected]> Tue, 23 Sep 2014 16:29:32 -0700
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.user |
|---|---|
| Message-ID | <CAP1=f4wvR2PwctARWWD4T-0Nwrykw9dHL91p=yUsaF+rB9LjkQ@mail.gmail.com> |
Interesting that main() is not considered a root with gcc. The crt0.S start code which references main is in the binary that is generated event with the nodefaultlibs call. The minrt flag and it doesn't seem to make a difference. The map file is telling me a few small functions are being linked in (memset, memcpy) and I assume that since the standard library wasn't built with -ffunction-sections or -fdata-sections that it then links the entire library. Also, seeing a lot of exception handling code from libstdc++ as well despite specifying -fno-exceptions, -fno-rtti, and -fno-enforce-eh-specs. Is this also a side effect of the library not being build with those sections flags? If so, why isn't the library built like that for cases like this where you want to have only a few small functions? I'm going to remove all references to the official memset, memcpy, etc. and see if that fixes the issue. -Wylder On Tue, Sep 23, 2014 at 4:04 PM, DJ Delorie <[email protected]> wrote: > > main() is not a root with gcc, start() is (defined by your linker > script), and is usually provided by crt0.o - except you told it not to > with -nodefaultlibs. > > The flag you really want is -minrt, which tells gcc to encode extra > information in each object that helps the linker reduce the amount of > runtime needed to only the routines that will actually do something > useful (and, most likely, remove C++ constructors/destructors at the > same time). > > If even with that flag the code still doesn't fit, add > -Wl,-Map,somemap.txt and see *what* functions are getting included, > and why. It may turn out to be something silly. > > Also, if main() returns a value, the runtime may include extra > processing to happen at exit() time, which is kinda pointless on an > MCU. main() should end in a while(1); so it doesn't return. > ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Mspgcc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mspgcc-users