Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize layout docs #27

Merged
merged 19 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5d6b7c1
Added the 'no_randomize_layout' attr to clang
Nixoncole Feb 12, 2019
53fec8d
Merge branch 'develop' of https://github.com/connorkuehl/llvm-project…
Nixoncole Feb 18, 2019
456bd5a
WIP, first attempt at emitting compiler warning
Nixoncole Feb 19, 2019
b1f11a3
Added declaration of Diagnostic(), receiving errors.
Nixoncole Feb 19, 2019
dee16c7
builds, but cannot compile. Cant find stdio.h
Nixoncole Feb 20, 2019
063f1b1
Added the 'no_randomize_layout' attr to clang
Nixoncole Feb 12, 2019
938b5cf
WIP, first attempt at emitting compiler warning
Nixoncole Feb 19, 2019
e1af06f
Added declaration of Diagnostic(), receiving errors.
Nixoncole Feb 19, 2019
a4a855d
builds, but cannot compile. Cant find stdio.h
Nixoncole Feb 20, 2019
9d3845e
Clean up PR
Feb 23, 2019
287458e
Merge branch 'no_ranomize_layout_attr' of https://github.com/clang-ra…
Feb 23, 2019
f94de06
Add DiagGroup to NoRandomizeLayout attribute
connorkuehl Feb 23, 2019
fadd247
Add NoRandomizeLayout to supported attributes list
connorkuehl Feb 23, 2019
ae1bf92
Add space after semicolon in warning message
connorkuehl Feb 23, 2019
7272914
First draft for attribute documentation
Nixoncole Feb 24, 2019
09a54e9
Edit ClangRandstruct entry in AttrDocs.td
Feb 24, 2019
9949798
Docs for the single attribute, 'randomize_layout'.
Nixoncole Feb 26, 2019
f06d4cc
touched up other docs ad ran 'clang-format'
Nixoncole Feb 26, 2019
ca2372f
Removed 'header' that is only for when you include docs for multiple …
Nixoncole Feb 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -3206,5 +3206,5 @@ def RandomizeLayout : InheritableAttr {
let Spellings = [GCC<"randomize_layout">, Declspec<"randomize_layout">,
Keyword<"randomize_layout">];
let Subjects = SubjectList<[Record]>;
let Documentation = [Undocumented];
let Documentation = [ClangRandstructDocs];
}
20 changes: 19 additions & 1 deletion clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -4094,4 +4094,22 @@ Likewise, when applied to a strong local variable, that variable becomes
``const`` and is considered externally-retained.

When compiled without ``-fobjc-arc``, this attribute is ignored.
}]; }
}];
}

def ClangRandstructDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
The attribute ``randomize_layout`` can be applied to the declaration of
a record. ``randomize_layout`` instructs the compiler to randomize the memory layout
of the member variables of the record.
.. code-block:: c

// Indicates that this struct should be randomized by Randstruct implementation.
struct s {
char *a;
char *b;
char *c;
}__attribute__((randomize_layout));
}];
}
7 changes: 4 additions & 3 deletions clang/lib/AST/RecordLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2986,11 +2986,12 @@ ASTContext::getASTRecordLayout(const RecordDecl *D) const {
if (Entry) return *Entry;

const ASTRecordLayout *NewEntry = nullptr;

bool ShouldBeRandomized = D->getAttr<RandomizeLayoutAttr>() != nullptr;

if (ShouldBeRandomized) {
Randstruct randstruct;
randstruct.reorganizeFields(*this, D);
Randstruct randstruct;
randstruct.reorganizeFields(*this,D);
}

if (isMsLayout(*this)) {
Expand Down