Don't embed timestamps!
Don't embed timestamps!
Posted Nov 3, 2009 9:46 UTC (Tue) by nix (subscriber, #2304)In reply to: Don't embed timestamps! by edmundo
Parent article: Wheeler: Fully Countering Trusting Trust through Diverse Double-Compiling
Posted Nov 3, 2009 10:52 UTC (Tue)
by jwakely (subscriber, #60262)
[Link] (6 responses)
Some uses of C++ templates require names with external linkage, so anonymous namespaces can be used to get similar effects to static linkage, without actually having static linkage.
Posted Nov 3, 2009 11:17 UTC (Tue)
by nix (subscriber, #2304)
[Link] (5 responses)
(I've been wondering what uses could possibly require external linkage for some time. It's not as if you can put things in anonymous namespaces in two different translation units and have them refer to each other, and references via function pointers don't care if you're using static linkage or not. So why is this done?)
Posted Nov 3, 2009 11:47 UTC (Tue)
by quotemstr (subscriber, #45331)
[Link] (2 responses)
Posted Nov 3, 2009 14:58 UTC (Tue)
by nix (subscriber, #2304)
[Link] (1 responses)
Posted Nov 4, 2009 17:21 UTC (Wed)
by jwakely (subscriber, #60262)
[Link]
Apparently the restriction on calling static functions from templates was put in place to allow template instantiation to be done at link-time, using only the information available to the linker (which might not include static functions.)
At the Santa Cruz meeting of the C++ committee this issue was just closed, with a change allowing static functions to be found (noone does instantiation at link time.)
I'll stop derailing this article with off-topic comments about C++ trivia now.
Posted Nov 3, 2009 16:58 UTC (Tue)
by jwakely (subscriber, #60262)
[Link] (1 responses)
That option already exists, see -frandom-seed, but shouldn't be needed to bootstrap gcc. (It is useful for users who want to compare binaries though.)
Instead, the anon namespace will still cause a random string to be part of the mangled name, but that name will no longer be used in the context that was causing bootstrap comparison failures.
Also, N.B. since GCC 4.2 "Members of the anonymous namespace are now local to a particular translation unit, along with any other declarations which use them, though they are still treated as having external linkage for language semantics." (from http://gcc.gnu.org/gcc-4.2/changes.html)
Posted Nov 3, 2009 20:00 UTC (Tue)
by nix (subscriber, #2304)
[Link]
Don't embed timestamps!
Don't embed timestamps!
Don't embed timestamps!
Don't embed timestamps!
C++ templates and static functions
Don't embed timestamps!
That means you get most of the benefits of static linkage, without actually having static linkage as far as the language is concerned.
Don't embed timestamps!
assumed it meant random names were no longer used. Foolish me didn't
bother to actually check the source code though.
