Today I wish to write about the way I’m currently losing my head to get Ruby-Elf testsuite to apply over other compilres beside GCC. Since I’ve been implementing some new features for
missingstatic upon request (by Emanuele “exg”), I decided to add some more tests, in particular considering Sun and Intel compilers that I decided to support for FFmpeg at least.
The new tests not only apply the already-present generic ELF tests (but rewritten and improved, so that I can extend them much more quickly) over files built with ICC and Sun Studio under Linux/AMD64, but also adds tests to check for the nm(1)-like code on a catalogue of different symbols.
The results are interesting in my view:
- Sun Studio does not generate
.data.relsections, it only generates a single
.picdatasection, which is not divided between read-only and read-write (which might have bad results with prelinking);
- Sun Studio also emits uninitialised non-static TLS variables as common symbols rather than in
.tbss(this sounds like a mistake to me sincerely!);
- the Intel C Compiler enables optimisation by default;
- it also optimises out unused static symbols with -O0;
- and even with
__attribute__((used))it optimises out static uninitialised variables (both TLS and non-TLS);
- oh and it puts a “.0” suffix to the name of unit-static data symbols (I guess to discern between them and function-static symbols, that usually have a code after them);
- and least but not last: ICC does not emit a
.data.relsection, nor a
.picdatasection: everything is emitted in
.datasection. This means that if you’re building something with ICC and expect
cowstatsto work on it, then you’re out of luck; but it’s not just that, it also means that prelinking will not help you at all to reduce memory usage, just a bit to reduce startup time.
Fixing up some stuff for Sun Studio was easy, and now
cowstats will work fine even under Sun Studio compiled source code, taking care of ICC quirks not so much, and also meant wasting time.
On the other hand, there is one new feature to
missingstatic: now it shows the nm(1)-like symbol near the symbols that are identified as missing the static modifier, this way you can tell if it’s a function, or constant, or a variable.
And of course, there are two manpages:
cowstats(1) (DocBook 5 rulez!) that describe the options and some of the working of the two tools; hopefully I’ll write more documentation in the next weeks and that’ll help Ruby-Elf being accepted and used. Once I have enough documentation about it I might actually decide to release something. — I’m also considering the idea of routing
man like git commands do.