Tobias Bosch | ef8f969 | 2019-06-10 15:50:33 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | type config struct { |
| 4 | // Flags to add to gcc and clang. |
| 5 | commonFlags []string |
| 6 | // Flags to add to gcc only. |
| 7 | gccFlags []string |
| 8 | // Flags to add to clang only. |
| 9 | clangFlags []string |
| 10 | // Toolchain root path relative to the wrapper binary. |
| 11 | rootRelPath string |
| 12 | // Path of the old wrapper using the toolchain root. |
| 13 | oldWrapperPath string |
| 14 | overrideOldWrapperConfig bool |
| 15 | } |
| 16 | |
| 17 | // Full hardening. |
| 18 | // Temporarily disable function splitting because of chromium:434751. |
| 19 | var crosHardenedConfig = config{ |
| 20 | rootRelPath: "../../../../..", |
| 21 | oldWrapperPath: "./sysroot_wrapper.hardened.old", |
| 22 | commonFlags: []string{ |
| 23 | "-fPIE", |
| 24 | "-D_FORTIFY_SOURCE=2", |
| 25 | "-fstack-protector-strong", |
| 26 | "-pie", |
| 27 | "-fno-omit-frame-pointer", |
| 28 | }, |
| 29 | gccFlags: []string{ |
| 30 | "-Wno-unused-local-typedefs", |
| 31 | "-Wno-maybe-uninitialized", |
| 32 | "-fno-reorder-blocks-and-partition", |
| 33 | }, |
| 34 | // Temporarily disable tautological-*-compare chromium:778316. |
| 35 | // Temporarily add no-unknown-warning-option to deal with old clang versions. |
| 36 | // Temporarily disable Wsection since kernel gets a bunch of these. chromium:778867 |
| 37 | // Disable "-faddrsig" since it produces object files that strip doesn't understand, chromium:915742. |
| 38 | clangFlags: []string{ |
| 39 | "-Wno-tautological-unsigned-enum-zero-compare", |
| 40 | "-Qunused-arguments", |
| 41 | "-grecord-gcc-switches", |
| 42 | "-Wno-section", |
| 43 | "-Wno-unknown-warning-option", |
| 44 | "-fno-addrsig", |
| 45 | "-Wno-tautological-constant-compare", |
| 46 | }, |
| 47 | } |
| 48 | |
| 49 | // Flags to be added to non-hardened toolchain. |
| 50 | var crosNonHardenedConfig = config{ |
| 51 | rootRelPath: "../../../../..", |
| 52 | oldWrapperPath: "./sysroot_wrapper.old", |
| 53 | commonFlags: []string{}, |
| 54 | gccFlags: []string{ |
| 55 | "-Wno-unused-local-typedefs", |
| 56 | "-Wno-maybe-uninitialized", |
| 57 | "-Wtrampolines", |
| 58 | "-Wno-deprecated-declarations", |
| 59 | }, |
| 60 | // Temporarily disable tautological-*-compare chromium:778316. |
| 61 | // Temporarily add no-unknown-warning-option to deal with old clang versions. |
| 62 | // Temporarily disable Wsection since kernel gets a bunch of these. chromium:778867 |
| 63 | clangFlags: []string{ |
| 64 | "-Wno-unknown-warning-option", |
| 65 | "-Qunused-arguments", |
| 66 | "-Wno-section", |
| 67 | "-Wno-tautological-unsigned-enum-zero-compare", |
| 68 | "-Wno-tautological-constant-compare", |
| 69 | }, |
| 70 | } |