@@ -4099,10 +4099,24 @@ When compiled without ``-fobjc-arc``, this attribute is ignored.
4099
4099
4100
4100
def ClangRandstructDocs : Documentation {
4101
4101
let Category = DocCatVariable;
4102
+ let Heading = "randomize_layout, no_randomize_layout";
4102
4103
let Content = [{
4103
- The attribute ``randomize_layout`` can be applied to the declaration of
4104
- a record. ``randomize_layout`` instructs the compiler to randomize the memory layout
4104
+ The attributes ``randomize_layout`` and ``no_randomize_layout`` can be applied
4105
+ to a record.
4106
+
4107
+ ``randomize_layout`` instructs the compiler to randomize the memory layout
4105
4108
of the member variables of the record.
4109
+
4110
+ Conversely, ``no_randomize_layout`` is used to indicate that if using the
4111
+ automatic strucuture selection feature of the Randstruct implementation, the
4112
+ compiler should not shuffle the members of the record.
4113
+
4114
+ In the event that a record is labeled with both attributes, the compiler will
4115
+ emit a warning indicating that these two cannot be used on the same record.
4116
+ The default behavior in this case is to not randomize the struct, as the
4117
+ attribute ``no_randomize_layout`` takes precedence over ``randomize_layout``.
4118
+ This is implementation defined behavior.
4119
+
4106
4120
.. code-block:: c
4107
4121
4108
4122
// Indicates that this struct should be randomized by Randstruct implementation.
@@ -4111,5 +4125,19 @@ of the member variables of the record.
4111
4125
char *b;
4112
4126
char *c;
4113
4127
}__attribute__((randomize_layout));
4128
+
4129
+ // Indicates that this struct should NOT be randomized by Randstruct implementation.
4130
+ struct s {
4131
+ char *a;
4132
+ char *b;
4133
+ char *c;
4134
+ }__attribute__((no_randomize_layout));
4135
+
4136
+ // Emits compiler warning. Struct is NOT randomized by Randstruct implementation.
4137
+ struct s {
4138
+ char *a;
4139
+ char *b;
4140
+ char *c;
4141
+ }__attribute__((randomize_layout)) __attribute__((no_randomize_layout));
4114
4142
}];
4115
4143
}
0 commit comments