[PATCH] sparc all BSPs: Use function and data sections
Chris Johns
chrisj at rtems.org
Sat Oct 26 00:15:58 UTC 2013
On 26/10/2013 1:28 am, Joel Sherrill wrote:
>
> I would love to do this across all BSPs but it can also
> break a BSP. The first SPARC executables I got were 0x80
> bytes because I was missing some KEEP() and ENTRY() directives
> in the linker script.
>
> In addition, this isn't a big deal on many BSPs. I would
> love to see it used on low memory BSPs. IMO it should be
> universal on the ARM given that many of them are low memory
> and we already have shared linker scripts.
>
Do you have any metrics on the link time on large code bases ? I assume this approach places extra pressure on linker because the number of sections it needs to manage increases.
The RSB has an option --targetcflags which lets you supply flags like the ones you have added so I decided to see what it did. I am surprised by the results.
This is the size output for the samples using the current git master with your patch built with gcc-4.8.2 and newlib-18-Oct-2013 [1]:
../source-builder/sb-set-builder --log=log_sparc --prefix=/Users/chris/development/rtems/4.11 \
--trace 4.11/rtems-sparc
chris at huia sis $ arm-rtems4.11-size $(find . -name \*.exe)
text data bss dec hex filename
93344 1648 4336 99328 18400 ./sparc-rtems4.11/c/sis/testsuites/samples/base_sp/base_sp.exe
196480 2112 6160 204752 31fd0 ./sparc-rtems4.11/c/sis/testsuites/samples/capture/capture.exe
193504 2176 20896 216576 34e00 ./sparc-rtems4.11/c/sis/testsuites/samples/cdtest/cdtest.exe
466848 5184 15280 487312 76f90 ./sparc-rtems4.11/c/sis/testsuites/samples/fileio/fileio.exe
69632 1440 4000 75072 12540 ./sparc-rtems4.11/c/sis/testsuites/samples/hello/hello.exe
396944 6336 26576 429856 68f20 ./sparc-rtems4.11/c/sis/testsuites/samples/iostream/cxx_iostream.exe
260752 6080 8752 275584 43480 ./sparc-rtems4.11/c/sis/testsuites/samples/loopback/loopback.exe
36544 1056 3552 41152 a0c0 ./sparc-rtems4.11/c/sis/testsuites/samples/minimum/minimum.exe
103120 1712 4368 109200 1aa90 ./sparc-rtems4.11/c/sis/testsuites/samples/nsecs/nsecs.exe
161264 1984 4992 168240 29130 ./sparc-rtems4.11/c/sis/testsuites/samples/paranoia/paranoia.exe
420160 12112 36112 468384 725a0 ./sparc-rtems4.11/c/sis/testsuites/samples/pppd/pppd.exe
98368 1712 4368 104448 19800 ./sparc-rtems4.11/c/sis/testsuites/samples/ticker/ticker.exe
94864 1584 7840 104288 19760 ./sparc-rtems4.11/c/sis/testsuites/samples/unlimited/unlimited.exe
And here are the results with the gcc runtime and newlib built with the extra flags. The executables are larger.
../source-builder/sb-set-builder --log=log_sparc --prefix=/Users/chris/development/rtems/4.11 \
--targetcflags="-ffunction-sections -fdata-sections" --trace 4.11/rtems-sparc
chris at huia sis $ arm-rtems4.11-size $(find . -name \*.exe)
text data bss dec hex filename
99472 1616 4336 105424 19bd0 ./sparc-rtems4.11/c/sis/testsuites/samples/base_sp/base_sp.exe
210400 2080 6160 218640 35610 ./sparc-rtems4.11/c/sis/testsuites/samples/capture/capture.exe
217280 2144 20896 240320 3aac0 ./sparc-rtems4.11/c/sis/testsuites/samples/cdtest/cdtest.exe
522176 5136 15248 542560 84760 ./sparc-rtems4.11/c/sis/testsuites/samples/fileio/fileio.exe
72992 1456 4000 78448 13270 ./sparc-rtems4.11/c/sis/testsuites/samples/hello/hello.exe
455184 6304 26560 488048 77270 ./sparc-rtems4.11/c/sis/testsuites/samples/iostream/cxx_iostream.exe
270368 6048 8752 285168 459f0 ./sparc-rtems4.11/c/sis/testsuites/samples/loopback/loopback.exe
37152 1056 3552 41760 a320 ./sparc-rtems4.11/c/sis/testsuites/samples/minimum/minimum.exe
113952 1680 4368 120000 1d4c0 ./sparc-rtems4.11/c/sis/testsuites/samples/nsecs/nsecs.exe
176752 1952 4992 183696 2cd90 ./sparc-rtems4.11/c/sis/testsuites/samples/paranoia/paranoia.exe
445696 12080 36096 493872 78930 ./sparc-rtems4.11/c/sis/testsuites/samples/pppd/pppd.exe
106608 1680 4368 112656 1b810 ./sparc-rtems4.11/c/sis/testsuites/samples/ticker/ticker.exe
100800 1552 7840 110192 1ae70 ./sparc-rtems4.11/c/sis/testsuites/samples/unlimited/unlimited.exe
I have not looked into why and do not have the time. I feel extending this to other BSPs will require more investigation.
Note, the sparc stdc++ libraries are built with these flags by default.
Chris
[1] All tools built on MacOS 10.9 (Maverick) using clang (linked gcc).
More information about the devel
mailing list