3 ms·
Yes; gcc and clang could, in principle, support an extension like: __attribute__((rand)) enum e { FOO, BAR, ... }; which randomizes the values, as an extens
by kazinator 3y ago
Yes; gcc and clang could, in principle, support an extension like:
__attribute__((rand)) enum e { FOO, BAR, ... };
which randomizes the values, as an extension.
You only need this in specific places, like setuid programs.
Randomization can be bad because it wrecks build reproducibility; it would have to be tied to the GNU Build ID.
If such an enum is used in any interface between files, the randomization has to be the same in every translation unit.
Maybe the syntax could specify a seed: rand(42).
- jmprspret 3y agoA comment in the commit notes that randomisation does not necessary mitigate the issue. Which is why only a couple of the values are random, with the others being those values, XOR'd with 0xff*