Re: Patch 4/6 randomize the stack pointer

From: Roland Dreier
Date: Thu Jan 27 2005 - 19:31:54 EST


Julien> Not very important but ((get_random_int() % 4096) << 4)
Julien> could be optimized into get_random_int() & 0xFFF0.

HPA> .. and gcc knows that.

HPA> 8: 25 ff 0f 00 00 and $0xfff,%eax
HPA> d: 83 c4 0c add $0xc,%esp
HPA> 10: c1 e0 04 shl $0x4,%eax

Actually gcc isn't quite that smart (since it obviously can't
understand the semantics of get_random int()). The original point was
that the "shl $0x4" can be avoided by directly &'ing with 0xfff0, not
that "% 4096" can be strength reduced to "& 0xfff".

- R.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/