Merge "Move file_contexts file for APEXes to under /system/sepolicy"
diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go
index 83c38db..f7d08cc 100644
--- a/android/prebuilt_etc.go
+++ b/android/prebuilt_etc.go
@@ -40,6 +40,10 @@
// optional name for the installed file. If unspecified, name of the module is used as the file name
Filename *string `android:"arch_variant"`
+ // when set to true, and filename property is not set, the name for the installed file
+ // is the same as the file name of the source file.
+ Filename_from_src *bool `android:"arch_variant"`
+
// Make this module available when building for recovery.
Recovery_available *bool
@@ -106,8 +110,16 @@
func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
p.sourceFilePath = ctx.ExpandSource(String(p.properties.Src), "src")
filename := String(p.properties.Filename)
+ filename_from_src := Bool(p.properties.Filename_from_src)
if filename == "" {
- filename = ctx.ModuleName()
+ if filename_from_src {
+ filename = p.sourceFilePath.Base()
+ } else {
+ filename = ctx.ModuleName()
+ }
+ } else if filename_from_src {
+ ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
+ return
}
p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath
p.installDirPath = PathForModuleInstall(ctx, "etc", String(p.properties.Sub_dir))
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index 1ecdf79..27736ba 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -106,3 +106,27 @@
t.Errorf("expected foo.installed.conf, got %q", p.outputFilePath.Base())
}
}
+
+func TestPrebuiltEtcGlob(t *testing.T) {
+ ctx := testPrebuiltEtc(t, `
+ prebuilt_etc {
+ name: "my_foo",
+ src: "foo.*",
+ }
+ prebuilt_etc {
+ name: "my_bar",
+ src: "bar.*",
+ filename_from_src: true,
+ }
+ `)
+
+ p := ctx.ModuleForTests("my_foo", "android_common_core").Module().(*PrebuiltEtc)
+ if p.outputFilePath.Base() != "my_foo" {
+ t.Errorf("expected my_foo, got %q", p.outputFilePath.Base())
+ }
+
+ p = ctx.ModuleForTests("my_bar", "android_common_core").Module().(*PrebuiltEtc)
+ if p.outputFilePath.Base() != "bar.conf" {
+ t.Errorf("expected bar.conf, got %q", p.outputFilePath.Base())
+ }
+}
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index 75f5962..d759125 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -66,6 +66,11 @@
"-mfloat-abi=softfp",
"-mfpu=neon-fp-armv8",
},
+ "armv8-2a": []string{
+ "-march=armv8.2-a",
+ "-mfloat-abi=softfp",
+ "-mfpu=neon-fp-armv8",
+ },
}
armClangCpuVariantCflags = map[string][]string{
@@ -161,6 +166,7 @@
"armv7-a",
"armv7-a-neon",
"armv8-a",
+ "armv8-2a",
"cortex-a7",
"cortex-a8",
"cortex-a9",
@@ -180,6 +186,7 @@
android.RegisterArchVariantFeatures(android.Arm, "armv7-a-neon", "neon")
android.RegisterArchVariantFeatures(android.Arm, "armv8-a", "neon")
+ android.RegisterArchVariantFeatures(android.Arm, "armv8-2a", "neon")
pctx.StaticVariable("armGccVersion", armGccVersion)
@@ -208,6 +215,8 @@
strings.Join(armClangArchVariantCflags["armv7-a-neon"], " "))
pctx.StaticVariable("ArmClangArmv8ACflags",
strings.Join(armClangArchVariantCflags["armv8-a"], " "))
+ pctx.StaticVariable("ArmClangArmv82ACflags",
+ strings.Join(armClangArchVariantCflags["armv8-2a"], " "))
// Clang cpu variant cflags
pctx.StaticVariable("ArmClangGenericCflags",
@@ -233,6 +242,7 @@
"armv7-a": "${config.ArmClangArmv7ACflags}",
"armv7-a-neon": "${config.ArmClangArmv7ANeonCflags}",
"armv8-a": "${config.ArmClangArmv8ACflags}",
+ "armv8-2a": "${config.ArmClangArmv82ACflags}",
}
armClangCpuVariantCflagsVar = map[string]string{
@@ -347,8 +357,8 @@
}
case "armv7-a":
fixCortexA8 = "-Wl,--fix-cortex-a8"
- case "armv8-a":
- // Nothing extra for armv8-a
+ case "armv8-a", "armv8-2a":
+ // Nothing extra for armv8-a/armv8-2a
default:
panic(fmt.Sprintf("Unknown ARM architecture version: %q", arch.ArchVariant))
}
diff --git a/cc/config/global.go b/cc/config/global.go
index 7cb3679..e2377e3 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -122,8 +122,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r344140"
- ClangDefaultShortVersion = "8.0.3"
+ ClangDefaultVersion = "clang-r344140b"
+ ClangDefaultShortVersion = "8.0.4"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cmd/host_bionic_inject/Android.bp b/cmd/host_bionic_inject/Android.bp
index acce683..5994103 100644
--- a/cmd/host_bionic_inject/Android.bp
+++ b/cmd/host_bionic_inject/Android.bp
@@ -16,4 +16,5 @@
name: "host_bionic_inject",
deps: ["soong-symbol_inject"],
srcs: ["host_bionic_inject.go"],
+ testSrcs: ["host_bionic_inject_test.go"],
}
diff --git a/cmd/host_bionic_inject/host_bionic_inject.go b/cmd/host_bionic_inject/host_bionic_inject.go
index 0dabbba..f7163d7 100644
--- a/cmd/host_bionic_inject/host_bionic_inject.go
+++ b/cmd/host_bionic_inject/host_bionic_inject.go
@@ -136,33 +136,28 @@
continue
}
+ laddr := lprog.Vaddr + dlwrap_linker_offset.Value
+
found := false
- for j, prog := range file.Progs {
+ for _, prog := range file.Progs {
if prog.Type != elf.PT_LOAD {
continue
}
- if lprog.Vaddr+dlwrap_linker_offset.Value != prog.Vaddr {
+ if laddr < prog.Vaddr || laddr > prog.Vaddr+prog.Memsz {
continue
}
found = true
- if lprog.Memsz != prog.Memsz {
- return fmt.Errorf("Linker prog %d (0x%x) memsz (0x%x) does not match (0x%x)",
- i, lprog.Vaddr, lprog.Memsz, prog.Memsz)
- }
-
- // The linker shouldn't be using BSS, since only one
- // BSS section is supported per ELF file.
- if prog.Memsz != prog.Filesz {
- return fmt.Errorf("Embedded prog %d (0x%x) memsz (0x%x) does not match filesz (0x%x)",
- j, prog.Vaddr, prog.Memsz, prog.Filesz)
- }
-
if lprog.Flags != prog.Flags {
return fmt.Errorf("Linker prog %d (0x%x) flags (%s) do not match (%s)",
i, lprog.Vaddr, lprog.Flags, prog.Flags)
}
+
+ if laddr+lprog.Memsz > prog.Vaddr+prog.Filesz {
+ return fmt.Errorf("Linker prog %d (0x%x) not fully present (0x%x > 0x%x)",
+ i, lprog.Vaddr, laddr+lprog.Memsz, prog.Vaddr+prog.Filesz)
+ }
}
if !found {
return fmt.Errorf("Linker prog %d (0x%x) not found at offset 0x%x",
diff --git a/cmd/host_bionic_inject/host_bionic_inject_test.go b/cmd/host_bionic_inject/host_bionic_inject_test.go
new file mode 100644
index 0000000..b415b34
--- /dev/null
+++ b/cmd/host_bionic_inject/host_bionic_inject_test.go
@@ -0,0 +1,146 @@
+// Copyright 2018 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package main
+
+import (
+ "debug/elf"
+ "fmt"
+ "testing"
+)
+
+// prog is a shortcut to fill out a elf.Prog structure
+func prog(flags elf.ProgFlag, offset, addr, filesz, memsz uint64) *elf.Prog {
+ return &elf.Prog{
+ ProgHeader: elf.ProgHeader{
+ Type: elf.PT_LOAD,
+ Flags: flags,
+ Off: offset,
+ Vaddr: addr,
+ Paddr: addr,
+ Filesz: filesz,
+ Memsz: memsz,
+ },
+ }
+}
+
+// linkerGold returns an example elf.File from a linker binary that was linked
+// with gold.
+func linkerGold() *elf.File {
+ return &elf.File{
+ Progs: []*elf.Prog{
+ prog(elf.PF_R|elf.PF_X, 0, 0, 0xd0fac, 0xd0fac),
+ prog(elf.PF_R|elf.PF_W, 0xd1050, 0xd2050, 0x6890, 0xd88c),
+ },
+ }
+}
+
+// fileGold returns an example elf binary with a properly embedded linker. The
+// embedded linker was the one returned by linkerGold.
+func fileGold() *elf.File {
+ return &elf.File{
+ Progs: []*elf.Prog{
+ prog(elf.PF_R, 0, 0, 0x2e0, 0x2e0),
+ prog(elf.PF_R|elf.PF_X, 0x1000, 0x1000, 0xd0fac, 0xd0fac),
+ prog(elf.PF_R|elf.PF_W, 0xd2050, 0xd3050, 0xd88c, 0xd88c),
+ prog(elf.PF_R, 0xe0000, 0xe1000, 0x10e4, 0x10e4),
+ prog(elf.PF_R|elf.PF_X, 0xe2000, 0xe3000, 0x1360, 0x1360),
+ prog(elf.PF_R|elf.PF_W, 0xe4000, 0xe5000, 0x1358, 0x1358),
+ },
+ }
+}
+
+// linkerLld returns an example elf.File from a linker binary that was linked
+// with lld.
+func linkerLld() *elf.File {
+ return &elf.File{
+ Progs: []*elf.Prog{
+ prog(elf.PF_R, 0, 0, 0x3c944, 0x3c944),
+ prog(elf.PF_R|elf.PF_X, 0x3d000, 0x3d000, 0x946fa, 0x946fa),
+ prog(elf.PF_R|elf.PF_W, 0xd2000, 0xd2000, 0x7450, 0xf778),
+ },
+ }
+}
+
+// fileGold returns an example elf binary with a properly embedded linker. The
+// embedded linker was the one returned by linkerLld.
+func fileLld() *elf.File {
+ return &elf.File{
+ Progs: []*elf.Prog{
+ prog(elf.PF_R, 0, 0, 0x3d944, 0x3d944),
+ prog(elf.PF_R|elf.PF_X, 0x3e000, 0x3e000, 0x946fa, 0x946fa),
+ prog(elf.PF_R|elf.PF_W, 0xd3000, 0xd3000, 0xf778, 0xf778),
+ prog(elf.PF_R, 0xe3000, 0xe3000, 0x10e4, 0x10e4),
+ prog(elf.PF_R|elf.PF_X, 0xe5000, 0xe5000, 0x1360, 0x1360),
+ prog(elf.PF_R|elf.PF_W, 0xe7000, 0xe7000, 0x1358, 0x1358),
+ },
+ }
+}
+
+// linkerOffset returns the symbol representing the linker offset used by both
+// fileGold and fileLld
+func linkerOffset() []elf.Symbol {
+ return []elf.Symbol{
+ elf.Symbol{
+ Name: "__dlwrap_linker_offset",
+ Value: 0x1000,
+ },
+ }
+}
+
+func TestCheckLinker(t *testing.T) {
+ cases := []struct {
+ name string
+ err error
+ file func() *elf.File
+ linker func() *elf.File
+ }{
+ {
+ name: "good gold-linked linker",
+ file: fileGold,
+ linker: linkerGold,
+ },
+ {
+ name: "good lld-linked linker",
+ file: fileLld,
+ linker: linkerLld,
+ },
+ {
+ name: "truncated RO section",
+ err: fmt.Errorf("Linker prog 0 (0x0) not fully present (0x3d944 > 0x3d943)"),
+ file: func() *elf.File {
+ f := fileLld()
+ f.Progs[0].Filesz -= 1
+ f.Progs[0].Memsz -= 1
+ return f
+ },
+ linker: linkerLld,
+ },
+ }
+
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ err := checkLinker(tc.file(), tc.linker(), linkerOffset())
+ if tc.err == nil {
+ if err != nil {
+ t.Fatalf("No error expected, but got: %v", err)
+ }
+ } else if err == nil {
+ t.Fatalf("Returned no error, but wanted: %v", tc.err)
+ } else if err.Error() != tc.err.Error() {
+ t.Fatalf("Different error found:\nwant: %v\n got: %v", tc.err, err)
+ }
+ })
+ }
+}