clang-randstruct / llvm-project

Randomize the order of fields in a structure layout as a compile-time hardening feature
3 stars 1 forks source link

Skip unions #33

Closed connorkuehl closed 5 years ago

connorkuehl commented 5 years ago

Forgot to bring this over when we originally ported from the plugin. Closes #23

With this PR, the Clang compiler will not randomize unions and it will emit a warning when someone decorates their union with the randomize_layout attribute.

/home/kuehlcon/llvm-project/build/bin/clang -g -Wno-format poc.c -o rand
poc.c:33:7: warning: union declared with 'randomize_layout' attribute [-Wrandomize-layout]
union u {
    ^

clang-test:

[100%] Running the Clang regression tests
llvm-lit: /home/kuehlcon/llvm-project/llvm/utils/lit/lit/llvm/config.py:337: note: using clang: /home/kuehlcon/llvm-project/build/bin/clang
Testing Time: 402.89s                                                                       
  Expected Passes    : 14089                                            
  Expected Failures  : 19                               
  Unsupported Tests  : 62
  [100%] Built target check-clang                     
  [100%] Built target clang-test