This has to be done differently on Windows and Unix systems.
I ran test suite on Windows, Ubuntu and FreeBSD.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
ELF/OutputSections.cpp | ||
---|---|---|
1687 ↗ | (On Diff #67505) | I'd add code to generate a RNG to LLVM rather than to LLD because it seems generic and should be useful in other places. |
Our project does, but we need only Windows version. We can keep this patch proprietary of course, if it's not desired for some reason
ELF/OutputSections.cpp | ||
---|---|---|
1687 ↗ | (On Diff #67505) | You mean creating random GUID, don't you? |
I asked the question because we do not usually create features just because other linkers have them, so I wanted to confirm that you actually needed it. So there's no problem to add this feature to LLD.
ELF/OutputSections.cpp | ||
---|---|---|
1687 ↗ | (On Diff #67505) | GUID is actually jus random 16 bytes, so maybe adding a function to create a GUID is too narrowly scoped. How about defining a function that returns truely random bytes of any length? Like std::vector<uint8_t> getRandomBytes(size_t Length); |
ELF/OutputSections.cpp | ||
---|---|---|
1687 ↗ | (On Diff #67505) | There is a special routine on Windows which should be used to create GUID (UuidCreate). I'm afraid getRandomBytes is too generic for this particular case. |
I have a concern about using current time as a random source. Even with a nano second resolution timer (and I think timers are in reality not that accurate), there's a small chance for two machines to create two different executables at the same time. If that happens, the two files get the same build-id. That's a small probability but much larger than a collision in 2^128 space.
How about using timer value + Bufs and calculate md5 of the combined value (a sort of hmac-md5)?
Maybe you can, but it's still less entropy than real random values, so why don't you just use a true random value such as /dev/random?