aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Yescas <jyescas@google.com>2023-04-07 10:35:35 -0700
committerKelvin Zhang <zhangkelvin@google.com>2023-06-09 18:54:21 +0000
commitfbfc668dc9bda9afdf9445b39a2ce3a527c6b1d0 (patch)
tree479d5987305429d72e9b1432234e5d30242d0615
parenta0e0476c3088685adadbf52c0a24b7a456db4ca9 (diff)
downloadsoong-fbfc668dc9bda9afdf9445b39a2ce3a527c6b1d0.tar.gz
16k: Align shared libraries and executables to 4k by defaultandroid13-gsi
The default ELF segment alignment will be 4096. This alignment can be overriden by setting the desired alignment in PRODUCT_MAX_PAGE_SIZE_SUPPORTED flag. The alignment has to be a multiple of the configured kernel page size. Test: Built changes for Pixel 4a, 6 and checked alignment. Bug: 276963698 Bug: 276801883 Bug: 286567905 Change-Id: Icb380041a5b27da1fa0d86b302e1e7cde9a236d7
-rw-r--r--android/config.go7
-rw-r--r--android/variable.go2
-rw-r--r--cc/config/arm64_device.go11
-rw-r--r--cc/config/arm_device.go7
4 files changed, 23 insertions, 4 deletions
diff --git a/android/config.go b/android/config.go
index ba95c5a20..8ac0c8311 100644
--- a/android/config.go
+++ b/android/config.go
@@ -93,6 +93,13 @@ func (c Config) PrimaryBuilderInvocations() []bootstrap.PrimaryBuilderInvocation
return []bootstrap.PrimaryBuilderInvocation{}
}
+// MaxPageSizeSupported returns the max page size supported by the device. This
+// value will define the ELF segment alignment for binaries (executables and
+// shared libraries).
+func (c Config) MaxPageSizeSupported() string {
+ return String(c.config.productVariables.DeviceMaxPageSizeSupported)
+}
+
// A DeviceConfig object represents the configuration for a particular device
// being built. For now there will only be one of these, but in the future there
// may be multiple devices being built.
diff --git a/android/variable.go b/android/variable.go
index 373891ae4..4bed08ad8 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -210,6 +210,7 @@ type productVariables struct {
DeviceVndkVersion *string `json:",omitempty"`
DeviceCurrentApiLevelForVendorModules *string `json:",omitempty"`
DeviceSystemSdkVersions []string `json:",omitempty"`
+ DeviceMaxPageSizeSupported *string `json:",omitempty"`
RecoverySnapshotVersion *string `json:",omitempty"`
@@ -480,6 +481,7 @@ func (v *productVariables) SetDefaultConfig() {
DeviceSecondaryArchVariant: stringPtr("armv8-a"),
DeviceSecondaryCpuVariant: stringPtr("generic"),
DeviceSecondaryAbi: []string{"armeabi-v7a", "armeabi"},
+ DeviceMaxPageSizeSupported: stringPtr("4096"),
AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 66087e6f0..5dcfdafa1 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -48,8 +48,7 @@ var (
"-Wl,-z,separate-code",
}
- arm64Lldflags = append(arm64Ldflags,
- "-Wl,-z,max-page-size=4096")
+ arm64Lldflags = arm64Ldflags
arm64Cppflags = []string{}
@@ -97,7 +96,13 @@ func init() {
"prebuilts/gcc/${HostPrebuiltTag}/aarch64/aarch64-linux-android-${arm64GccVersion}")
exportedVars.ExportStringListStaticVariable("Arm64Ldflags", arm64Ldflags)
- exportedVars.ExportStringListStaticVariable("Arm64Lldflags", arm64Lldflags)
+
+ exportedVars.ExportStringList("Arm64Lldflags", arm64Lldflags)
+ pctx.VariableFunc("Arm64Lldflags", func(ctx android.PackageVarContext) string {
+ maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported()
+ flags := append(arm64Lldflags, maxPageSizeFlag)
+ return strings.Join(flags, " ")
+ })
exportedVars.ExportStringListStaticVariable("Arm64Cflags", arm64Cflags)
exportedVars.ExportStringListStaticVariable("Arm64Cppflags", arm64Cppflags)
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index d702c6145..1adb477c2 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -181,7 +181,12 @@ func init() {
exportedVars.ExportString("ArmClangTriple", clangTriple)
exportedVars.ExportStringListStaticVariable("ArmLdflags", armLdflags)
- exportedVars.ExportStringListStaticVariable("ArmLldflags", armLldflags)
+ exportedVars.ExportStringList("ArmLldflags", armLldflags)
+ pctx.VariableFunc("ArmLldflags", func(ctx android.PackageVarContext) string {
+ maxPageSizeFlag := "-Wl,-z,max-page-size=" + ctx.Config().MaxPageSizeSupported()
+ flags := append(armLldflags, maxPageSizeFlag)
+ return strings.Join(flags, " ")
+ })
exportedVars.ExportStringListStaticVariable("ArmFixCortexA8LdFlags", armFixCortexA8LdFlags)
exportedVars.ExportStringListStaticVariable("ArmNoFixCortexA8LdFlags", armNoFixCortexA8LdFlags)