Cleanup libart-compiler version script

Add Apache license header
Use globs instead of full symbol names to avoid issues with different
compiler versions
Link libelffile without whole-archive

Bug: 186902856
Change-Id: I22fe724a4868bd29cd2ff543846c1e0c819cb460
Test: m test-art-host-gtest-art_runtime_tests test-art-host-gtest-art_runtime_compiler_tests
Test: m dex2oat oatdump
diff --git a/compiler/Android.bp b/compiler/Android.bp
index 830a9f0..172af5e 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -176,6 +176,7 @@
     ],
 
     export_include_dirs: ["."],
+    // Not using .map.txt because this is an internal API
     version_script: "libart-compiler.map",
 }
 
@@ -229,7 +230,7 @@
         "libprofile",
         "libdexfile",
     ],
-    whole_static_libs: ["libelffile"],
+    static_libs: ["libelffile"],
     runtime_libs: [
         // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load
         // `libart-disassembler.so`.
@@ -297,7 +298,7 @@
         "libprofiled",
         "libdexfiled",
     ],
-    whole_static_libs: ["libelffiled"],
+    static_libs: ["libelffiled"],
     runtime_libs: [
         // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load
         // `libartd-disassembler.so`.
@@ -495,8 +496,9 @@
         "liblzma",
     ],
     static_libs: [
-        "libvixld",
         "libartd-compiler",
+        "libelffiled",
+        "libvixld",
     ],
 }
 
@@ -520,8 +522,9 @@
         // TODO(b/192070541): Consider linking `libart-simulator-container`
         // dynamically.
         "libart-simulator-container",
-        "libvixl",
         "libart-compiler",
+        "libelffile",
+        "libvixl",
     ],
     test_config: "art_standalone_compiler_tests.xml",
 }
@@ -558,6 +561,7 @@
     ],
     static_libs: [
         "libartd-compiler",
+        "libelffiled",
         "libvixld",
     ],
 }
diff --git a/compiler/libart-compiler.map b/compiler/libart-compiler.map
index 3522d04..7e7841f 100644
--- a/compiler/libart-compiler.map
+++ b/compiler/libart-compiler.map
@@ -1,47 +1,38 @@
+#
+# Copyright (C) 2022 The Android Open Source Project
+#
+# 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.
+#
 
 ART_COMPILER {
-global:
-    global:
-        extern "C++" {
-            # TODO(b/247611526): replace more long unmangled names with simple glob patterns
-            "art::CompiledCode::CodeDelta() const";
-            "art::CompiledCode::CodeDelta(art::InstructionSet)";
-            "art::CompiledCode::CodePointer(void const*, art::InstructionSet)";
-            "art::CompiledMethodStorage::CompiledMethodStorage(int)";
-            "art::CompiledMethodStorage::UniqueVMapTableEntries() const";
-            "art::CompiledMethodStorage::~CompiledMethodStorage()";
-            "art::Compiler::Create(art::CompilerOptions const&, art::CompiledMethodStorage*, art::Compiler::Kind)";
-            "art::CompilerOptions::CompilerOptions()";
-            "art::CompilerOptions::GetVerificationResults() const";
-            "art::CompilerOptions::IsImageClass(char const*) const";
-            "art::CompilerOptions::IsPreloadedClass(char const*) const";
-            "art::CompilerOptions::ShouldCompileWithClinitCheck(art::ArtMethod*) const";
-            "art::CompilerOptions::~CompilerOptions()";
-            "art::CreateTrampoline32(art::InstructionSet, art::EntryPointCallingConvention, art::ThreadOffset<(art::PointerSize)4>)";
-            "art::CreateTrampoline64(art::InstructionSet, art::EntryPointCallingConvention, art::ThreadOffset<(art::PointerSize)8>)";
-            "art::VerificationResults::AddRejectedClass(art::ClassReference)";
-            "art::VerificationResults::AddUncompilableMethod(art::MethodReference)";
-            "art::VerificationResults::IsClassRejected(art::ClassReference) const";
-            "art::VerificationResults::IsUncompilableMethod(art::MethodReference) const";
-            "art::VerificationResults::VerificationResults()";
-            "art::VerificationResults::~VerificationResults()";
-            "void art::debug::WriteDebugInfo<art::ElfTypes32>(art::ElfBuilder<art::ElfTypes32>*, art::debug::DebugInfo const&)";
-            "void art::debug::WriteDebugInfo<art::ElfTypes64>(art::ElfBuilder<art::ElfTypes64>*, art::debug::DebugInfo const&)";
-            art::CompiledCode::AlignCode*;
-            art::CompiledMethod::*;
-            art::CompiledMethodStorage::DumpMemoryUsage*;
-            art::CompiledMethodStorage::GetThunkCode*;
-            art::CompilerOptions::ParseDumpInitFailures*;
-            art::CompilerOptions::ParseRegisterAllocationStrategy*;
-            art::IntrinsicObjects*;
-            art::debug::MakeMiniDebugInfo*;
-            art::linker::operator*;
-            art::operator*;
-        };
+  global:
+    extern "C++" {
+      *art::debug::WriteDebugInfo*;
+      art::CompiledCode::*;
+      art::CompiledMethod::*;
+      art::CompiledMethodStorage::*;
+      art::Compiler::Create*;
+      art::CompilerOptions::*;
+      art::CreateTrampoline*;
+      art::IntrinsicObjects::*;
+      art::VerificationResults::*;
+      art::debug::MakeMiniDebugInfo*;
+      art::linker::operator*art::linker::LinkerPatch::Type*;
+      art::operator*art::Whence*;
+    };
 
-        jit_load;
+    jit_load;
 
-    local:
-        *;
+  local:
+    *;
 };
-
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 084239c..d28ad93 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -106,6 +106,9 @@
         "libartpalette",
         "libprofile",
     ],
+    static_libs: [
+        "libelffile",
+    ],
     apex_available: [
         "com.android.art",
         "com.android.art.debug",
@@ -157,6 +160,9 @@
         "libartpalette",
         "libprofiled",
     ],
+    static_libs: [
+        "libelffiled",
+    ],
     apex_available: [
         "com.android.art.debug",
     ],
@@ -565,6 +571,7 @@
         "libartd-compiler",
         "libartd-dex2oat",
         "libartd-dex2oat-gtest",
+        "libelffiled",
         "libvixld",
     ],
 }
@@ -587,6 +594,7 @@
         "libart-compiler",
         "libart-dex2oat",
         "libart-dex2oat-gtest",
+        "libelffile",
         "libvixl",
     ],
     test_config: "art_standalone_dex2oat_tests.xml",