Reply by Dave Nadler April 5, 20162016-04-05
On Thursday, October 22, 2015 at 6:35:04 PM UTC-4, srao wrote:
> I need to cut down the size occupied by the boot code drastically to add > in new code. The current memory occupied by boot code +application+ram in > an external flash memory chip is together 1MB. This cannot be increased. > The boot code is located at the high address. All source code is written > in C++. > > This is clearly an embedded/firmware query and would need help so as to > how to optimize the source code keeping in mind the memory constraint. > This problem might not have one single solution, I am looking for ways in > which i can approach it. > > Details: Enhancement on a legacy code, borland compiler, 32bit flash > memory chip. > Limitations: > 1. no IDE. Build process is using make, breakpoints cannot be added. > 2. boot Make file build the boot.hex image file based on its dependent > files. > > FOR EXAMPLE : The boot make file below has files a and b dependent on it > to be built to create an hex image file. These files a, b contribute to > the code memory and hence overall boot memory. > > $(ObjDir)a.obj: w:a.cpp > $(ObjDir)b.obj: w:b.cpp > main_obj= > $(ObjDir)a.obj > $(ObjDir)b.obj > mainEXE.exe:$(main_obj) > mainEXE.exe > mainEXE.map > > Could someone please help me with possible steps to be taken to > decrease/optimize existing code or how to go about looking at this > problem? > --------------------------------------- > Posted through http://www.EmbeddedRelated.com
Have you finished this project successfully?
Reply by Dave Nadler November 10, 20152015-11-10
On Wednesday, October 28, 2015 at 5:40:25 PM UTC-4, srao wrote:
> ...I have already identified a few parts of code, which > were unused and excluded from build, but i believe there are more such > possibilities which I might not be able to quickly identify and that's how > the question popped up in the first place.
Have you finished this project successfully?
Reply by Dave Nadler October 28, 20152015-10-28
On Wednesday, October 28, 2015 at 4:37:30 PM UTC-4, srao wrote:
> Dave, Is Objxref a tool or just an exe download?
It should be in the same directory as the compiler...
Reply by srao October 28, 20152015-10-28
>On 28/10/15 21:32, Tauno Voipio wrote: >> On 28.10.15 22:09, Grant Edwards wrote: >>> On 2015-10-28, srao <109468@EmbeddedRelated> wrote: >>> >>>> Is there a tool to identify the unused functions so that i can >>>> exclude them from the build? >>> >>> GCC and Gnu binutils will do that automatically for you at link time >>> if you use the right options (-ffunction-sections for gcc and >>> --gc-sections for ld). >>> >>> I assume any decent toolchain will have equivalent options. >> >> >> The Borland things are so old that the link-time optimization was only >> a twinkle in the father's eye. >> > >Actually, Borland tools have had "smart linking" (if I remember their >term for it correctly) from way back in the DOS days. It is not >link-time optimisation, but it simply omits functions that are not used >in the final link image. > >Despite being suggested many times, the OP still has given no indication
>that he has looked at the map file, or considered compile-time and >link-time options, or looked at any documentation for the toolchain. >Until he has control of these basics, any effort in helping him is
wasted.
> >(To the OP - if you /have/ studied the map file and compiler and linker >options, let us know the results of your research. The more information
>you give, the better the help you can get.)
As said by Tauno Voipio above, this version does not provide complete link time optimisation. I have already identified a few parts of code, which were unused and excluded from build, but i believe there are more such possibilities which I might not be able to quickly identify and that's how the question popped up in the first place. --------------------------------------- Posted through http://www.EmbeddedRelated.com
Reply by Dave Nadler October 28, 20152015-10-28
On Wednesday, October 28, 2015 at 4:09:26 PM UTC-4, Grant Edwards wrote:
> I assume any decent toolchain will have equivalent options.
Well, it was a decent toolchain two decades ago, but the objxref utility is the closest thing... Also, it can't strip unused functions; modules get pulled in whole. See ya, Dave
Reply by David Brown October 28, 20152015-10-28
On 28/10/15 21:32, Tauno Voipio wrote:
> On 28.10.15 22:09, Grant Edwards wrote: >> On 2015-10-28, srao <109468@EmbeddedRelated> wrote: >> >>> Is there a tool to identify the unused functions so that i can >>> exclude them from the build? >> >> GCC and Gnu binutils will do that automatically for you at link time >> if you use the right options (-ffunction-sections for gcc and >> --gc-sections for ld). >> >> I assume any decent toolchain will have equivalent options. > > > The Borland things are so old that the link-time optimization was only > a twinkle in the father's eye. >
Actually, Borland tools have had "smart linking" (if I remember their term for it correctly) from way back in the DOS days. It is not link-time optimisation, but it simply omits functions that are not used in the final link image. Despite being suggested many times, the OP still has given no indication that he has looked at the map file, or considered compile-time and link-time options, or looked at any documentation for the toolchain. Until he has control of these basics, any effort in helping him is wasted. (To the OP - if you /have/ studied the map file and compiler and linker options, let us know the results of your research. The more information you give, the better the help you can get.)
Reply by srao October 28, 20152015-10-28
>On Wednesday, October 28, 2015 at 2:00:05 PM UTC-4, srao wrote: >>... Is there a tool to >>identify the unused functions so that i can exclude them from the
build?
>>So far I have been using source tree to find the link between various >>files/functions. > >You can try Borland objxref. WARNING: Don't take OBJXREF output too >seriously. A label listed as 'unreferenced' means it is not referenced >outside the module that defines it. It is not NECESSARILY unused, >but probably it should not be global. objxref has lots of other >'features' with C++ code as well. > >Hope that helps, >Best Regards, Dave
Thanks Roberto and Dave. Dave, Is Objxref a tool or just an exe download? I am asking because, I looked it up, and did not find a trustworthy source to download it. --------------------------------------- Posted through http://www.EmbeddedRelated.com
Reply by Tauno Voipio October 28, 20152015-10-28
On 28.10.15 22:09, Grant Edwards wrote:
> On 2015-10-28, srao <109468@EmbeddedRelated> wrote: > >> Is there a tool to identify the unused functions so that i can >> exclude them from the build? > > GCC and Gnu binutils will do that automatically for you at link time > if you use the right options (-ffunction-sections for gcc and > --gc-sections for ld). > > I assume any decent toolchain will have equivalent options.
The Borland things are so old that the link-time optimization was only a twinkle in the father's eye. -- -TV
Reply by Grant Edwards October 28, 20152015-10-28
On 2015-10-28, srao <109468@EmbeddedRelated> wrote:

> Is there a tool to identify the unused functions so that i can > exclude them from the build?
GCC and Gnu binutils will do that automatically for you at link time if you use the right options (-ffunction-sections for gcc and --gc-sections for ld). I assume any decent toolchain will have equivalent options. -- Grant Edwards grant.b.edwards Yow! Is it NOUVELLE at CUISINE when 3 olives are gmail.com struggling with a scallop in a plate of SAUCE MORNAY?
Reply by Dave Nadler October 28, 20152015-10-28
On Wednesday, October 28, 2015 at 2:00:05 PM UTC-4, srao wrote:
>... Is there a tool to >identify the unused functions so that i can exclude them from the build? >So far I have been using source tree to find the link between various >files/functions.
You can try Borland objxref. WARNING: Don't take OBJXREF output too seriously. A label listed as 'unreferenced' means it is not referenced outside the module that defines it. It is not NECESSARILY unused, but probably it should not be global. objxref has lots of other 'features' with C++ code as well. Hope that helps, Best Regards, Dave