diff options
author | Colin Cross <ccross@android.com> | 2017-11-02 23:09:41 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-11-03 22:28:03 -0700 |
commit | 324a457440feee29a5e9c08bb1f311112809185c (patch) | |
tree | 038e2221a6beb520f4deb7085f89cbeb460f50c6 /cc | |
parent | 0e37bc78d4d08cbf0843b043208867229802b827 (diff) | |
download | build_soong-324a457440feee29a5e9c08bb1f311112809185c.tar.gz build_soong-324a457440feee29a5e9c08bb1f311112809185c.tar.bz2 build_soong-324a457440feee29a5e9c08bb1f311112809185c.zip |
Consolidate ldflags that are used on all devices
Move ldflags that are specified for all devices into
deviceGlobalLdflags, and add them to linker.go:
-Wl,-z,noexecstack
-Wl,-z,relro
-Wl,-z,now
-Wl,--build-id=md5
-Wl,--warn-shared-textrel
-Wl,--fatal-warnings
-Wl,--no-undefined-version
Bug: 68855788
Test: m checkbuild
Change-Id: I82561b4189287d7638006f9e298c5151f9930c5e
Diffstat (limited to 'cc')
-rw-r--r-- | cc/config/arm64_device.go | 7 | ||||
-rw-r--r-- | cc/config/arm_device.go | 7 | ||||
-rw-r--r-- | cc/config/global.go | 14 | ||||
-rw-r--r-- | cc/config/mips64_device.go | 7 | ||||
-rw-r--r-- | cc/config/mips_device.go | 7 | ||||
-rw-r--r-- | cc/config/x86_64_device.go | 7 | ||||
-rw-r--r-- | cc/config/x86_device.go | 7 | ||||
-rw-r--r-- | cc/linker.go | 6 | ||||
-rw-r--r-- | cc/makevars.go | 2 |
9 files changed, 22 insertions, 42 deletions
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index bdcbd05e..13e9a08b 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -38,18 +38,11 @@ var ( } arm64Ldflags = []string{ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--build-id=md5", - "-Wl,--warn-shared-textrel", - "-Wl,--fatal-warnings", "-Wl,-m,aarch64_elf64_le_vec", "-Wl,--hash-style=gnu", "-Wl,--fix-cortex-a53-843419", "-fuse-ld=gold", "-Wl,--icf=safe", - "-Wl,--no-undefined-version", } arm64Cppflags = []string{ diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go index 3411e074..80ec3240 100644 --- a/cc/config/arm_device.go +++ b/cc/config/arm_device.go @@ -45,15 +45,8 @@ var ( } armLdflags = []string{ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--build-id=md5", - "-Wl,--warn-shared-textrel", - "-Wl,--fatal-warnings", "-Wl,--icf=safe", "-Wl,--hash-style=gnu", - "-Wl,--no-undefined-version", "-Wl,-m,armelf", } diff --git a/cc/config/global.go b/cc/config/global.go index 4a2f6065..7362f2e5 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -71,8 +71,20 @@ var ( "-Werror=format-security", } + deviceGlobalLdflags = []string{ + "-Wl,-z,noexecstack", + "-Wl,-z,relro", + "-Wl,-z,now", + "-Wl,--build-id=md5", + "-Wl,--warn-shared-textrel", + "-Wl,--fatal-warnings", + "-Wl,--no-undefined-version", + } + hostGlobalCflags = []string{} + hostGlobalLdflags = []string{} + commonGlobalCppflags = []string{ "-Wsign-promo", } @@ -110,7 +122,9 @@ func init() { pctx.StaticVariable("CommonGlobalCflags", strings.Join(commonGlobalCflags, " ")) pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " ")) pctx.StaticVariable("DeviceGlobalCflags", strings.Join(deviceGlobalCflags, " ")) + pctx.StaticVariable("DeviceGlobalLdflags", strings.Join(deviceGlobalLdflags, " ")) pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " ")) + pctx.StaticVariable("HostGlobalLdflags", strings.Join(hostGlobalLdflags, " ")) pctx.StaticVariable("NoOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " ")) pctx.StaticVariable("CommonGlobalCppflags", strings.Join(commonGlobalCppflags, " ")) diff --git a/cc/config/mips64_device.go b/cc/config/mips64_device.go index 9dd11652..487b11a1 100644 --- a/cc/config/mips64_device.go +++ b/cc/config/mips64_device.go @@ -45,14 +45,7 @@ var ( } mips64Ldflags = []string{ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--build-id=md5", - "-Wl,--warn-shared-textrel", - "-Wl,--fatal-warnings", "-Wl,--allow-shlib-undefined", - "-Wl,--no-undefined-version", } mips64ArchVariantCflags = map[string][]string{ diff --git a/cc/config/mips_device.go b/cc/config/mips_device.go index 840702ac..f178b978 100644 --- a/cc/config/mips_device.go +++ b/cc/config/mips_device.go @@ -43,14 +43,7 @@ var ( } mipsLdflags = []string{ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--build-id=md5", - "-Wl,--warn-shared-textrel", - "-Wl,--fatal-warnings", "-Wl,--allow-shlib-undefined", - "-Wl,--no-undefined-version", } mipsToolchainLdflags = []string{ diff --git a/cc/config/x86_64_device.go b/cc/config/x86_64_device.go index 1941eb8d..1eab9dd6 100644 --- a/cc/config/x86_64_device.go +++ b/cc/config/x86_64_device.go @@ -34,14 +34,7 @@ var ( x86_64Cppflags = []string{} x86_64Ldflags = []string{ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--build-id=md5", - "-Wl,--warn-shared-textrel", - "-Wl,--fatal-warnings", "-Wl,--hash-style=gnu", - "-Wl,--no-undefined-version", } x86_64ArchVariantCflags = map[string][]string{ diff --git a/cc/config/x86_device.go b/cc/config/x86_device.go index a95305bc..8aea64d9 100644 --- a/cc/config/x86_device.go +++ b/cc/config/x86_device.go @@ -40,14 +40,7 @@ var ( x86Cppflags = []string{} x86Ldflags = []string{ - "-Wl,-z,noexecstack", - "-Wl,-z,relro", - "-Wl,-z,now", - "-Wl,--build-id=md5", - "-Wl,--warn-shared-textrel", - "-Wl,--fatal-warnings", "-Wl,--hash-style=gnu", - "-Wl,--no-undefined-version", } x86ArchVariantCflags = map[string][]string{ diff --git a/cc/linker.go b/cc/linker.go index 1cf3f613..d5727aa0 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -196,7 +196,13 @@ func (linker *baseLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps { func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { toolchain := ctx.toolchain() + hod := "Host" + if ctx.Os().Class == android.Device { + hod = "Device" + } + if !ctx.noDefaultCompilerFlags() { + flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod)) if Bool(linker.Properties.Allow_undefined_symbols) { if ctx.Darwin() { // darwin defaults to treating undefined symbols as errors diff --git a/cc/makevars.go b/cc/makevars.go index 295b4ac0..f84ae24e 100644 --- a/cc/makevars.go +++ b/cc/makevars.go @@ -174,6 +174,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string, toolchain.Cppflags(), }, " ")) ctx.Strict(makePrefix+"GLOBAL_LDFLAGS", strings.Join([]string{ + fmt.Sprintf("${config.%sGlobalLdflags}", hod), toolchain.Ldflags(), toolchain.ToolchainLdflags(), productExtraLdflags, @@ -219,6 +220,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string, toolchain.ClangCppflags(), }, " ")) ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{ + fmt.Sprintf("${config.%sGlobalLdflags}", hod), toolchain.ClangLdflags(), toolchain.ToolchainClangLdflags(), productExtraLdflags, |