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
This commit is contained in:
@@ -38,18 +38,11 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
arm64Ldflags = []string{
|
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,-m,aarch64_elf64_le_vec",
|
||||||
"-Wl,--hash-style=gnu",
|
"-Wl,--hash-style=gnu",
|
||||||
"-Wl,--fix-cortex-a53-843419",
|
"-Wl,--fix-cortex-a53-843419",
|
||||||
"-fuse-ld=gold",
|
"-fuse-ld=gold",
|
||||||
"-Wl,--icf=safe",
|
"-Wl,--icf=safe",
|
||||||
"-Wl,--no-undefined-version",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arm64Cppflags = []string{
|
arm64Cppflags = []string{
|
||||||
|
@@ -45,15 +45,8 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
armLdflags = []string{
|
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,--icf=safe",
|
||||||
"-Wl,--hash-style=gnu",
|
"-Wl,--hash-style=gnu",
|
||||||
"-Wl,--no-undefined-version",
|
|
||||||
"-Wl,-m,armelf",
|
"-Wl,-m,armelf",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,8 +71,20 @@ var (
|
|||||||
"-Werror=format-security",
|
"-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{}
|
hostGlobalCflags = []string{}
|
||||||
|
|
||||||
|
hostGlobalLdflags = []string{}
|
||||||
|
|
||||||
commonGlobalCppflags = []string{
|
commonGlobalCppflags = []string{
|
||||||
"-Wsign-promo",
|
"-Wsign-promo",
|
||||||
}
|
}
|
||||||
@@ -110,7 +122,9 @@ func init() {
|
|||||||
pctx.StaticVariable("CommonGlobalCflags", strings.Join(commonGlobalCflags, " "))
|
pctx.StaticVariable("CommonGlobalCflags", strings.Join(commonGlobalCflags, " "))
|
||||||
pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " "))
|
pctx.StaticVariable("CommonGlobalConlyflags", strings.Join(commonGlobalConlyflags, " "))
|
||||||
pctx.StaticVariable("DeviceGlobalCflags", strings.Join(deviceGlobalCflags, " "))
|
pctx.StaticVariable("DeviceGlobalCflags", strings.Join(deviceGlobalCflags, " "))
|
||||||
|
pctx.StaticVariable("DeviceGlobalLdflags", strings.Join(deviceGlobalLdflags, " "))
|
||||||
pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " "))
|
pctx.StaticVariable("HostGlobalCflags", strings.Join(hostGlobalCflags, " "))
|
||||||
|
pctx.StaticVariable("HostGlobalLdflags", strings.Join(hostGlobalLdflags, " "))
|
||||||
pctx.StaticVariable("NoOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " "))
|
pctx.StaticVariable("NoOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " "))
|
||||||
|
|
||||||
pctx.StaticVariable("CommonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
|
pctx.StaticVariable("CommonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
|
||||||
|
@@ -45,14 +45,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
mips64Ldflags = []string{
|
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,--allow-shlib-undefined",
|
||||||
"-Wl,--no-undefined-version",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mips64ArchVariantCflags = map[string][]string{
|
mips64ArchVariantCflags = map[string][]string{
|
||||||
|
@@ -43,14 +43,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
mipsLdflags = []string{
|
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,--allow-shlib-undefined",
|
||||||
"-Wl,--no-undefined-version",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mipsToolchainLdflags = []string{
|
mipsToolchainLdflags = []string{
|
||||||
|
@@ -34,14 +34,7 @@ var (
|
|||||||
x86_64Cppflags = []string{}
|
x86_64Cppflags = []string{}
|
||||||
|
|
||||||
x86_64Ldflags = []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,--hash-style=gnu",
|
||||||
"-Wl,--no-undefined-version",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x86_64ArchVariantCflags = map[string][]string{
|
x86_64ArchVariantCflags = map[string][]string{
|
||||||
|
@@ -40,14 +40,7 @@ var (
|
|||||||
x86Cppflags = []string{}
|
x86Cppflags = []string{}
|
||||||
|
|
||||||
x86Ldflags = []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,--hash-style=gnu",
|
||||||
"-Wl,--no-undefined-version",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x86ArchVariantCflags = map[string][]string{
|
x86ArchVariantCflags = map[string][]string{
|
||||||
|
@@ -196,7 +196,13 @@ func (linker *baseLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
|
|||||||
func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||||
toolchain := ctx.toolchain()
|
toolchain := ctx.toolchain()
|
||||||
|
|
||||||
|
hod := "Host"
|
||||||
|
if ctx.Os().Class == android.Device {
|
||||||
|
hod = "Device"
|
||||||
|
}
|
||||||
|
|
||||||
if !ctx.noDefaultCompilerFlags() {
|
if !ctx.noDefaultCompilerFlags() {
|
||||||
|
flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod))
|
||||||
if Bool(linker.Properties.Allow_undefined_symbols) {
|
if Bool(linker.Properties.Allow_undefined_symbols) {
|
||||||
if ctx.Darwin() {
|
if ctx.Darwin() {
|
||||||
// darwin defaults to treating undefined symbols as errors
|
// darwin defaults to treating undefined symbols as errors
|
||||||
|
@@ -174,6 +174,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
|||||||
toolchain.Cppflags(),
|
toolchain.Cppflags(),
|
||||||
}, " "))
|
}, " "))
|
||||||
ctx.Strict(makePrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
|
ctx.Strict(makePrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
|
||||||
|
fmt.Sprintf("${config.%sGlobalLdflags}", hod),
|
||||||
toolchain.Ldflags(),
|
toolchain.Ldflags(),
|
||||||
toolchain.ToolchainLdflags(),
|
toolchain.ToolchainLdflags(),
|
||||||
productExtraLdflags,
|
productExtraLdflags,
|
||||||
@@ -219,6 +220,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
|||||||
toolchain.ClangCppflags(),
|
toolchain.ClangCppflags(),
|
||||||
}, " "))
|
}, " "))
|
||||||
ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
|
ctx.Strict(clangPrefix+"GLOBAL_LDFLAGS", strings.Join([]string{
|
||||||
|
fmt.Sprintf("${config.%sGlobalLdflags}", hod),
|
||||||
toolchain.ClangLdflags(),
|
toolchain.ClangLdflags(),
|
||||||
toolchain.ToolchainClangLdflags(),
|
toolchain.ToolchainClangLdflags(),
|
||||||
productExtraLdflags,
|
productExtraLdflags,
|
||||||
|
Reference in New Issue
Block a user