Re: [PATCH] x86: Align jump targets to 1 byte boundaries

From: Daniel Borkmann
Date: Fri Apr 10 2015 - 15:23:47 EST


On 04/10/2015 02:50 PM, Denys Vlasenko wrote:
...
New-ish versions of gcc allow people to specify optimization
options per function:

https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes

optimize
The optimize attribute is used to specify that a function is to be compiled
with different optimization options than specified on the command line.
Arguments can either be numbers or strings. Numbers are assumed to be an
optimization level. Strings that begin with O are assumed to be an
optimization option, while other options are assumed to be used with
a -f prefix.

How about not aligning code by default, and using

#define hot_func __attribute__((optimize("O2","align-functions=16","align-jumps=16")))

I stumbled over that some time ago in a different context. Apparently,
that's being considered broken by gcc folks [1]. ;)

[1] http://gcc.gnu.org/ml/gcc/2012-07/msg00211.html
--
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/