diff options
| author | Mister Oyster <oysterized@gmail.com> | 2017-12-18 13:19:09 +0100 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-12-22 16:38:51 +0100 |
| commit | 8cd351f4dc8a475ee150dac1655998a6097ef518 (patch) | |
| tree | 0d2d0b89257aeb52393377c2965cde9aee7d8996 /patches | |
| parent | 887327a79385584b39f978285184edd2f3b6687a (diff) | |
force_shim: add force_shim back and fix compile errors
Diffstat (limited to 'patches')
5 files changed, 211 insertions, 2 deletions
diff --git a/patches/bionic/0001-linker-Allow-devices-to-force-shim-libs.patch b/patches/bionic/0001-linker-Allow-devices-to-force-shim-libs.patch new file mode 100644 index 0000000..bcab3a5 --- /dev/null +++ b/patches/bionic/0001-linker-Allow-devices-to-force-shim-libs.patch @@ -0,0 +1,147 @@ +From 9a8e59412302d554788422549d20c65c5ba2993f Mon Sep 17 00:00:00 2001 +From: "Christopher R. Palmer" <crpalmer@gmail.com> +Date: Thu, 16 Mar 2017 21:33:27 -0400 +Subject: [PATCH] linker: Allow devices to force shim libs + +There are certain contexts in which the environment is cleansed. +Two examples that I know of are gps processes and mali gles blobs. + +Generally, it is a better idea to use the environment variable because +then you can customize it on a per-service / script level and it is +easier to test and debug changes on the fly. + +However, to avoid having libdimytry hexedit these blobs, allow a +last resort device level forced list of shim libraries. + +[rashed] +Adapt for blueprint and add go module for dynamic C++ flag setting + +Change-Id: I2f6aff9325beb5aa2f748bf72e6c3c0535d5aac2 +--- + linker/Android.bp | 20 ++++++++++++++++++ + linker/forced-shims.go | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ + linker/linker.cpp | 11 ++++++++-- + 3 files changed, 84 insertions(+), 2 deletions(-) + create mode 100644 linker/forced-shims.go + +diff --git a/linker/Android.bp b/linker/Android.bp +index 2e2ef3342..182a70353 100644 +--- a/linker/Android.bp ++++ b/linker/Android.bp +@@ -1,3 +1,23 @@ ++bootstrap_go_package { ++ name: "soong-forced-shims", ++ pkgPath: "android/soong/forced_shims", ++ deps: [ ++ "blueprint", ++ "blueprint-pathtools", ++ "soong", ++ "soong-android", ++ "soong-cc", ++ ], ++ srcs: [ ++ "forced-shims.go", ++ ], ++ pluginFor: ["soong_build"], ++} ++ ++forced_shims_defaults { ++ name: "forced_shims_defaults", ++} ++ + cc_library_static { + name: "liblinker_malloc", + defaults: ["linux_bionic_supported"], +diff --git a/linker/forced-shims.go b/linker/forced-shims.go +new file mode 100644 +index 000000000..4a973be62 +--- /dev/null ++++ b/linker/forced-shims.go +@@ -0,0 +1,55 @@ ++// Copyright (C) 2017 The LineageOS 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. ++package lineage; ++ ++import ( ++ "android/soong/android" ++ "android/soong/cc" ++ ++ "github.com/google/blueprint" ++) ++ ++func init() { ++ android.RegisterModuleType("forced_shims_defaults", forcedShimsFactory) ++} ++ ++func forcedShimsFactory() (blueprint.Module, []interface{}) { ++ module, props := cc.DefaultsFactory() ++ android.AddLoadHook(module, forcedShims) ++ ++ return module, props ++} ++ ++func forcedShims(ctx android.LoadHookContext) { ++ type props struct { ++ Cppflags []string ++ } ++ ++ p := &props{} ++ p.Cppflags = globalDefaults(ctx) ++ ++ ctx.AppendProperties(p) ++} ++ ++func globalDefaults(ctx android.BaseContext) ([]string) { ++ var cppFlags []string ++ ++ device_forced_shim_libs := ctx.DeviceConfig().ForcedShims() ++ if (len(device_forced_shim_libs) > 0) { ++ cppFlags = append(cppFlags, "-DFORCED_SHIM_LIBS=") ++ cppFlags = append(cppFlags, device_forced_shim_libs) ++ } ++ ++ return cppFlags ++} +diff --git a/linker/linker.cpp b/linker/linker.cpp +index 8cafa6ea8..469eb4ab8 100644 +--- a/linker/linker.cpp ++++ b/linker/linker.cpp +@@ -715,8 +715,7 @@ static void reset_g_active_shim_libs(void) { + } + } + +-void parse_LD_SHIM_LIBS(const char* path) { +- g_ld_all_shim_libs.clear(); ++void parse_shim_libs(const char* path) { + if (path != nullptr) { + // We have historically supported ':' as well as ' ' in LD_SHIM_LIBS. + for (const auto& pair : android::base::Split(path, " :")) { +@@ -730,6 +729,14 @@ void parse_LD_SHIM_LIBS(const char* path) { + reset_g_active_shim_libs(); + } + ++void parse_LD_SHIM_LIBS(const char* path) { ++ g_ld_all_shim_libs.clear(); ++#ifdef FORCED_SHIM_LIBS ++ parse_shim_libs(FORCED_SHIM_LIBS); ++#endif ++ parse_shim_libs(path); ++} ++ + template<typename F> + static void for_each_matching_shim(const char *const path, F action) { + if (path == nullptr) return; +-- +2.11.0 + diff --git a/patches/build/soong/0002-soong-Add-a-function-to-return-list-of-forced-shim-l.patch b/patches/build/soong/0002-soong-Add-a-function-to-return-list-of-forced-shim-l.patch new file mode 100644 index 0000000..479a4a5 --- /dev/null +++ b/patches/build/soong/0002-soong-Add-a-function-to-return-list-of-forced-shim-l.patch @@ -0,0 +1,25 @@ +From cf146811021a5f267faef7d191aa3c3a073d2dfa Mon Sep 17 00:00:00 2001 +From: Mister Oyster <oysterized@gmail.com> +Date: Mon, 18 Dec 2017 13:14:35 +0100 +Subject: [PATCH] soong: Add a function to return list of forced shim libs + +Change-Id: I87343b922019db4240148ed9f5c04bfa37f9dd4b +--- + android/config.go | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/android/config.go b/android/config.go +index 268d121..4bae523 100644 +--- a/android/config.go ++++ b/android/config.go +@@ -501,3 +501,7 @@ func (c *deviceConfig) CoverageEnabledForPath(path string) bool { + } + return coverage + } ++ ++func (c *deviceConfig) ForcedShims() string { ++ return String(c.config.ProductVariables.Lineage.Linker_forced_shim_libs) ++} +-- +2.11.0 + diff --git a/patches/install.sh b/patches/install.sh index 43ce4a0..9073f82 100644 --- a/patches/install.sh +++ b/patches/install.sh @@ -4,7 +4,7 @@ echo $1 rootdirectory="$PWD" # --------------------------------- -dirs="build/make/core build/soong frameworks/av frameworks/base hardware/interfaces system/core" +dirs="bionic build/make/core build/soong frameworks/av frameworks/base hardware/interfaces system/core vendor/lineage" # red + nocolor RED='\033[0;31m' diff --git a/patches/uninstall.sh b/patches/uninstall.sh index 4410174..793404d 100644 --- a/patches/uninstall.sh +++ b/patches/uninstall.sh @@ -4,7 +4,7 @@ echo $1 rootdirectory="$PWD" # --------------------------------- -dirs="bionic build/make/core build/soong frameworks/av frameworks/base hardware/interfaces system/core" +dirs="bionic build/make/core build/soong frameworks/av frameworks/base hardware/interfaces system/core vendor/lineage" for dir in $dirs ; do cd $rootdirectory diff --git a/patches/vendor/lineage/0001-lineage-Export-forced-shims-list-to-soong.patch b/patches/vendor/lineage/0001-lineage-Export-forced-shims-list-to-soong.patch new file mode 100644 index 0000000..ac517c2 --- /dev/null +++ b/patches/vendor/lineage/0001-lineage-Export-forced-shims-list-to-soong.patch @@ -0,0 +1,37 @@ +From dd9e633d2274339daf03ab49f52a36332f1fbdc2 Mon Sep 17 00:00:00 2001 +From: Rashed Abdel-Tawab <rashed@linux.com> +Date: Wed, 8 Nov 2017 17:41:47 -0500 +Subject: [PATCH] lineage: Export forced shims list to soong + +Change-Id: Ie53c39e194ca4f15317beb4c485acf01b7d78781 +--- + build/soong/android/variable.go | 1 + + build/soong/soong_config.mk | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/build/soong/android/variable.go b/build/soong/android/variable.go +index c56c36b8..c6e0e587 100644 +--- a/build/soong/android/variable.go ++++ b/build/soong/android/variable.go +@@ -6,5 +6,6 @@ type Product_variables struct { + } + + type ProductVariables struct { ++ Linker_forced_shim_libs *string `json:",omitempty"` + Needs_text_relocations *bool `json:",omitempty"` + } +diff --git a/build/soong/soong_config.mk b/build/soong/soong_config.mk +index 331f123c..6f978537 100644 +--- a/build/soong/soong_config.mk ++++ b/build/soong/soong_config.mk +@@ -4,6 +4,7 @@ lineage_soong: + $(hide) (\ + echo '{'; \ + echo '"Lineage": {'; \ ++ echo ' "Linker_forced_shim_libs": "$(LINKER_FORCED_SHIM_LIBS)",'; \ + echo ' "Needs_text_relocations": $(if $(filter true,$(TARGET_NEEDS_PLATFORM_TEXT_RELOCATIONS)),true,false)'; \ + echo '},'; \ + echo '') > $(SOONG_VARIABLES_TMP) +-- +2.11.0 + |
