Merge "Add informational message to help with updation of VNDK abi references."
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index 91f47e0..b2a8914 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -111,6 +111,7 @@
"LOCAL_CONLYFLAGS": "conlyflags",
"LOCAL_CPPFLAGS": "cppflags",
"LOCAL_REQUIRED_MODULES": "required",
+ "LOCAL_OVERRIDES_MODULES": "overrides",
"LOCAL_LDLIBS": "host_ldlibs",
"LOCAL_CLANG_CFLAGS": "clang_cflags",
"LOCAL_YACCFLAGS": "yaccflags",
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 56ff713..9bcb783 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -228,6 +228,10 @@
if binary.coverageOutputFile.Valid() {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
}
+
+ if len(binary.Properties.Overrides) > 0 {
+ fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES := "+strings.Join(binary.Properties.Overrides, " "))
+ }
})
}
diff --git a/cc/binary.go b/cc/binary.go
index 7794eab..c3e899a 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -45,6 +45,13 @@
No_pie *bool `android:"arch_variant"`
DynamicLinker string `blueprint:"mutated"`
+
+ // Names of modules to be overridden. Listed modules can only be other binaries
+ // (in Make or Soong).
+ // This does not completely prevent installation of the overridden binaries, but if both
+ // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
+ // from PRODUCT_PACKAGES.
+ Overrides []string
}
func init() {
diff --git a/cc/cc.go b/cc/cc.go
index e91711e..c8d5251 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -52,7 +52,7 @@
ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
- ctx.TopDown("minimal_runtime_deps", minimalRuntimeDepsMutator())
+ ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator())
ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
ctx.TopDown("vndk_deps", sabiDepsMutator)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index c9fcafc..859d876 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -115,6 +115,7 @@
SanitizerEnabled bool `blueprint:"mutated"`
SanitizeDep bool `blueprint:"mutated"`
MinimalRuntimeDep bool `blueprint:"mutated"`
+ UbsanRuntimeDep bool `blueprint:"mutated"`
InSanitizerDir bool `blueprint:"mutated"`
}
@@ -199,8 +200,9 @@
}
}
+ // Global integer_overflow builds do not support static libraries.
if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil {
- if !ctx.Config().IntegerOverflowDisabledForPath(ctx.ModuleDir()) {
+ if !ctx.Config().IntegerOverflowDisabledForPath(ctx.ModuleDir()) && !ctx.static() {
s.Integer_overflow = boolPtr(true)
}
}
@@ -209,8 +211,9 @@
ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0])
}
+ // Global integer_overflow builds do not support static library diagnostics.
if found, globalSanitizersDiag = removeFromList("integer_overflow", globalSanitizersDiag); found &&
- s.Diag.Integer_overflow == nil && Bool(s.Integer_overflow) {
+ s.Diag.Integer_overflow == nil && Bool(s.Integer_overflow) && !ctx.static() {
s.Diag.Integer_overflow = boolPtr(true)
}
@@ -250,10 +253,14 @@
s.Diag.Cfi = nil
}
- // Also disable CFI for host builds.
+ // Disable sanitizers that depend on the UBSan runtime for host builds.
if ctx.Host() {
s.Cfi = nil
s.Diag.Cfi = nil
+ s.Misc_undefined = nil
+ s.Undefined = nil
+ s.All_undefined = nil
+ s.Integer_overflow = nil
}
if ctx.staticBinary() {
@@ -305,7 +312,7 @@
if ctx.Device() && sanitize.Properties.MinimalRuntimeDep {
flags.LdFlags = append(flags.LdFlags, minimalRuntimePath)
}
- if !sanitize.Properties.SanitizerEnabled {
+ if !sanitize.Properties.SanitizerEnabled && !sanitize.Properties.UbsanRuntimeDep {
return flags
}
@@ -416,14 +423,12 @@
}
if Bool(sanitize.Properties.Sanitize.Integer_overflow) {
- if !ctx.static() {
- sanitizers = append(sanitizers, "unsigned-integer-overflow")
- sanitizers = append(sanitizers, "signed-integer-overflow")
- flags.CFlags = append(flags.CFlags, intOverflowCflags...)
- if Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) {
- diagSanitizers = append(diagSanitizers, "unsigned-integer-overflow")
- diagSanitizers = append(diagSanitizers, "signed-integer-overflow")
- }
+ sanitizers = append(sanitizers, "unsigned-integer-overflow")
+ sanitizers = append(sanitizers, "signed-integer-overflow")
+ flags.CFlags = append(flags.CFlags, intOverflowCflags...)
+ if Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) {
+ diagSanitizers = append(diagSanitizers, "unsigned-integer-overflow")
+ diagSanitizers = append(diagSanitizers, "signed-integer-overflow")
}
}
@@ -463,15 +468,20 @@
runtimeLibrary = config.AddressSanitizerRuntimeLibrary(ctx.toolchain())
} else if Bool(sanitize.Properties.Sanitize.Thread) {
runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(ctx.toolchain())
- } else if len(diagSanitizers) > 0 {
+ } else if len(diagSanitizers) > 0 || sanitize.Properties.UbsanRuntimeDep {
runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(ctx.toolchain())
}
if runtimeLibrary != "" {
+ runtimeLibraryPath := "${config.ClangAsanLibDir}/" + runtimeLibrary
+ if !ctx.static() {
+ runtimeLibraryPath = runtimeLibraryPath + ctx.toolchain().ShlibSuffix()
+ } else {
+ runtimeLibraryPath = runtimeLibraryPath + ".a"
+ }
+
// ASan runtime library must be the first in the link order.
- flags.libFlags = append([]string{
- "${config.ClangAsanLibDir}/" + runtimeLibrary + ctx.toolchain().ShlibSuffix(),
- }, flags.libFlags...)
+ flags.libFlags = append([]string{runtimeLibraryPath}, flags.libFlags...)
sanitize.runtimeLibrary = runtimeLibrary
// When linking against VNDK, use the vendor variant of the runtime lib
@@ -594,16 +604,21 @@
}
// Propagate the ubsan minimal runtime dependency when there are integer overflow sanitized static dependencies.
-func minimalRuntimeDepsMutator() func(android.TopDownMutatorContext) {
+func sanitizerRuntimeDepsMutator() func(android.TopDownMutatorContext) {
return func(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize != nil {
mctx.VisitDepsDepthFirst(func(module android.Module) {
if d, ok := module.(*Module); ok && d.static() && d.sanitize != nil {
- // If a static dependency will be built with the minimal runtime,
- // make sure we include the ubsan minimal runtime.
if enableMinimalRuntime(d.sanitize) {
+ // If a static dependency is built with the minimal runtime,
+ // make sure we include the ubsan minimal runtime.
c.sanitize.Properties.MinimalRuntimeDep = true
+ } else if Bool(d.sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
+ len(d.sanitize.Properties.Sanitize.Diag.Misc_undefined) > 0 {
+ // If a static dependency runs with full ubsan diagnostics,
+ // make sure we include the ubsan runtime.
+ c.sanitize.Properties.UbsanRuntimeDep = true
}
}
})
diff --git a/scripts/strip.sh b/scripts/strip.sh
index ff8aaa0..318c7ad 100755
--- a/scripts/strip.sh
+++ b/scripts/strip.sh
@@ -56,6 +56,7 @@
"${CROSS_COMPILE}nm" -D "${infile}" --format=posix --defined-only | awk '{ print $$1 }' | sort >"${outfile}.dynsyms"
"${CROSS_COMPILE}nm" "${infile}" --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > "${outfile}.funcsyms"
comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols"
+ echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty.
"${CROSS_COMPILE}objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo"
"${CROSS_COMPILE}objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo"
"${CROSS_COMPILE}objcopy" --rename-section saved_debug_frame=.debug_frame "${outfile}.mini_debuginfo"