• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2019 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package main
6
7func processStackProtectorFlags(builder *commandBuilder) {
8	fstackMap := map[string]bool{"-D__KERNEL__": true, "-fno-stack-protector": true, "-nodefaultlibs": true,
9		"-nostdlib": true}
10
11	fstack := false
12	if builder.target.abi != "eabi" {
13		for _, arg := range builder.args {
14			if arg.fromUser && fstackMap[arg.value] {
15				fstack = true
16				break
17			}
18		}
19	}
20	if fstack {
21		builder.addPreUserArgs("-fno-stack-protector")
22		builder.transformArgs(func(arg builderArg) string {
23			if !arg.fromUser && arg.value == "-fstack-protector-strong" {
24				return ""
25			}
26			return arg.value
27		})
28	}
29}
30